When we think of JavaScript on the server side, our minds always think nodejs , but is this correct? What are the alternatives? Why do we need/care about these alternatives?

JavaScript on the server side has become mainstream, like sliced bread, everyone knows it, everyone has tried it, everyone uses it (Uber, Netflix even Microsoft...).

Node has made all this possible. It is a simple but not to simple runtime, that gives you enough to build powerful apps.

On my job I consider myself a polyglot developer, so I'm surrounded by Java , JavaScript and other languages all the time and this gives me exposure to different runtimes, JVM , V8 , ChakraCore and most recently GraalVM. According to their website:

GraalVM is a universal virtual machine for running applications written in JavaScript, Python 3, Ruby, R, JVM-based languages like Java, Scala, Kotlin, and LLVM-based languages such as C and C++.

Why would one care about another runtime? Well, to me it all started when I saw the Techempower Benchmark and noticed that in contrast to popular believe, JavaScript isn't really super fast! (I believe it is super productive, but speed is highly debatable). Of course benchmarks should always be taken with a grain of salt, this one is quite interesting as it compares around 300 different frameworks across different languages and runtimes.

To my despair, the best result of nodejs ranks at #52, so I decided to see what can we do to improve this. Looking at the benchmark source code turned out to not help much as there were no obvious performance bottlenecks, so I've decided to look outside of the box/ V8 .

So at the first sight, GraalJS does not seem to give us much of an improvement, a few wins here and there, but on the other hand, what the Techempower benchmarks is showing is that, on the long run, jobs on the JVM tend to be the fastest.

In order to verify my premise, I've started working on a small project called EcmaScript for Eclipse Vert.x or ES4X in short. The idea was simple:

Create a modern EcmaScript runtime on top of the Eclipse Vert.x toolkit using the capabilities of the JVM/GraalVM

In order to keep the project maintainable I've decided to keep it minimal:

Provide a commonjs module loader Develop using a node/npm style a.k.a. package.json Support debugging with chrome inspector IDE support using TypeScript Definitions

After a couple of iterations and feedback, I've decided to implement the bechmark. So I've started with:



npm init -y npm add vertx-scripts --save-dev npm add @vertx/core --save-prod npm add @vertx/web --save-prod npm add @reactiverse/reactive-pg-client --save-prod npm install

This looked pretty much nodejs friendly to me, so I've implemented the benchmark and went over the process of being reviewed by the community and being merged into the master branch. And when that happen something amazing emerged:

JavaScript and Vert.x were not just fast, but by far the fastest when compared to nodejs (or Spring Framework as a reference to the most common framework used in Java), but even faster that the pure Java counterpart of the benchmark using the same dependencies vert.x and vertx-web .

In fact the results are amazing as it puts JavaScript as the #2 fastest language in the benchmark:

So the next time you need to write high performance JavaScript server code, give a look at ES4X, or join the project and help making it even greater!!!