JavaScript
Article

JavaScript Comes of Age

By Darren Jones

JavaScript will be 20 years old next year (counting from when it first debuted in the Netscape browser). It’s a language with a chequered history and carries a lot of baggage from its early years, but as it leaves its teenage years behind it, I think it’s a language that has now finally grown up.

JavaScript revolutionized the web by allowing scripts to run in a browser. But after its initial popularity it soon started to get a bad reputation and was often associated with poorly written, cut-and-pasted code that was used to create annoying pop-ups and cheesy ‘effects’. The phrase DHTML became a dirty word in web development. JavaScript also had some annoying shortcomings as a programming language.

But, despite all of its problems, JavaScript has something that other languages don’t have – reach and ubiquity. It only requires a browser to run, which means that anybody with a computer or smartphone is capable of running a JavaScript application. JavaScript has achieved the dream that Java had of being available on all platforms by using the browser as its virtual machine. And it can now run without a browser thanks to the development of engines such as Node.js.

JavaScript also has a low barrier to entry when it comes to development; since all you need to write a program is a simple text editor. It is the most popular language on GitHub by a number of measures. This means that there is a lot of JavaScript code out there and many problems have already been solved, often in many different ways. It also means that help is often easy to come by and libraries of code are very well tested.

After an awkward first decade, JavaScript spent its teenage years growing up. The revolution started with the advent of Ajax, when people started to sit up and take JavaScript seriously. jQuery then got people using JavaScript to build some serious applications and Node has taken it all to a whole new level. People have started to recognize that JavaScript is a powerful and flexible language with some cool features such as:

  • Asynchronous event-driven programming
  • Functions as objects
  • Closures
  • Prototypal Inheritance
  • Object literals and JSON

JavaScript has also proven to be flexible enough to allow solutions to be written that overcome its main shortcomings. A number of frameworks and libraries have been written to address these issues and make JavaScript a nicer language to program in. Modern web browsers have also had a big effect on the language by virtually eradicating the inconsistencies in implementation that plagued it in the past (who remembers having to write multiple versions of code just to get a simple event to work, for example?). And speed is no longer an issue as the various engines used in modern browsers are already blazingly fast, and they’re only getting faster.

I strongly believe that JavaScript will be the most important language to learn over the next few years. The way websites are developed has evolved and they are now likely to be single-page web applications that rely heavily on JavaScript to do the heavy lifting on the client side, often using modern front-end frameworks such as Backbone or Angular.js. Isomorphic JavaScript is the process of using JavaScript to program the server-side of a web application and is gaining in popularity because of the advantages of using the same language for the whole application. The data that is transported from databases is often stored in JSON format. It’s possible to build an application for iOS, Android and FireFox OS using a combination of HTML, CSS and JavaScript. The Internet of Things is a broad term used to describe anything from household gadgets to small robots, most of which are using JavaScript to interact with their APIs. In short, JavaScript is becoming the language of choice, not just for the front and back end of web development, but also for interacting with a huge number of modern devices.

SitePoint has recently published my book “JavaScript Novice To Ninja,” which takes you from the very beginning and works up to the more advanced topics in JavaScript. It begins by introducing the basics of programming, covering topics such as variables, conditional logic, loops, arrays, functions and objects in the earlier chapters. It then moves on to using JavaScript to interact with a browser environment, covering events, the DOM, animation and forms. Then in the later part of the book, more advanced concepts such as testing and debugging, object oriented programming and functional programming are covered, showing that JavaScript is capable of handling these. We also take a loom at recent developments such as HTML5 APIs, Ajax, frameworks and task runners, such as Grunt. There’s also a practical project that involves building an interactive quiz application that develops in each chapter.

If you’ve always wanted to learn how to program then now is the perfect time to get started and JavaScript is the perfect language to learn. As it moves into its 20s, JavaScript has finally grown up and is starting to go places!

More:
Comments
Hammer65

I've been checking out the new Java SDK 8 with the Nashorn js engine and JavaFX. Very nice. Would love to see a good article on using it and bundling apps using it.

BHouwens

I think JS is going to become even more popular after ES6 comes in with its improvements. I read an interesting article on the tidal wave of frameworks though. Suggested that a more atomic style of using specific little libraries for specific things might be the future.

Interesting stuff.

felgall

ES7 is quite a way through the development process now so JavaScript should continue to evolve and become more and more powerful.

