Scott H Young

The Beginner’s Guide to Learning to Program


One of the most frequent questions I get asked in emails is what’s the best way to learn how to program. In the past I’ve shied away from this question, since the internet is populated by much better programmers than myself.

However, while there are many guides to learning a specific programming languages or tool, I’ve seen relatively few dealing with managing the learning process itself. After writing code for ten years and learning over a dozen of languages to various levels of sophistication, I’ve seen it’s this process that matters more than anything else.

Even if you’re not interested in programming, I think it forms an interesting case study for learning any technical skill, so much of what I’ll say will be applicable to non-programmers as well.

I’m also hoping there’s a chance I can convince a few people to give coding a try. It’s an incredibly fun hobby, and the fact that many people do it for a living shouldn’t detract from that.

Don’t Be Afraid of Syntax

A major reason many people are scared off from trying to learn to code is well… all that code. Like reading a paragraph in a foreign language, you can sometimes make out a few words, but the rest looks like gibberish. How can someone possibly read and understand it?

Luckily syntax is the easy part! Although each language has its own quirks, the basic concepts of computer programming don’t change much from language to language, so syntax is merely a shorthand for those basic ideas.

As an example, a common idea in programming is a loop. The idea is that you want to repeat some section of instructions until some stopping criteria is reached. Once you understand the basic idea of a loop, figuring out how to do it in your language of choice is as simple as googling, “How do I use a loop in…” and you’ll get thousands of examples.

Loops are a very simple idea, but this applies for less common and more difficult programming techniques as well. When I had to learn C++ to build a graphics ray-tracing program, I wanted to create multiple shading routines separate from the rendering, so I quickly googled, “C++ function pointers” and got the exact syntax.

Syntax, just like mathematical symbols and formulas, are often the reason people without a self-professed love of nerdy things avoid learning the subject. But once you realize this is simply a short-hand for other concepts, it is easy to figure out what the syntax is if you know the concept.

Start with a Tutorial Book

The best place to start is always with a careful walkthrough. For programming, I like O’Reilly as a guide whenever learning a new language. Generally the assumed programming skill prior to starting is low, so they are a great start.

Walking through examples avoids a lot of frustration because you can type the syntax out exactly and avoid causing unintentional bugs. Getting anything working in the beginning can give you the confidence to continue forward with projects of your own design.

If you’re learning your first language, you may want to take an intro class on programming which can teach the basic concepts. Semantics are more important than syntax, so understanding the basic ideas is essential, while memorizing the exact spelling of a command usually isn’t (if you’re wrong, you’ll get an error and a quick Google search will inform you of your mistake).

Here’s some free courses which cover the basics:

  • MIT’s Intro to Computer Science – A little harder than most, but it covers basically all the programming you’ll need to get started (and then some). I did this class myself early in the MIT Challenge. Focus on Unit 1, since the later units deal more with math and electrical engineering.
  • Udemy’s Programming Classes – I haven’t done these since they didn’t exist when I was starting out, but there’s many available on different languages.
  • Google’s Code Academy – A concise intro to Python, one of my favorite languages.

The goal in the initial phase should be to get something working. Once you get that started, it usually isn’t hard to modify existing programs to get something original before moving onto projects of your own.

Which Language Should You Start With?

There are a lot of answers to this, so I don’t presume to have a universally correct one. My feeling is that, if you aren’t already a computer wizard, getting your computer prepared to start programming can be a frustrating task if you’re not used to it, and can turn many people off before they write a single line of code.

If you’re using a Mac, many programming languages come preinstalled, so you need to do very little to get started. In that case, I’d suggest Python as a starting language because it is easier to read and can start running immediately (just get a text-editor like TextMate). Ruby is also good, particularly if you eventually want to use Ruby on Rails.

If you’re using Windows, things can be a bit trickier, but you should still be able to download the compiler/interpreter for most languages and begin writing code. Google’s Code Academy tutorials provide setup instructions for Python in various platforms.

For first languages, I’d generally avoid C++ and C, because they tend to be a little less forgiving than Python. I’d also avoid web languages like PHP because they can be tricky to set up and require you to learn more at once (HTML, SQL, XML). And only take on LISP if you’re a masochist or just really like prefix notation.

Of course, the first language you should use, should be the one you want to use. So overrule my suggestions if you want to do something specific with your programming knowledge (such as smart phone apps, video games or websites), just keep in mind there may be a bit more to learn in the beginning as you familiarize yourself.

