Science

Why You Should Just Learn JavaScript Already

It's pretty clear which programming language you should tackle first.

Flickr.com/marissa anderson

You’ve decided to learn a programming language. That’s great. Good for you. Time to consider the smartest approach.

What language should I learn?

JavaScript.

Do you want a second to think about it?

No.

Wait, what about all those other programming languages?

JavaScript was designed 1995 with the world wide web in mind. Along with HTML and CSS, it’s why the modern internet looks the way it does. If you’re learning to program to get a general sense of how code or the internet works, or if you want to make your website look pretty, JavaScript is a pretty solid bet. If you’ve ever peeled back the skin of your browser — “View Developer Source” on Chrome — there’s a very good chance the guts you’re staring at are written in JavaScript.

As Nathan Bernard, the founder of the Lrn code-learning app told Inverse in August, JavaScript has had its “too big to fail” moment. “From the very, very back part to a database to a server, to a web interface, to a mobile native application,” he said, “you can use JavaScript for every single one of those things.”

Shouldn’t I have JavaScript disabled on my computer, because I heard something about insecurities?

That’s Java, and while Java and JavaScript are both in the programming realm and share similar names, they aren’t the same thing. A huge number of websites use JavaScript; fewer require Java — as Lifehacker notes, you can safely disable the Java browser-plug in without worrying about hobbling your internet experience.

Will learning JavaScript make it easier to learn other languages?

It likely will because the underlying logic is similar, but it doesn’t necessarily need to in order to justify the time you put in. JavaScript is also a skill that has value by itself whereas a lot of other languages aren’t useful unless your multilingual (code-wise).

Python is a cool name, but I don’t really get what Ruby on Rails could possibly mean.

Ruby was the birthstone of the guy who created the language, which god suped up at MIT. Do you really want to talk about that?

No, sorry, I digress. Why should I care about JavaScript?

Each programming language has its own perks and quirks, so it boils down to what you want to do. There are several big players — C++, Ruby on Rails, Python, for instance — and a host of B-listers. If you’re a biologist who wants to quickly comb through hundreds of images to quantify the specific stained proteins, for instance, then maybe MatLab is a good choice. But JavaScript is the Tom Hanks of the A-list, it’s been around a while and it’s everywhere, specifically in the repositories of code-sharing paradise GitHub. And, because it’s relevant to the internet, we’re assuming it has at least passing relevance to you. For the amateur coder, JavaScript is widely regarded as fairly easy to pick up (though perhaps tough to master).

How should I get started?

If you’re using Chrome — sorry mobile peeps — go to “View” and select “Javascript Console” under “Developer.” Good job. You’re on your way.

What’s the first piece of code I should learn?

Drop the following into the console: javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i&DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);

Nothing happened!

Replace the ampersand with this: -

Now the page just looks insane.

Yup.

You’re kind of an asshole, huh?

Nah, just wanted to give you the opportunity to fix your first bit of broken code. The moral of the story is that details matter. Also that JavaScript can be kind of funny.

Want to get started? You could do worse than check out the aforementioned Lrn app or Code Academy’s JavaScript tutorial.

If I buy a book, which one should it be?

This one. Be eloquent.

Should I go ahead and move to San Francisco?

Probably not. Maybe Fresno.