Admitting that Javascript was a Mistake

There was an interesting article that was written by Guillaume Marceau recently about visually expressing the usefulness of programming languages. The article uses star-line plots to show how different programming languages compare with one another in speed and expressiveness, as each is used to solve a number of common problems. It’s always nice to check your gut reaction to different programming languages against empirical evidence. Language choice can be as varied as our food preferences, often not based solely on fact. Like our palate, we may find that our preference for our favorite programming languages change over time. As we learn more and use our language of choice to solve real problems, the initial love affair may turn into a nightmare.

At Digital Bazaar, our initial fondness for Javascript is turning into a deep distaste for the way Javascript has evolved in the browsers…

Wrongful Optimization

In the programming language visualization article, Marceau concludes that there are many functional programming languages that are very fast, compared to C and C++. He also notes that the primary factor that determines the speed of a language is it’s maturity — the number of years that it has been around. In general, one of the primary benefits of functional programming languages is that they provide closure-based programming, lock-less data structures, and eschew saving state that result in a high degree of automatic parallelization and processing throughput for problems that can be easily defined in functional terms. In theory, and sometimes in practice, functional programming is great for quickly processing large swaths of data (speed) or cleverly solving an algorithmic problem with very compact code (expressiveness).

Javascript, while not considered a “pure” functional programming language, relies heavily on functional programming techniques and is where most new programmers are introduced to many functional techniques. The use of Javascript far outweighs the use of most (if not all) functional programming languages like Haskell, and Lisp. This is mainly due to the massive deployment it enjoyed when it shipped with the Netscape browser back in the late 1990s. Javascript is still the primary mechanism for scripting, animating and modifying web pages in the web browser. Javascript has brought us such great applications as Google Maps, Digg, Gmail, Facebook, and Twitter. Recently, we have seen massive speed improvements for Javascript in Firefox, Google Chrome, and Opera. Unfortunately, the speed improvements for Javascript are mostly irrelevant because they optimize the wrong thing.

Note that when Javascript is mentioned in this article, we are talking about not only the language, but the core set of libraries and programming environment as well.

The current focus on Javascript performance largely misses the point of what we’re trying to do with Javascript in the browser — control a graphical user interface. Control of a GUI is something that is “fundamentally procedural”. By “fundamentally procedural”, I mean that there is a list of steps that you must complete in a very specific order, and tying in step interdependencies or GUI state is not straightforward in functional programming languages. To grossly over-generalize, GUIs mesh better with procedural techniques than functional ones.

Attempting to force something that is procedural in nature into a functional programming language, like Javascript, leads to the awful, sinking feeling that you get when something goes wrong in your Javascript code. Couple that with Javascript’s lack of a core set of Web libraries (like jQuery), awful functional debugger support, silent failure by design, over-dependence on closures, and single-threaded processing model and you have the Web as we know it today — shiny on the outside with a lack of substance inside.

Ours is not a blind dislike for Javascript, we have our reasons…


We're not around right now. But you can send us an email and we'll get back to you, asap.


© 2022 Digital Bazaar, Inc. All rights reserved.

Log in with your credentials

Forgot your details?