Which Programming Language Should I Learn First?
Why Do You Want to Learn to Code?
If you're looking to go beyond one specific project or specialty, though, or want to learn a bunch of languages, it's best to start with learning the basic concepts of programming and how to "think like a coder." That way, no matter what your first programming language, you can apply those skills towards learning a new one (maybe in as little as 21 minutes). Even kids' coding apps can be useful to start with. For example, the first formal programming course I took (well, other than BASIC back in fourth grade) was Harvard's CS50, which you can take for free. Professor Malan starts the course off with Scratch, a drag-and-drop programming environment built for kids that teaches coding basics and logic—while helping you create something cool—and then he proceeds to teach you C.
We've featured several other excellent resources for learning to code over the years, such as interactive course Codecademy, but even with those you still need to choose which language to start with. So let's take a look at the differences between the more popular ones and which are most recommended as a starter language.
The Most-Often Recommended Programming Languages for Beginners
Most of the "mainstream" programming languages—such as C, Java, C#, Perl, Ruby, and Python—can do the same—or nearly the same—tasks as the others. Java, for example, works cross-platform and is used for web apps and applets, but Ruby also can do large web apps and Python apps similarly run on Linux and Windows. SOA World points out that because many languages are modeled after each other, the syntax or structure of working on them is often nearly identical, so learning one often helps with learning the others. For example, to print "Hello World," Java and C# are syntactically similar just as Perl and Python are:
They differ, however, in how easy they are to set up and get into. SOA World continues:
Here's a quick comparison of the most popular programming languages:
C: Trains You to Write Efficient Code
That said, coding in C is stricter and has a steeper learning curve than other languages, and if you're not planning on working on programs that interface with the hardware (tap into device drivers, for example, or operating system extensions), learning C will add to your education time, perhaps unnecessarily. Stack Overflow has a good discussion on C versus Java as a first language, with most people pointing towards C. However, personally, although I'm glad I was exposed to C, I don't think it's a very beginner-friendly language. It'll teach you discipline, but you'll have to learn an awful lot before you can make anything useful.
Java: One of the Most Practical Languages to Learn
Java is the second most popular programming language, and it's the language taught in Stanford's renowned (and free) Intro to CS programming course. Java enforces solid Object Oriented principles (OOP) that are used in modern languages including C++, Perl, Python, and PHP. Once you've learned Java, you can learn other OOP languages pretty easily.
Java has the advantage of a long history of usage. There are lots of "boilerplate" examples, it's been taught for decades, and it's widely used for many purposes (including Android app development), so it's a very practical language to learn. You won't get machine-level control, as you would with C, but you'll be able to access/manipulate the most important computer parts like the filesystem, graphics, and sound for any fairly sophisticated and modern program—that can run on any operating system.
Python: Fun and Easy to Learn
Many people recommend Python as the best beginner language because of its simplicity yet great capabilities. The code is easy to read and enforces good programming style (like indenting), without being overly strict about syntax (things like remembering to add a semicolon at the end of each line). Patrick Jordan at Ariel Computing compared the time it takes to write a simple script in various languages (BASIC, C, J, Java, and Python) and determined that while the other languages shouldn't be ignored, Python: requires less time, less lines of code, and less concepts to be taught to reach a given goal. […] Finally programming in Python is fun! Fun and frequent success breed confidence and interest in the student, who is then better placed to continue learning to program.
SOA says Python is an absolute must for beginners who want to get their feet wet with Linux (or are already familiar with Linux). Python's popularity is also rising quickly today thanks to wide adoption on popular websites like Pinterest and Instagram.
Choosing Your Path
One last consideration is whether or not you might want to go from coding as a hobby to doing it as a career. Dev/Code/Hack breaks down the different job roles and the skills you should pick up for them:
Back-end/Server-side Programmer: Usually uses one of the following: Python, Ruby, PHP, Java or .Net. Has database knowledge. Possibly has some sysadmin knowledge.
Mobile Programmer: Objective-C or Java (for Android). HTML/CSS for mobile websites. Potentially has server-side knowledge.
3D Programmer/Game Programmer: C/C++, OpenGL, Animation. Possibly has good artistic skill.
High-Performance Programmer: C/C++, Java. May have background in mathematics or quantitative analysis.
In the end, though, there's no one way to get started learning to code. The most important thing is to learn the fundamentals through "scratching your itch," so to speak, with working on a problems you want to solve or something you want to build.