Advertisement

Article

Learning to program 2 – and the winner is…

Fabrizio Ferri-Benedetti

Fabrizio Ferri-Benedetti

  • Updated:

I’ve wanted to learn how to program for years, but I’ve never got round to doing it. In this series, I’m going to tell you about the trials and tribulations of programming as a novice. In this, the second episode, I’ll tell you what language I’ve chosen and why.

In the last article, I told you what I wanted from my first programming language, and which ones made my top five. I gave it lots of thought, and a few days later, I made my decision and got ready to start programming.

Learning to program 2 – and the winner is…

What I wanted

In the first article, I explained exactly what I was looking for: a popular, well-documented language that was multi-use, and whose syntax was flexible and appealing. More than anything, I wanted it to be a language I could try things out on from the start.

Remember: I’m not aiming to be as good as a computer engineer, or to make the next 3D game. My goal is much more modest: to learn the basics in programming. It’s something anyone could do.

Ruby, Python, Java, JavaScript and Perl all met my criteria. On the surface, all of them looked like good possibilities. But time was pressing on. I had to choose.

A tough choice

It’s a difficult thing to do, choose. Sometimes it seems almost cruel. I had five wonderful programming languages in front of me. To dismiss any one of them was to close the door to a whole world of possibility, and a whole lot of discussion, at least for a while.

But choosing also helps you to focus your efforts. By choosing one language and trying to learn it well, you avoid confusion. It’s true that a good programmer will end up learning more than one language (in fact it’s better that they do), but you have to start somewhere.

In the end, I went for JavaScript. When I told my programming buddies, some of them grimaced. Others were confused. And others supported my decision. Nobody, it seems, is indifferent when it comes to JavaScript. That’s a good sign.

JavaScript! Why not?

There are only two types of languages: the ones people complain about and the ones nobody uses.

Bjarne Stroustrup, creator of C++

Everyone seems to have an opinion on JavaScript. I think the best way to explain why I’ve chosen JavaScript is to tell what most people complain about, and to explain why they’re just not true.

Myth 1: “it’s a more limited version of Java”

Since it has the word “Java” in the title, many people think that JavaScript is related to Java. I also thought that, until I realized that they have hardly anything to do with each other.

The experts say that JavaScript is more like C with elements of Self and Scheme. In the words of the expert Douglas Crockford, JavaScript “is no more a subset of Java than Java is a subset of C”.

So why does JavaScript have Java in the name? For marketing reasons. JavaScript was created by Netscape, who, to secure it in the market, had the bright idea of associating it with the (then) golden boy of languages – Java.

Myth 2: “It’s not a serious language”

“In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders”
Douglas Crockford, author of JavaScript, The Good Parts

JavaScript has a complicated past. It’s still associated with the special effects used way back when the internet began. And a bad reputation is hard to shake.

Luckily, JavaScript has changed a lot. The standard it’s regulated by, ECMAScript, has pretty much everything a language could want.

Myth 3: “It’s only used in web browsers”

These days, JavaScript is used for pretty much everything: 3D games, mobile and desktop apps, and complex web applications. Windows 8 applications can be created using either HTML5 or JavaScript.

The myth that JavaScript is only used in web browsers doesn’t hold water. And what’s more – even if it were true, it wouldn’t change the fact that JavaScript is perfectly valid as a general purpose programming language.

Why? Because we spend more time on web browsers than on any other application. The browser is the new operating system, and JavaScript is its star language.

Myth 4: “It’s slow”

An interpreted language is slower than a compiled one. And JavaScipt was one of the slower interpreted languages. But it wasn’t its fault – the fault lay with both browsers and programmers.

In a recent survey, JavaScript was shown to be a medium-speed language in Google Chrome. With its incredible JavaScript V8 engine, JS code ran just as quickly as C++.

The obsession with performance amongst the JavaScript community is such that the code for complex applications is optimized to the hilt. When you have the right skills, JavaScript is a very fast language.

What do you need to get started with JS?

Once I had chosen which language I was going to learn, I gathered together some of the best learning resources and I prepared my PC to write and run my first programs.

These are the resources I chose. Most of them are free, and some of them are probably already on your computer.

A browser: Google Chrome

One of the advantages of JavaScript is that it’s already on your browser. You don’t have to install a compiler, an interpreter, or any extra tools. If you have a browser, you can go right ahead and use JavaScript.

My current browser is Google Chrome, so I chose it as a platform to try out my programs. Its engine, V8 JavaScript, is one of the fastest out there. But I could equally have used another browser.

Another advantage of Chrome is its tools for developers. When you press F12, a panel opens, with a first-class set of tools. To learn JavaScript, the console is essential.

A text editor: Sublime Text

You could write your code in the notepad, but there are some things that a code editor does better. The perfect example is Sublime Text, a code editor whose simplicity and power has totally won me over.

Among other things, Sublime Text…

  • Writes code in different colors so it’s more legible
  • Shows line and column numbers
  • Has multiple text selection
  • Uses a panel along the side to allow for easier navigation
  • Has a “distraction-free” mode
  • Can be personalized to your needs

There are many other text editors out there. If you like Notepad++, it’s another excellent option, especially as it can be used as both a notepad and a code editor.

An online course: Codecademy

I admit it: one of the reasons I opted for JavaScript in the end was that there are so many free courses online. The most impressive one is the Codecademy JavaScript course, which is free.

The course is interactive and its difficulty increases at a gentle pace. As a course for complete beginners, I recommend Getting Stated with Programming.

Books in electronic format

When you learn a programming language, it’s always a good idea to stock up on reference books. Reading is a good way to complement your practice, and to really reinforce what you’ve learned.

After doing some research and shopping around, in the end I downloaded the following titles onto my Kindle:

At the same time, I downloaded two classics, The C Language (Kernighan and Ritchie) and Thinking in Java (Eckel). Why? Because JS’s syntax has a lot in common with C and Java, and because seeing how other languages work reinforces what you’ve learned.

You might wonder if you need to learn more math. No, not really: for the majority of programs, all you need is basic arithmetic (addition, subtraction, multiplication and division), some logic, and to know what a Cartesian coordinate system is.

That is unless you want to program 3D games or physics simulators, of course.

Ready to rock and roll!

So, I’ve got my books and I’ve got my course. Now all I need to do is read them, and write my very first lines of code.

In the next chapter, I’ll take my first steps in Javascript. You’re welcome to join me! I’m pretty confident that with just a little effort, I’ll be able to write a decent program in Javascript. But why take my word for it – stop by and give it go yourself!

Ready to start? Click here!

Original article written by Fabrizio Ferri-Benedetti for Softonic ES.

Fabrizio Ferri-Benedetti

Fabrizio Ferri-Benedetti

Latest from Fabrizio Ferri-Benedetti

Editorial Guidelines