Learning How to Program: A Guide. Part IV

What language should I start with?

(Be sure to check out part 1, part 2, and part 3 of this series if you haven't already).

Here's another question I hear a lot: "If I'm just starting out in programming, what language should I be learning?"

You'll hear a lot of different answers to this question, many passionately defended. Every programmer has a favorite way to program, preferences among programming languages, and ideas about how best to learn this complicated subject. Having taught introductory programming using a variety of languages, though, I've arrived at what I think is truly the only right answer to the question.

Which is: it doesn't much matter.

I know that this answer will send many programmers and professors howling. For that matter, it will displease many authors of computer books. It seems like every year there is a course or book offering a new way to learn introductory programming, and no one wants to think that their innovations aren't making a real difference, but unfortunately I think that's the case. Let's take a little history lesson. A long time ago, when I was a lad with little more than a Vic-20 and a dream, you were supposed to learn programming with the BASIC language. In fact, it had been invented expressly as a "teaching" language, because it was thought that "real" programming languages of the time, like ALGOL and its derivatives, were just too darn complicated and scary for the novice. In the same era there was another language called LOGO, not so well remembered now, that was a rudimentary graphics language in which you moved an imaginary "turtle" around the screen, leaving a visible trail, using commands like FORWARD 30 and LEFT 90. That language was designed to introduce schoolchildren to programming.

Not long after that the world was introduced to Pascal. This language was another ALGOL derivative, but like BASIC and LOGO it was designed as a "teaching" language, just one that included most of the features of what was then called a "modern" programming language. For a while, Pascal was the dominant language used in introductory programming courses.

Then "object-oriented" programming came along. If you don't really know what that term means yet, that's okay, just know that Pascal was not object-oriented, but object-oriented programming seemed to be the way all programming was going, and it was thought that object-oriented programming would be easier for novices to understand. So then the object-oriented language C++ became popular in introductory courses. But C++, although straightforward enough at the beginner level, has some complications at the intermediate and advanced levels. Teachers started looking for a replacement, something that was "simple," or at least "simpler," while still being "modern." Now introductory programming courses were being offered in Java, Smalltalk, and a little later, Python, and a lot of other languages besides.

The point of this discursion is to show that throughout the brief history of computer programming, teachers have tried different introductory languages, believing that they had figured out a way to make programming easier. In the end, though, learning to program remains a difficult task, and the overall success rate appears to be unchanged. What makes the learning process easy or difficult is not the language, but rather the approach and the resources. If you take a course, for example, a good teacher makes a world of difference, but also how the course is structured, how much is asked of the student, how big a step in learning is required from one programming assignment to the next.

But how, then, do you choose which language to start with? Here are a couple of suggested approaches.

You could go down to a bookstore (yes, they still exist!) with a nice selection of introductory programming books and look for a book that you like. The key here is to look for the book you like, not so much the language you like. If the writer's style draws you in, and you can easily follow the text, you're more likely to stick with it. Of course, you want to make sure that whatever programming area you are choosing is something that you can get started on relatively easily. For example, if a book is teaching Web server programming, you'll have to set up a Web server, plug-in the files needed for the programming language to execute, link the server up to some development tools, and so on, so maybe you'd rather start with something easier to set up.

Another approach is to think about the kind of programming you want to do eventually, and then select a language that will start you in that direction. Again, though, I would avoid any situation that has a complicated setup procedure -- not because I think it's necessarily beyond the abilities of a beginner, but because it's a large hurdle that can slow initial progress to a crawl, and because the goal is to find out as quickly as possible how much you actually enjoy programming. Believe me, there are lots of people who really enjoy programming who don't enjoy setting up servers and installing development tools.

So here are some particular languages to consider.

I'm going to start with C++. Among other things, C++ is used in systems programming and in the creation of heavyweight games -- by that I mean the kind of games you would play on a console or PC and pay more than $20 for. Also, as a bonus, C++ is the language used in my book. Am I really going to recommend a language on that basis? To quote Phineas: "Yes. Yes I am." If you get into programming and find that you truly enjoy it, the next, most crucial step is learning to solve problems, and I honestly believe my book is a great way to do so, or wouldn't have written it. Anyway, if you want to learn C and C++ and don't want to shell out any cash yet, a good place to start is cprogramming.com. The site contains lots of good basic information about setting up a compiler, language syntax, and so on. There's also a section on C++ books for beginners. Another great resource is cplusplus.com. There's a forum there specifically for new programmers.

If you are interested in web application programming, from small websites up to large-scale enterprise web services, you might look at Java, a C++-derived language. As a bonus, Android applications are typically written in Java, if phone app development is an interest. There are lots of good Java resources freely available on the Internet. You might as well start here: docs.oracle.com/javase/tutorial/index.html. You have several choices when it comes to free Java development environments. Personally I like Eclipse, but believe me, opinions vary. My main advice, and this goes for every language, not just Java, is to remember that the goal is to get in there and start programming. At this stage, don't spend a lot of time worrying about whether or not you're getting the "best" development environment. If you can install it on your computer and figure out how to get it to work, that's good enough. Put a check in that box and move on.

If you think Windows business application programming might be your bag, you might look into Microsoft's C#, yet another C++-derived language. Knowledge of this language will also prepare you for developing on a Windows Phone. There are almost no owners of Windows Phones, which makes learning how to develop for them kind of pointless, but that breeds a lovable underdog mentality, sort of like Chicago Cubs fans. Seriously, though, if you'd like to start with C#, you'll want to start with the official Microsoft pages, such as: msdn.microsoft.com/en-us/vstudio/hh341490.aspx (if my history with Microsoft's site is any guide, expect this link to go dead in mere minutes). From there you can grab Visual Studio Express, the free version of their development suite (which is a good C++ environment, as well).

Guess what? Pascal still exists and is still a reasonable place to start. I haven't tried this development environment, but I hear good things about Free Pascal (www.freepascal.org).

There is also Python, an interpreted language that uses a variety of programming paradigms (if that expression doesn't mean anything to you yet, don't worry, it will). The language is primarily used for scripting, both on websites and elsewhere. Some undergraduate computer science programs have switched to Python as the introductory language, claiming, of course, that students are learning more, or learning easier. I don't buy it, but it's a good place to start as any. Check out wiki.python.org/moin/BeginnersGuide.

Another scripting language is PHP, although unlike Python, PHP is explicitly a web language, with code embedded in HTML pages. As such, I don't know that it's a great place to start if you're just trying to figure out how to program or whether you like programming, unless web programming is specifically what you want to do. If so, head over to php.net/manual/en/getting-started.php.

Okay, I'm going to stop here. There are lots of other languages to choose from, but I think you're best off picking one from the list above. Once you learn the basics of programming, you should explore other languages, and that includes the funky ones like Prolog or Haskell. But trying to figure out if you like programming with an oddball language like Prolog is like trying to decide how good a seafood restaurant is by ordering something off the "landlubber" menu.

Tags: 

Share this

Learning How to Program: A Guide. Part III

What's the best way to get started?

(Be sure to check out part 1 and part 2 of this series if you haven't already).

Okay, you think you may be a good candidate for programming, and now you want to know where to start.

Your first thought might be to enroll in a class somewhere. That's logical enough; courses teach things and you want to learn. But it is probably not the right choice.

The first problem is the cost. College courses vary widely in price, but none are exactly what I would call cheap. At this stage you are primarily trying to discover your inner programmer -- or discover whether or not an inner programmer dwells within you. If it turns out the answer to that question is "no," there's no shame in that, but you would like to get that answer as inexpensively as possible.

The second problem is that choosing a good school is a difficult and time-consuming process. You might have to go through this process eventually, and I'll discuss some tips about this later, but it's a lot of effort when you just want to get your feet wet.

The third problem is that it may take several courses before you find out for sure whether or not you really enjoy programming. Depending on your prior educational experience, and where you enroll, you might not be allowed to start with a programming course, or even a computer science or information systems course at all. And depending on how the first programming course is structured, it may not be a good yardstick to measure yourself against. Lots of undergraduate computer science curriculum start with an "easy" course that gently introduces programming concepts, requiring mostly mechanical operations from the students' brains with very little demands on their problem-solving ability. Ultimately, though, problem-solving ability is what programming is all about, which is why it's the subject of my book. So what happens is that the student sails through the first course with ease, because it's really a using-the-software course, like an Excel course, and doesn't discover the kind of thinking programming ultimately requires until a later course. By that time, the student has made a substantial investment of time and money, and is reluctant to stop even if things go poorly. This situation isn't good for anybody.

Or you could run into the reverse situation, a course that's very hard for you, but is it the material or the instructor that's not clicking for you?

I want to be clear about what I am saying here. Enrolling in a course or program, whether at a college or some independent training outfit, is an excellent idea for programmers. It's just not how I would recommend you find out if you are a programmer. (I feel the same way about any field. I wouldn't suggest enrolling in law school, for example, without doing everything possible to find out if you enjoy the law first).

Instead, I would suggest trying to learn the basics of programming on your own. Wait, I hear some of you saying: "That's crazy. Programming is tough. I need someone to show me the way." You probably will need some help, but not as much as you think, and you can get the help you need without resorting to a formal class.

So, to sum up, the best way to get started is to scoop up some resources (like books or compilers, that kind of thing) and start playing around with code. Before we get down to specifics, though, we need to answer another question: what programming language should you start with? And that's another article.

Tags: 

Share this

Learning How to Program: A Guide. Part II

How I know if programming is for me?

(Be sure to check out part 1 of this series if you haven't already).

Maybe you've already gone far enough into programming that you know the answer to this question. But I've found many fledgling programmers, or people considering taking a programming, who aren't sure if they are heading down the right path.

People learn programming for a variety of reasons. Most people get into it for career reasons, but even so, the attraction of a programming career varies. For some, they see the figures from the Bureau of Labor Statistics explaining how many programmers will be needed in the future, and how much money they make, and think: here's a good job. Others might see the results of programming, such as a video game, and think, the result of the programming looks like fun, I'll bet the programming is fun, too.

Some people get into programming out of a sense of curiosity about how computers work. Others might have no expectation of a full-time career in programming, but think that learning a little programming will help them in their other tasks. As the use of computers has grown in medicine, for example, I've had many students who are also doctors or otherwise employed in the medical community who want to learn enough about programming to write database applications or macros to assist them in the management of their practice.

Of course, having a good reason for wanting to be a programmer doesn't mean that you will be a good programmer. So what are the indicators that programming is something you should pursue? Unfortunately, there's no way to know for sure until you actually get into it. In all my years of teaching beginning programming, the best indicator for long-term success I've seen is the student's level of enjoyment. A good programmer enjoys programming. I don't mean that every act of coding will bring unbridled joy, or that programming is fun in the same way that playing a favorite sport or video game is fun. But there should be a real pleasure in seeing one's program working, even if the program is a pitiable little thing that accomplishes almost nothing.

When I finish the term of a first programming course, I sometimes have students who are asking me to evaluate them on their long-term chances. The truth is that the best indication of long-term success isn't a student's grade in the course, although of course a high grade is a good sign. The best indication isn't how good those first programs are, although again, well-written programs at that stage are another good sign. No, the best indication is whether or not the student is looking forward to taking more programming courses. Often, at the end of that first programming course, I'll have a student that is battered but eager, looking forward to the next challenge. That's a student I feel good about going forward. It's when a student tells me, "I really want to take a break from programming next term," that I get concerned.

Or let me put it another way. Probably just about anybody could become a pretty good programmer if they work hard enough to become one. But make no mistake about it, programming is tough mental work. If, on some level, you're not enjoying the work, you're never going to be able to focus on it long enough to master it.

The moral of this story is, if you've never programmed before, and you think you might enjoy it, you should give it a try and find out if you're right.

Here are a list of things some might think would have some impact on the chances of a particular person's success as a programmer, but that in my experience, don't count for much of anything:

Demographic background. You may or may not think you resemble the stereotypical image of a programmer, but that has no bearing on your potential for success. I've taught Americans of every stripe, as well as students from countries all over the world. Although I sometimes notice trends in terms of learning styles, or the way they communicated with me as a teacher, I've never seen any trends in terms of ability. Good programmers can come from anywhere.

Let me also say something specifically about women programmers. As I said above, the best indication for programming success is genuine enjoyment in the task. It may be that men, taken as a group, enjoy programming more than women. But this makes no difference for a woman (or girl!--never too early to start) who wants to try her hand at it. Women who enjoy programming are just as good at programming as men who enjoy programming. So if you're a woman who is interested in programming, you are exactly the sort of person who should try it out. And there are lots of other women in programming already, so you don't have to worry that you'd be alone.

Mathematics. Computers are just machines that do things with numbers, so it's natural to think that programming skill and mathematical skill must be closely related, but that's not really the case. There are lots of excellent programmers who aren't particularly good at math. Also, there are lots of people who genuinely enjoy programming who do not enjoy math at all. In my own case, although I learned to program at an early age, and programming has always seemed natural to me, math was typically my worst subject in school, and my lowest score on standardized tests. I remember the exact moment, explaining a tricky concept in discrete mathematics, when I suddenly realized that I actually enjoyed math -- I think I was about thirty years old.

Computer Use. Unfortunately, just because a person really enjoys working with computers doesn't mean he or she will enjoy programming. I guess the reverse is true, though; if you don't like technology, you probably shouldn't try to learn programming. But I don't know that this ever comes up!

Tags: 

Share this

Learning How to Program: A Guide. Part I

There are a lot of people who are starting to learn how to program, or considering learning how to program, who have come to me with questions about the best way to go about that. I'm going to create a series of articles to give my best answers to the kind of questions that are typically asked:

(I'll connect these questions to other articles as I write them.)

Since I've just written a book, Think Like a Programmer, that encapsulates my best ideas on problem-solving, which I think is the most important skill a new programmer can have, you might expect me just to recommend buying my book and call it a day. But there's a lot more to it than that. I'll be talking about how my book fits into the overall picture later on, but it's just one piece of the puzzle.

So let's get started. I'm going to tag all of these posts with "learning how to program" to make them easy to follow.

Tags: 

Share this

All Is Well?

Hmm. It would be nice to have received an e-mail from my hosting service--"The fire's out in the boiler room"--but the site seems to be back to normal, minus the missing content. I've put up pages for the new book, but I'm not sure I'll put up everything else that got hosed. Please note that for now guest account registering is disabled.

Share this

Pages

Subscribe to Front page feed