It's a real pity that most college classes teach how to write JavaScript for Netscape 2-4 rather than any of the more modern versions.

Paul_Wilkins

Wow - that's equivalent to learning how to ride a horse and cart instead of getting a drivers license.

shaunmstone

A number frameworks and libraries - should be a number of...

BHouwens

Definitely. The other problem is that it will still be some time before we see this JS being used everywhere, what with slow browser upgrade adoption etc.

Amit_Yaron

I like Javascript (or ECMAScript) very much. Thanks to that language's object notation, we have a splendid lightweight data format named JSON.

daz4126

There's a bit about this in one of the later chapters in the book. I defnitely think the future will be all about small modules that do one thing very well, rather than huge monolithic frameworks that try to do everthing. This will definitely be easier when the module pattern from ES6 gets adopted.

You could even put lots of different modules together under an umbrella namespace using something like Ender or a build process, effectively creating your own custom bespoke framework.

daz4126

This is such a shame. Most modern browsers have good support for the latest JavaScript and even quite a bit of ES6. You can also use various transpilers to use most of ES6 today, so it would be good to see courses teaching the most up to date methods so that people could see what JS is capable of!

daz4126

Thanks - will try to get this changed!

daz4126

I actually think that most modern browsers are updating quite quickly, so this isn't as much of a problem as it used to be.

daz4126

I love JSON! It hits the sweet spot between being a human and machine readable data format. And the fact that it can be encoded as a simple string makes it amazingly portable!

pinoniq

(I had to add (dot) because I'm only allowed 2 links in my answer)

To start, this rand it not targeted to you personally. I like your article, it shows that JS is indeed a very mature language. One that has been around for a long while. Also comparing it to Java's all platform mission is a +1! But...

Talking about Object Oriented programming vs Functional programming in JS is simply not understanding JS.

To be honest, I'm sick and tired of all those 'write OO in JS'-tutorials. They make for bad code, var self=this; crap and people panicking when this suddenly is not this but that, or window.
As long as people write articles about JS Objects and how to write 'OO' code in JS, it will stay in puberty.

Also, stop calling it asynchronous. It simply isn't. JavaScript is a blocking synchronous language. The only asynchronous thing in JavaScript are certain browser api's. for instance the XHR object, a good answer can be found here: http://stackoverflow.com/a/2035662/2496717

You also state 'Closure' as being a cool feature of the language. Not sure you understand what a Closure is, nearly all languages have them, not so special imo.

And your last statement about learning JS as a first programming language. Couldn't agree less. Javascript is a very hard language to grasp. Just try and explain what 'this' is: http://bjorn.tipling.com/all-this or perfectionkills(dot)com/know-thy-reference/ . Add the hard to grasp prototyping + new key word, and you have yourself a very powerfull but hard to learn language.

A small snippet to end: typeof new String('foo') != typeof 'foo' && new String('foo') == 'foo'. I rest my case, hard to learn

daz4126

Hi pinoniq,

Thanks for your feedback - it's always good to see the other side of things, and the links you sent made interesting reading.

I think that JS struggles with both an OO and functional approach, but the fact is that you can do both in JS, if you want to. I'd be interested to hear why you think the OO approach is so bad?

Yes I agree that the language itself isn't asynchronous, but the way callbacks (and promises) are used makes the language behave as if it was asynchronous.

I still stand by my assertion that JS is a good language to learn for a first timer. I think the advantage is that people can learn JS using just their browser and it also gives them access to lots of other places to practice and see examples. Yes it has more quirks than most languages, but don't all languages have some difficult ideas to get your head around? I think you can get the basics of programming without running into too many JS gotchas.

Cheers,

DAZ

sshivasurya

i love javascript from server side to client side smile smile gonna rock !

sa_scott

The fact that Javascript is being used for programming hardware now is an indication of it's maturity. On a lighter note, emulation of older computers for games is far better now. Here are some examples:

No more having to faff about with software such as DOSbox, just play in browser. After years of hating the language, I love it for the above sites alone! smile

daz4126

I've just been reliving some childhood memories playing Chuckie Egg!

Yes I agree, that JavaScript's quirks and annoyances are outweighed by its ubiquity in the browser nowaday. And more and more applications are showing what it is capable of!

Pullo

Chuckie Egg!!!!
That is a blast from the past!
How many hours did I spend on that game?

daz4126

I spent many childhood hours playing this - the shock when the giant bird started chasing you!

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.