Which Language Should You Learn First?

If everybody should learn to code, what's the right tool for learning?

What’s the best programming language for a beginner to start with?

It seems like a simple question, and one that lots of aspiring developers ask themselves, but it’s actually somewhat loaded. Are you asking because you want to get a job as a developer? Because you want to get in on the mobile app craze? Because you’ve been tasked with improving your company’s web offerings, even though you’re not a developer? Or just out of personal interest, for the fun of it?

I fell into the “for the fun of it” category when I first learned at the age of 11, by taking a weekend class in BASIC at a local private school, on a good old TRS-80 Model III. Why BASIC? Because that was pretty much the only beginner language used at the time, if you were too cool for Logo. In high school, I learned BASIC again before moving on to Pascal. I never wrote anything terribly advanced in either language, but the experience gave me a good basic grounding in understanding how programming languages work—procedural ones, anyway.

For the purposes of this discussion, I’m going to try to consider the question in a vacuum. I’ll assume the goal is “I want to know more about how to write code in a current language.” If you need to know a language for a specific work task, then the choice is probably made for you already.

I believe a good beginning programming language should have the following characteristics:

  • A relatively forgiving syntax. This isn’t to say that a starter language should encourage bad habits. However, a language shouldn’t require developers to master the debugger before they see their first running application.
  • Immediately visible results. For a novice programmer, writing simple starter applications, immediately getting to see what you wrote translate into some kind of results on your screen is the best way to keep interest high. If you need to mess around with a bunch of different includes or libraries before you get to see something, that interest will wane.
  • A lightweight or non-existent IDE. Again, for a novice programmer, the tools shouldn’t get in the way of seeing the results. If you have to spend time installing or configuring an IDE, you’re not coding.

Based on those criteria, JavaScript fits the bill nicely. The loosely typed nature of JavaScript makes the syntax somewhat more forgiving than traditional OOP languages, but most of the syntactical rules are similar enough to C++ or Java that a transition to the more formal languages wouldn’t be too difficult. Although there are plenty of JavaScript editors available if you want to use them, in a pinch you could write the code in any text editor and run it in your browser—it’s hard to get more lightweight than that. Because the code runs in the browser, it has more visual punch than running in a terminal window…even if the output is just text, seeing it in a browser, like a “proper” web page, has a more satisfying effect.

It’s not much of a stretch to consider JavaScript as a good starter language, although I admit that I was surprised when I first heard it suggested, but that’s probably my old-school C-bias talking. A number of universities, including Stanford, Drexel, and Tufts, use JavaScript in their introductory computer science classes. The gifted program at my son’s middle school is successfully teaching JavaScript to 12-year-olds. It’s easy enough to learn, but scales nicely to more formal languages in ways that the traditional “learning” languages like Logo or Scratch don’t.

JavaScript isn’t the only example that meets those criteria; you could make decent arguments for Python or Ruby, and those are good choices as well. The current popularity of JavaScript plays a role, though, as there will be more resources for learners, and more libraries and frameworks to explore as the novice stops being a novice. That’s a pretty fine distinction, though; if you have a local class with a great instructor who’s teaching Ruby, you won’t set yourself back by learning it.

I suspect that the answer to the question varies over time, and will change again in the next decade. JavaScript is also a pretty safe answer in this time and place; it’s widely popular, and has lots of fans right now. I imagine there’s somebody out there who’s certain that the best language for beginners is Haskell, or Ada, or R. If that’s you, tell us about it in the comments.

tags: , ,

Get the O’Reilly Programming Newsletter

Weekly insight from industry insiders. Plus exclusive content and offers.

  • ponkhead

    learn lisp now or you will never be a decent programmer ever. your brain needs lisp to learn to programme and if you dont use lisp and do everything in lisp for the rest of your lives then you will have bugs all over your code, only lisp has zero bugs in the code. if you dont believe me then read land of lisp, it shows you in detail the bugs that will enslave you if you dont use lisp forever.