Learning by Project

Although I’ve been following the classic classroom-style curriculum for my MIT Challenge, that doesn’t mean I feel it’s the best model for self-education. The best way to learn is often by making a project that interests you and trying to build it.

Learning projects are great for programming, but it’s easy to make mistakes when designing one. Here’s the criteria I follow when setting up a project designed to teach me a new skill:

  1. It should be short. Don’t try to make a new Facebook, since you probably won’t finish and most your time will be doing repeat tasks rather than learning.
  2. It should force you to learn the technology you want to know. If you’re a beginner that could simply mean basic programming. If you’re a novice, it could mean learning multithreading, databases, GUIs or graphics APIs.
  3. It should be fun. I’ve learned more from making fun programs and games than from trying to replicate dry textbook assignments. Fun means you’ll be more motivated to work on it.

I’ve used this process extensively. When learning 2D graphics programming, I made a Space Invaders clone. When trying to learn Python’s regular expressions, I made a program that could go through all my business receipts and figure out the sales taxes I owed.

Debugging Frustration

The key barrier in any learning effort is to surpass the frustration barrier. If you do any programming, a lot of time will be spent debugging. The wrong way to approach this is to get frustrated and quit. The right way is to use debugging as an essential part of the learning process.

I’ve found there are two main types of bugs for programs that aren’t of significant complexity. There’s simple errors, the kind where you misspell a variable name or put parameters in the wrong order. These also tend to be the easiest to fix.

The second type are caused because your model of how the computer works isn’t the same as reality. And while these can be the most frustrating, they are also the greatest opportunity to learn.

My biggest mistake I made in my early days of programming was to only try to get the program working. I would try different approaches and when one worked, I would stick with it, even if I didn’t understand why my previous approach had failed.

Understanding every error can be beyond the ability of a beginner programmer. However, if you endeavor to understand why certain expressions won’t work, or certain algorithms run afoul, you’ll learn much more about the language than the band-aid method I had used in my early days.

Doing this means when you get an error, search for it online and chances are you’ll find a forum posting where someone made the same mistake. Look for the explanations given as follow-up and you can usually see an explanation into the nature of the error.

If the explanation references computing concepts which are new to you, then you can begin trying to learn about those new concepts. This way you can slowly build up your vocabulary of programming problems and designs so that you can avoid such problems in the future.

Thoughts on Learning any Technical Skill

Much of this advice is programming-specific, but the basic ideas are true for learning any technical skill, be it calculus, statistics, mechanics, chemistry, drafting or design:

  1. Don’t sweat the syntax.
  2. Start with a tutorial book (or class).
  3. Learn with projects.
  4. Use errors as a chance to learn new concepts.

Programming has to be one of the best skills I’ve learned, not only because it’s fun and rewarding, but because it teaches a lot of life lessons as well. It taught me how to build things, organize projects and set goals for myself. And, as computers become more integrated into our lives, it’s nice to know a little of the language they speak.


Print Friendly
StumbleUpon It!

This website is supported, in part, by affiliate arrangements (usually Amazon). Affiliate relationships are always marked by bolded links.


