Historical and Modern JavaScript

In a discussion about which version of JavaScript people should learn, someone suggested to me that Historical JavaScript is like their 20 year old car. Both still work. The suggested that learning historical JavaScript is therefore something quite reasonable for people to do in order to be able to add JavaScript to their web pages.

I'd suggest that the analogy is perhaps a bit closer than that person suggested. Both a 20 year old car and historical JavaScript are somewhat limited in what they can do. Your 20 year old car can't reverse park itself, it doesn't have a hybrid engine to save on fuel costs, and it is more likely to break down and so have higher maintenance costs. Historical JavaScript is similar in that there are many things it can't do or requires a lot more code to do than more modern versions and it has a high maintenance cost in that if you want to use it on multiple pages you need to copy parts of it to each page and if you want to make a small change you have to hunt through a lot of code to find all the places that need to be changed.

Just as a more modern car can do older car can't, is more efficient than an older car and has much lower maintenance costs than older cars, modern JavaScript can do a lot more than older versions, it has more commands making it more efficient and it can be made completely or almost completely unobtrusive meaning that maintenance costs are much lower as the entire script is in one place.

There is one difference between a car and JavaScript though. A new car costs a lot more to purchase than an older car. People therefore buy old cars because they can save a lot of money up front and the extra costs of the older car will take quite a few years before you it reaches the point where the old car has cost you more than a new one would have. With JavaScript it is just as easy to learn modern JavaScript as it is to learn historical JavaScript. Over the past decade or so I have written four or five sets of tutorials to teach the basics of JavaScript - each has covered the same basic list of tasks that you need to know in order to start using JavaScript - only the commands themselves and where you put them has changed between the different series that I have written. Learning modern JavaScript is therefore no harder than learning historical JavaScript. Modern JavaScript only becomes more expensive than historical JavaScript (in terms of the time you are spending to learn it) when you move beyond what historical JavaScript can do and start learning all the extra things that are possible in modern JavaScript.

Just as the modern but far more expensive cars cheaper to run than the old cheap car, modern JavaScript is much cheaper to maintain than historical JavaScript. Historical JavaScript has code jumbled with HTML perhaps on many different pages while modern JavaScript has all the code together in a separate file so that you can make the change in one place and have it apply automatically to all the pages that use it. So while the version of JavaScript you learn may take you the same time to learn the same amount, the modern version will take up a lot less of your time when you are actually using it and need to make changes.

This far higher maintenance cost is acceptable with cars where buying a newer car means spending a lot more money up front but is the higher maintenance costs for JavaScript really acceptable when the cost of learning a newer version of JavaScript that has lower maintenance costs is the same as the cost of learning the older way?


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow