Why I Believe JavaScript is the Best First Programming Language to Learn


If you've never programmed before and want to start building that skill, I think JavaScript is the best place to start. I'm not claiming this to be the absolute truth, since it really depends on why you want to start and what you want to do with your programming skills. These are just my opinions and reasons why I believe JavaScript the best place to start for the average person who wants to start coding.

Universality

Until a few years ago, JavaScript was primarily a language for front-end web programming. Nowadays, it works pretty nicely for doing backend development, native iOS and Android development, scripting, and possibly more that I haven't discovered. While it may not be the best choice for most of these use-cases, it can be used for all of these, and that's hugely important for a newbie programmer. While it's easy for experienced programmers to pick up new languages on the fly and choose the best tool for the job, this probably isn't the case for someone who's just starting out. JavaScript allows a novice to dabble in many different areas without the overhead of learning many different languages and syntaxes.

I've used PHP, Ruby, and Python to create the backend of web applications. Someone who knows JavaScript can do the same with Node.js. I've used Python quite a bit to write scripts to manipulate and analyze data. Someone who knows JavaScript can do the same, also with Node, without even touching anything web-related. Native iOS and Android apps are written in Objective-C and Java, respectively. Appcelerator Titanium lets you write native apps with JavaScript. Knowing JavaScript lets you get started in many different areas, and from there you can learn the languages that are best suited to what you're trying to do.

Jeff Atwood takes this to the extreme when he says that any application that can be written in JavaScript, will eventually be written in JavaScript. I don't fully subscribe to that idea, but I think it does say something about JavaScript's usefulness.

Little to no setup

Want to write some code and see what it does? Hop on any computer, and there's an interactive environment right there in the web browser. No packages to install, nothing to set up. You don't have to deal with the terminal, which can be intimidating for someone who's never worked outside a graphical environment before. Google Chrome even has debugging tools built right in.

Even if you've never programmed before, you can go to www.google.com, type the following snippet into the JavaScript console, and press enter.

document.gbqf.q.value = "I entered this with JavaScript!"; 

The search box will then populate with the text "I entered this with JavaScript". You might not understand what you did and why it worked, but at least you were able to run a piece of code and make it do something. That's far more accessible to a beginner than installing packages, setting up an environment, possibly importing libraries, and then finally being able to write code that actually does something.

Want to learn how a for loop works? Run the following code in the browser's JavaScript console to count from 1 to 50.

for(var i = 1; i <= 50; i++) { 
 console.log(i); 
} 

Congratulations! You just used one of the most important concepts in programming using the same software you're likely using to read this post (unless you're on a mobile device).

JSON

JSON, or JavaScript Object Notation, is widely used nowadays to transmit data between different services. Want to pull data from some API? You'll likely need to understand JSON. Each language has its own way of representing data, but if you understand how JavaScript does it, you've got JSON covered with no extra effort.

C-style syntax

While I actually prefer coding in languages that are more space-based than brace-based, C is an important language to know. Many popular high-level languages are implemented in C, so doing some C coding can give you a much better understanding of what's going on behind the scenes. While knowing JavaScript does little to teach you about how things are actually implemented, coding in a language with C-style syntax makes for an easier transition to something like C or C++ if you want to go down that route in the future. I don't mean to say it will be an easy transition, but I think going from JavaScript to C would be easier than going from Python or Ruby to C.

Agree? Disagree? I'd love to hear your thoughts where you think is the best place for a new programmer to start.

UPDATE: I just came across this excellent Quora post: What's a good first programming language to learn? which addresses different reasons to get into programming and which languages are best suited for each of them.

© 2024 Sean Gransee