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?

TRS-80_Model_3_01I 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.


Sign up for the O'Reilly Programming Newsletter to get weekly insight from industry insiders.
topic: Programming
  • http://MiningTheSocialWeb.com/ Matthew Russell

    As a general comment, it seems to me that the advent of IPython Notebook can be a significant game changer in the education space. Assuming an IPython Notebook server is provided to you as a student, you literally just open your web browser and start coding in a “friendly” environment with a variety of interpreted languages (a few of which meet or mostly meet all of your criteria). You get all the power of working in a shell/REPL but with the convenience of “executable paper” as opposed to a terminal window, which may be a little intimidating for beginners.

    At the end of the day, my vote would probably be for Python in an IPython Notebook environment. What does it for me is that Python forces you to write readable code and has a pseudo-code like syntax. Add in a nice work environment for projects that can mix code and prose on “executable paper” that can be trivially/nicely exported, and you have a real winner on your hands.

  • Nate

    I wish I could find someone proficient in Javascript that could help me out learning it. Provide me with some various projects to try and code, and maybe talk me through it a bit. If anyone out there has the time to help me learn, hit me up @ eloquentcode@gmail.com. Thanks…

    • Marco Angeli

      Have you ever tried Codeacademy?

      • the schmoo

        Thanks Marco, he is looking for a tutor and you shove him back into the library stacks. The library is a resource, for sure, but he is looking for a tutor.

  • Jon Roberts

    I’ve been programming for decades, and I’m still not too cool for Logo! If you think you’ve exhausted the algorithmic complexity or educational options of the language, you should try looking (again) at Turtle Geometry by Harold Abelson and Andrea diSessa. In my experience, students can start fastest using Logo via KTurtle, picking up lots of fundamentals, then move to something among Javascript/Ruby/Python/Perl (codecademy.com makes a nice introduction) for quick&dirty modern coding, and finally to the state-mandated Java/C++ for object orientation. However, if you want the kids to understand the true staples of computer science such as variables, loops, decisions, subroutines, algorithms, and recursion as early and thoroughly as possible, nothing I’ve seen is simpler or more elegant than KTurtle. Low threshold, high ceiling.

  • Cansu Aslaner

    very nice good post thanx admin

    SesliChat http://www.sesliremix.com/sesli-chat

  • http://www.obeythetestinggoat.com/ hjwp

    In the UK at least, Python seems to be the most popular choice for teaching programming. There’s quite a buzz around throwing out the old primary/secondary “ICT” (Information and Communication Technology) curriculums, which were just about teaching kids to use MS Word, and teach actual programming instead. It’s Python everywhere, except for younger kids who start out with Scratch, and Raspberry Pis a go-go. Did you know you can script Minecraft in Python on a Raspberry Pi? Show that to a 12-year old and they go nuts :)

    • MOB_i_L

      You can script Minecraft in Scratch too on a Raspberry Pi. There is a Youtube-video about that.

  • Joshua Macy

    The problems I see with Javascript as a first language are that unless you have O’Reilly’s Javascript: The Good Parts, you’re likely to pick up some really bad habits and the language gives you no clue that what you’re doing might be dangerous or not scale well. What’s more, in order to make it do something interesting you really have to dive into learning the DOM and browser, probably before you’re ready. In my experience that leads to a lot of cut-and-paste from examples on Stack Exchange by people who don’t really understand the code they’re trying to use. I wouldn’t discourage a new programmer from playing around with Javascript, particularly if they have a specific web-related project in mind, but I think for more general-purpose “I want to learn to program” I’d point them towards Python (and the IPython Notebook that Matthew Russell pointed to makes getting started with Python easier than ever).

  • Zigurd

    I don’t know if I can agree with “lightweight or non-existent IDE.” Should finding syntax errors by hand be part of learning? Is it valid to evaluate language syntax independently of IDE tools?

    Should a modern debugger, or the use of productivity tools in an IDE be left out? Can a language with threads really be properly learned without being able to inspect a running program?

    “Printf debugging” is a tough habit for some novices and intermediate-level learners to break, while the realization that threads in a running program can be stopped and variables inspected opens key insights into how computers really work. This aspect of learning about computers should be reconsidered.

    • Joshua Macy

      I can kind of see where Brian’s coming from, though. There are IDEs which will drop so much boiler-plate in your project at the push of a button that it’s not clear whether you’re really learning the language or just learning the IDE. On the other hand things like syntax highlighting, code completion, and evaluation that will drop you right on the line in error are like learning to write on a modern word processor instead of using a manual typewriter and fussing with white-out or retyping pages. I don’t see any reason doing without makes for a better learning experience.

  • msaunby

    OK, so is this a question that is best answered by a human, or a machine? What would IBM’s Watson suggest? My best guess is that in the not too distant future most programming instruction will be delivered by machines anyway, it almost is right now with the “here’s a known problem, solve it” style. In time perhaps the machines doing the teaching will experiment on the students and develop better strategies and most likely better languages.

    Right now I’d suggest adults who’ve yet to try and learn to code try Processing (processing.org). It installs easily and has lots of interesting examples.

    For youngsters I don’t know, maybe pick 4 or 5 and see how it goes. If they’re hoping to make it as a professional one language isn’t going to be enough.

  • Kevin Taberski

    It depends on what your goals are.

    As an embedded systems developer, I would “almost” urge one to start off with assembler – an incredibly hard sell in today’s environment to be sure – but an excellent way to gain an appreciation for the way the hardware actually functions.

    Teaching languages like BASIC and Pascal may be a good place to start for learning “higher” level languages, but neither (IMHO) are very good production languages. The trap with learning these languages is the desire to continue to use them – rather than move on.

    Personally, I started with Fortran, then moved on to assembler (hand assembled machine code really) because I didn’t have access to tools. I then learned Pascal which I got a bit hooked on and dabbled a bit in BASIC. Eventually I was “forced” to learn “C” because that was the language of choice of one on my employers.

    Ultimately, you may end up learning many languages. The trick is not to get too attached to your first. An analogy may be music. You need to pick an instrument to learn to read music, keep time and so on, but once you have a grasp of the fundamentals there is really no reason why you can’t pick up another instrument.

    I’m a fan of “C” and C++ mainly due to their commonality across platforms and ease of access to the hardware. I tend to use C# for Windows based applications due to its reasonable commonality to “C” and it’s ease of use regarding Windows Controls.

    Again, it depends on your goals and application.

  • Ewald Horn

    Great article, and, interestingly enough, it’s the same conclusion I’ve reached as well.

    This year, I started teaching someone programming, from scratch, a few months ago, and, after some thought, decided to start with JavaScript instead of my primary languages, C++ and Java. This choice was made after considering which language was the closest to Java / C# / C++ / Objective-C but was easier to learn.

    While I fully understand that JavaScript can be a fickle beast if not approached correctly, I am confident that the decision was the right one. With easy-to-use and understand tools like NotePad++, it’s easy to have someone learn the basic foundations of programming without getting into complexities like IDE’s etc.

    There are of course alternatives, like Python, which I really like, but I opted for JavaScript as it’s the only one that runs directly in the browser, without plug-ins or any other requirements. It’s also rather close to the Java / C# / Objective-C languages that will be required if this person wants to go into the mobile development space, which they’ve indicated an interest in.

    There are resources like Codecademy and LearnStreet that have fantastic tutorials for Javascript available, and the web is of course full of great samples and tutorials. With the rise of tools like NodeJS, Cordova and Titanium Appcelerator, I see a great deal of programming solutions that can be developed directly in JavaScript.

    My take on JavaScript is that it’s a great tool on it’s own, is a great language to start learning with and will not get in the way of someone wanting to learn other languages later on.

  • macqueen

    Definitely Smalltalk. Where the objects came from. Only 5 keywords. Pure objects, not hybrid mix of programming paradigms which complicates things. No types (you don’t need types in our natural language). Does not require files. You don’t even need a web browser to execute it. You don’t need to read hundreds of tutorials and books to learn the basics.

    There are high quality land tested libraries, some of them more than 30 years mature. Smalltalk is mostly written in itself and open for learning (check Pharo Smalltalk). And a professional visual programming environment to help newbies to find classes, methods, references through their browsers.

    The language is not syntax-oriented but problem-solving oriented. Used to teach object-oriented programming in lot of universities in Europe and South-America.

  • cyberjunkie

    When I used to teach I would start the first have of the semester using Alice http://alice.org. Very quickly I was able to teach them about objects and meathods, all while they were having fun creating interactive 3D worlds. Then the second half of the semester I would teach them Java. They learned and understood so much more Java with only half a semester, than when I taught it for a whole semester.

  • Sachin Bhutani

    Interesting article, I am also interested in publishing a guest post on your blog, on behalf of one of
    my client. Tried finding your contact information but not able to find.. please
    update so that i’ll share all details with you.

  • Alexandre Villares

    Immediately visible results & lightweight IDE: Processing.org

  • Beerman58

    I’m going to throw this out there just because it worked for me, and hasn’t been mentioned yet: what about Visual Basic for Applications (VBA), the scripting language behind any number of Microsoft Office programs? (Excel seems like the obvious place to start, but you can write macros for Word, Outlook, even Power Point.)

    Now I know there are a lot of VBA haters out there because it isn’t a “real” language, but look at the matchup: Relatively forgiving syntax? Check. Immediate visible results? Check. A lightweight IDE? Check (assuming you already have Excel for other reasons).

    Furthermore, you mention that the intro language likely won’t help you with diverse, work-specific tasks… but what workplace doesn’t have the proverbial all-inclusive-source-of-truth Excel spreadsheet that has far outgrown its original intentions and is in desperate need of elegant, custom built automation? (No workplace of the five I’ve been at, haha.) Sure, on one hand you are just enabling your peers to limp along doing in a spreadsheet what should be done in a relational database, but on the other hand, if you are the non-IT guy that just saved everyone in the office 10 minutes a day with your macro, you *will* be popular enough that Brenda from accounting will try to set you up with her daughter…

    On second thought, stick with JavaScript.

  • agungshafira

    great nice & cool…. mobil sedan corolla

  • PSD to HTML

    HTML tutorial for beginners is something that is really getting popular. Anybody willing to set up his own website, needs to have at least the basic knowledge of HTML.

    PSD to HTML

  • NG

    I cut my teeth on Pascal and COBOL. Pascal did not impair my ability to “move onto” other languages.