Perhaps no other question is more frequently asked by new programmers than “what programming language should I learn?” Looking at Wikipedia’s list of programming languages, it’s no surprise that figuring out what language to learn first can seem extremely daunting.
To say that there is no consensus answer to this is a massive understatement. In fact, if you asked 20 fairly experienced programmers what programming language to learn, you’d be lucky to hear even two of the same answer. This is mainly because this question is naturally extremely subjective. One sect of coders will tell you to start with a high-level, object-oriented language like Python or Ruby. Another will insist that starting with anything but plain old C will mislead and misguide you. Then there’s the functional language elitists, that will tell you that those other languages are no way to learn, and that you really ought to start with something like Scheme or Haskell.
The point is, there’s no one right answer to the question of which programming language to learn first. There are, however, plenty of wrong ones. Few truly expert programmers would tell you to learn PHP (a language commonly criticized for not following proper programming conventions, while being bloated, messy, and counter-intuitive). The same is true for Visual Basic (not necessarily because it’s a bad language as much as that it’s a bad language to learn). Perl can be a tremendously useful language, and is often referred to as “the glue that holds the internet together,” but few would recommend it because it allows extremely messy and ugly code to work just fine.
Here are some criteria I recommend keeping in mind when choosing a language:
- Pick something readable. If the programming language allows you to write ugly, awful code, it’s a bad choice to start working with. Code written in the language you pick should be easy to read, interpret, and understand. This not only helps you understand your code, but allows you to read other people’s code and understand the way it works.
- Pick something interactive. A language with an interactive mode, in which you can type expressions and have them evaluated as you go, is critical for developing an understanding of how the language works. Such a language should also have a good debugger to help you troubleshoot your code, as well as letting you follow the program step by step as it is run.
- Pick something active. When you’re trying to learn a language, it’s important to make sure it’s actively used, actively developed, has resources to learn with (tutorials, ebooks, etc.), and has a strong community. If you have questions about the language, your code, or anything of the sort, you’ll be relying on this infrastructure to get answers and get help.
- Pick something simple. It’s better to start with a high-level scripting language and work with that than it is to start with, say, C, and have to deal with includes, memory management, and all that jazz.
- Pick something practical. Academically focused programming languages can be great teaching tools, but when trying to teach oneself, you’re usually better off working with something people code with in the real world.
There are a few languages that fit this criteria pretty well, but perhaps none more so than Python. Every time the question of which programming language to use pops up, Python ends up as one of the most popular choices. This is likely a combination of Python’s fairly clean syntactical rules, its versatility in being at least a pretty good choice for nearly any purpose, the many bindings in Python for working with various libraries, and the host of free resources available about it. Noted open-source advocate and hacker-culture writer Eric S. Raymond first suggested Python’s usefulness way back in 2000, when Perl was still much more popular, and many have followed in his footsteps in doing so.
Ruby, a language fundamentally similar to Python in many ways (but don’t tell either language’s fan club that, they tend not to get along) is also a very good first choice. For a while, its documentation and resources lagged behind Python’s, but it is very much catching up. It’s also still not as versatile (Python is commonly used for administrative scripts and scientific research, to name just two places where Ruby lags behind), but is still great to learn from.
Whichever language you do choose, don’t let the lesson of my previous blog post go unrecognized. Remember that more than anything, you’re learning how to program. The language you choose is more of a means to an end than anything else. If you go into it with the mindset that you’re “learning Ruby,” you’ll probably just learn Ruby. If you approach it as “learning to program through studying Ruby,” you’ll stand a much better chance of being equipped to take away everything a good language can teach you about programming as a whole.