18 Responses to “The Beginner’s Guide to Learning to Program”

  1. Luis says:

    http://www.codecademy.com/
    http://www.programr.com/
    these are also webs in which to learn to program, with step to step tutorials and exercises

  2. Jeroen Hendrickx says:

    Great advice. I wholeheartedly agree with taking Python as a first language. Mine was Visual Basic for Applications, which took years to unlearn.

    For me, programming has been a crash course in human fallability. You can’t write perfect code, so you just fail, try again, test, fail again, try some more. Every failure teaches you something new.

    Which makes you wonder why so many professional programmers seem to be so arrogant and self-centered.

  3. Alexander says:

    A few people I know have tried to pick up programming. This is how it usually goes:
    1. they have an introductory book on Java or C++
    2. they get Hello World working
    3. they learn about functions and loops
    4. the learning curve steepens
    5. they put it off
    6. they forget most of what they’ve learned
    7. they lose interest
    I suggest people learn the basics of HTML in 10 seconds and start with Javascript immediately. It runs in your browser so it needs no setup and you can quickly move on to spectacular (graphical) things, so there is a quick motivational feedback. By the time they reach Javascript’s limitations they’ll have a bigger tolerance for seemingly boring things.

    It would be nice if people didn’t give up so quickly, but in reality most do, which I think is why too few people program. (Actually it’s the same with mathematics; people give up because it takes too long for the spectacular results to come.)

  4. Keith says:

    Very useful post. I’m actually just beginning to learn Python. Thanks for the info!

  5. Andre says:

    I don’t want to nitpick, but imperative programming is not the only paradigm: Functional and logic programming are also important. Although they’re not as widespread as imperative programming, they have interesting concepts that will enhance your thinking style (when it comes to programming). Alas, LISP is the only functional language you have mentioned, which you’ve argued against because of the syntax (a contradiction? :-)).

    Anyhow, I liked your article. But in my opinion, a crucial aspect is missing: the social one. It’s very motivating to know other programmers with whom you can exchange your ideas and from whom you can learn.
    Even more, once you’re familiar with basic programming concepts it becomes increasingly harder to improve your programming skills without feedback from more seasoned programmers. There are simply many subtleties that you don’t notice if they’re not spelled out for you.

  6. Eric says:

    This may be of relevance, https://www.edx.org/courses

  7. Dan M says:

    There is a lot of really good advice in this article. Some thoughts, as a professional programmer (I work at Netflix):

    1. The section on Learning By Project is *full* of useful advice. All three of those points are spot-on. If you take one thing away from this post, make it that section.

    2. I’ve never been a fan of books. I think I’ve read maybe two books about programming in my 10+ years of programming, and neither had much of an impact on my skills or motivation. If reading isn’t your thing, don’t sweat it.

    3. For a first programming language, I would suggest choosing either web (Alexander’s comment, above mine, gives many great reasons) or mobile. Making an iPhone or Android app is way easier than most people expect, and it’s immensely rewarding seeing something you’ve created run on your phone for the first time (even if it doesn’t do very much).

    4. The internet is your best friend. You can Google anything about any problem, and you’ll find useful help. Just remember to start giving back as your skills improve :)

    Great post!

  8. Marian says:

    Hi Scot! There are also other great places to start with Python.

    One of the best is the free e-book “Learn python the hard way” (http://learnpythonthehardway.org/). The HTML version is easy to browse and understand. And very well explained.

    Another good resource is CodeCademy’s Python course: http://www.codecademy.com/tracks/python

    And other good resources can and will be found on KhanAcademy (a great online library with lots of movies and lessons): http://www.khanacademy.org/cs/tutorials/programming-basics . This has the advantage that new classes are added all the time and they are of very good quality.

    And yes…learning programming may look difficult, but it’s a lot of fun!

  9. Mahfoud says:

    Thanks for the article, Great!
    Personnally, the first programming language I’ve learned is C, because it was thaught in my institute but I think that it was a really good thing for me, because when I’ve started learning high-level languages like python or php, it was easy for me to go through and understand what’s happenning deeply inside.

  10. Darion says:

    I started with HTML and CSS which I learned to begin building websites for affiliate marketing. Then as I became more interested in adding degrees of dynamism to my sites I started learning PHP.

    The best resource I’ve found so far for getting started with PHP is Tutsplus.com. You have to subscribe to the premium version for the really good stuff but look for the video series by Jeffrey Way and you’ll have found what I’m talking about.

    I am also concurrently learning JavaScript and jQuery at codecademy.com. Codecademy is a much better way to learn than simply reading from a textbook since you are able to immediately implement the code alongside the lesson. There is also a large community of users there that can help when you get stuck on a certain topic.

    As I’m learning these two languages I’m working on a side project that helps me keep track of the different methods I’ve engaged in for both personal and professional development. Whether I launch it to the world will depend on how useful I find it. However I know that it will be invaluable for my web development training.

  11. Rook74 says:

    Thanks for a great article,Scott, couldn’t have come at a better time for me. I am in the process of learning some very technical regulatory stuff in the pharma industry, and I already picked up a couple of ideas from your article. Firstly, not to be intimidated by the terminology (my translation of syntax in this case), and to focus more on meaning (the equivalent of semantics in my case), and also to dive in and google the finer points. My mistake was trying to find a resource that would explain everything I need to know but such doesn’t exist, needless to say, with your strategy (or my interpretation of it), I can definitely get going, thanks again, at least for the inspiration to try a new tact.I also like the project based learning approach, it works for me in this instance as well.

    @Alexander – great advice, I have experienced exactly what you discuss when I tried to learn programming, it’s almost like you were there! I tried Java once, went quite a bit through the tutorial material but once it slowed down (as in the results were much slower and the slog much more noticeable), I quit and then at some point tried to take on PHP together with mySQL, but again, same result. Will definitely try your advice.
    @Jeroen – there is something deeply philosophical about what you just said. I have examined my previous experience with programming languages and I believe I quit because I always had this inflated perception of my capabilities, once reality refuted that perception I quit, probably to protect my ego. But the way you put it is so refreshing. If failure is inevitable, no point in taking it badly, but harnessing it to one’s advantage is the only sensible thing to do. Great idea, thanks!

  12. Max says:

    I started off by setting up everything manually, taking the time to go through various tutorials/books, but this was 10 years ago. Now I’d definitely recommend http://www.codeschool.com/ (no affiliation) because they set everything up for you and you just type the code in their prompts. They tell you if it compiles right or not, and you get instant feedback with the lessons they teach you.

    A lot of courses are free — it’s awesome.

  13. Stephen Lee says:

    Thanks for another great article, Scott.

    One thing that I’ve found useful is using online interpreters for programming languages. If you are away from home (i.e. at work, at a library, or at a friend’s house) and don’t have the language you’re learning installed on the computer you’re using, you can use an online interpreter to practice your target language.

    How do you find an interpreter? That’s easy! Just search in Google: “online [target language] interpreter.” You can usually find a good one without much difficulty.

  14. Scott Young says:

    Andre,

    Imperative isn’t the only paradigm, but it’s probably the easiest for a beginner. LISP is a great language, I loved using Scheme (and of course there’s Haskell and others) but I would say it introduces programming in a way that is less accessible for most people who aren’t coming from a strong mathematical background.

    Prolog and logic programming are also interesting, but again, I feel they’re less intuitive for the average person. Imperative style is popular because for most programming tasks, viewing the program as a recipe to follow is an intuitive structure. There are obvious exceptions, but usually not for beginners.

    -Scott

  15. Parag Shah says:

    Great article Scott.

    I agree with Dan, in that learning with a project is the best way to learn.

    A few years back I was talking with a friend who is a self taught programmer. I asked him, what learning technique he used. He gave me an example of how he learned web programming. He said he first taught himself just enough PHP so he could make a simple page with a list of items. Then he put it behind a web server and served the static list. Then he made a text file with the list and read it from the PHP program (see how he is gradually bringing in dynamic elements) to render the list. Then he created a database and populated a table with the contents of the list (now he is talking to a database).

    Once this entire loop was setup, he created a form which the user could use to enter data, then setup authentication, and so forth.

    I think this style, where you start with something basic, and build up step by step may work well for a lot of people who want to learn programming with the project based method.

  16. Momo says:

    Scott, now that you’re coming to the end of this challenge, could you (perhaps in a future writeup) suggest how one would best acquire the equivalent of a MIT comp sci. degree, circumventing some of its inherent (classroom style?) limitations?

    Knowing what you now know, how would you devise a curriculum and instruct someone else wanting to learn comp sci/EE in 12 or less months?

    With the amount of interest in tech/programming/startups (see udemy, codeacademy, coding workshops etc), this ‘CSEE in 12 months’ could easily branch off into its own blog and gain a massive audience.

  17. Eric says:

    One thing I’d like to mention (don’t get me wrong Scott – good article!) is that, at least from what I’ve seen, recursion is the man stumbling block for aspiring programmers who get past the initlal step of understanding assignments, control flow statements, and the other basic concepts. Once you understand how recursion works, everything else is just a matter of time to understand.

    Also, functional languages are pretty cool for anyone who’s good with math and for whatever reason, hasn’t done much programming – or is looking for a chellenge! I remember that SML just irritated and confused me at first, since all the programming I’d done up until then was in C-likes (C, Java, C++).

  18. Scott Young says:

    Eric,

    Recursion can be a stumbling block, but it’s not necessary for most programming tasks. Languages like LISP make it the default pattern for loops, but I think that is unnecessarily conceptually difficult for a new programmer.

    -Scott

Debate is fine, flaming is not. Pretend that this comment form is a discussion taking place in my house. That means I enjoy constructive criticism and polite suggestions. Personal attacks, insults and all-purpose nastiness will be removed especially if it is directed at other readers.

Leave a Reply