Let's Learn JavaScript - Using JavaScript

I really love JavaScript.

I’ve learned and used several programming languages, like C and Java, Ruby and Elixir, even Objective-C. All of them are nice and powerful, but I never really loved any of them as I love JavaScript.

Maybe because none of them are so surprising as JavaScript. After so many years of using JavaScript, I’m still surprised by something, I still hit the weirdness of the language. But strangely, instead of hating that, I like the language even more.

So I’ll tell you from the start:

Learn JavaScript only if you are prepared to think differently and you have an open mind.

JavaScript is the world’s most misunderstood programming language. Partially because it’s different from other languages and most people learn it after they’ve learned something else. Partially because at first JavaScript looks so deceivingly simple and similar to what people already know so they think they know JavaScript even if they don’t.

All programming languages have weird parts. All have good and bad parts. But everybody likes to make fun only of JavaScript. Why?

Because JavaScript is one of the most used programming languages in the world.

People using as main programming language something else are also using JavaScript as a secondary language. No other programming language is used so much as a secondary language.

The past

Brendan Eich created JavaScript in 1995 while working at Netscape. He implemented JavaScript in 10 days. As you can guess it was not perfect.

JavaScript has (almost) nothing to do with Java:

  1. The similar name is a marketing gimmick rather than good judgment.
  2. Due to the same marketing reasons, he was pressed to make JavaScript a bit more Java-like.

After the JavaScript was shipped in Netscape Navigator, Microsoft reversed engineered the language, as it was at that time, with all the problems. Then they added it in Internet Explorer.

Netscape was horrified. They tried to maintain control by standardizing JavaScript as ECMAScript. But it was too late, Microsoft didn’t let them, broken parts remained.

It would take years to fix some of them. Others will never be fixed.

The weirdness

Some will say terrible things about JavaScript. Many of these things are true. When you write something in JavaScript for the first time, you can quickly despise it.

It will accept almost anything you typed but interpret it in a way that was completely different from what you meant. This, of course, means that you don’t have a clue what are you doing, but the real issue is that:

JavaScript is ridiculously liberal in what it allows.

The idea was that it would make programming in JavaScript easier for beginners. In reality, it makes finding problems harder because the system will not point them out to you. It will just try to make sense from what you tell it to do.

This flexibility also has its advantages, though. It leaves space for a lot of techniques that are impossible in more rigid languages. After learning the language properly and working with it for a while, the chances are you will actually like JavaScript.

The katana

There is a meme out there that compares programming languages with weapons. In that world, where Java is a panzer and C a fighter plane, JavaScript is merely a Samurai sword, a katana.

A katana can easily break in the hands of a barbarian, but it is deadly in the hands of a samurai. And so is JavaScript.

JavaScript is not so powerful and can’t do so much damage as others. But it is much leaner and flexible. You’ll never run out of fuel or ammunition, and no one will hear you coming.

If you want to master JavaScript you’ll have to become a Samurai. You’ll have to master the katana and be careful not to break it or cut yourself with it.

Katana

Now you know what to expect from JavaScript. The road ahead is dark and full of terrors.

In the next part of this tutorial, we’ll start to write some code.

    Want to learn more?