JavaScript - From Obscure Language to Mainstream Language for Serverless

JavaScript was for decade considered a failed language. But now it is a mainstream multipurpose language that also fits perfectly with serverless solutions. Tuesday, March 5, 2019

JavaScript was created over 10 days in May 1995 by Brendan Eich. You read it correctly — 10 days! Not several years like any other language (Java, C# …), but just 10 days and it still remains mostly the same as the first version. Yes, it has been improved, but the core is the same.

That it was designed in 10 days has some consequences. Some?!? There are numerus blogs written about it, memes, and sarcasm talks about strange design decisions. JavaScript was almost not used for about 10 years, although it was the only language that ran in a browser. It was mainly used for simple dialog messages to the user and for showing and hiding some content. It was slow, buggy, and incompatible between browsers. In 2000, I attended several lectures of one of the best web experts at the time in our area. His lectures always began with the question: "Who likes JavaScript?" Then he waited for a few seconds. No one ever raised their hand. Then he proudly concluded: "I know nobody likes JavaScript!!!" Another respected expert told us at a lecture that if you love JavaScript you have Stockholm syndrome — a psychology deviation when the hostage develops a psychological alliance with their abductor. In this case, JavaScript is the abductor, because you go through so much suffering learning all the obscure parts.

Lambda Live Debugger Banner

Belief prevailed that the replacement of JavaScript was mandatory. But there was no other language running in the browser. Then in 2008, Douglas Crockford wrote the book The Good Parts and showed us the way that the language could be useful. It actually showed that it is like an ugly duckling hiding its true beauty. And what is the beauty? It is a functional prototypal language that you can morph to use in various ways. As a functional language or as an object language and anything in between. But mostly, the key benefit is its asynchrony nature. For a long running operation (like calling a server) you have to create another function that receives the result. And in the meantime, the thread can do other stuff. This was later made easier to use with promises and the async/await pattern. But the concept is the same — it does not use resources (thread) while you wait for the other work to finish.

The speed was also an issue for JavaScript. Because it was the only language that runs in the browser, it was the blocker for Google to expand its empire. Google did not wait and it built Chrome with its JavaScript engine V8 that raised the speed to the level compared to C# and Java, but not only the speed of execution. They optimized the startup to respected degrees, and the resources that JavaScript needs are minimum. You do not see a slow running computer because you have 20 tabs open in a browser.

Meanwhile, C# and Java ruled the servers. Servers were big monsters that rarely stopped. A long startup time of the environment was never the issue because they didn't serve user requests until they were fully initialized.

Then came serverless. We do not use monster servers anymore, but small servers/containers that start and stop according to the scaling requirements. JavaScript's short startup time, low needed resources, and fast execution is perfect for serverless. In an environment where big bungling C# and Java act like an elephant in a shop of porcelain, JavaScript was a perfect fit for serverless implemented in Node.js, which use Google V8.

The complexity and ugliness of JavaScript syntax was also the issue and still is. It was greatly improved with new versions. The huge shift was the arrival of TypeScript. A language that transpiles to JavaScript, brought most of the feature's that enterprise languages such as C# have. Its most important feature were types that made it easier to build a bigger, more complex system.

It is really surprising how history turns.