5 alternatives to Node.js and if this makes sense

Alexey Shepelev
Nerd For Tech
Published in
7 min readDec 8, 2021

--

Photo by Pankaj Patel on Unsplash

Node.js is not a perfect product, which has certain drawbacks (using JS?). Some of them are the result of erroneous decisions at an early stage of development. As is often the case, it is sometimes difficult or impossible to find an alternative to this system, especially in the enterprise sector. But if you do not need to support a large legacy code, which will supply programmers with work for many years to come, you are free to take a look at other solutions.

ASP.NET

An old friend is better than two new ones. ASP.NET has a long history. The Active Server Pages technology, which formed the basis of ASP.NET services, was developed at the end of the last century. Of course, the duration of development is not always conclusive, but the long life of a product speaks volumes. Although ASP.NET has a completely different principle of operation, it is not just an environment for running program code and connecting modules, it is a platform for creating web services. It is often used to solve problems similar to Node.js.

Whereas Node.js is the brainchild of a small team and in its most basic form is an environment for running JS programs outside a web browser with access to I/O, ASP.NET is a typical product of a huge corporation. It initially contains a large number of default libraries that immediately allow you to start developing. Node is driven forward by the developer community, and therefore the system must first be equipped with all the necessary modules, of which there are a great many. The simplest “Hello world!” in Node will bring several thousand files into the system. What’s more, quantity does not always mean quality. Sometimes it seems that developers are even ready to stuff “i++” into a separate module, which will then be downloaded a million times, and a sudden update or removal of this package will cause serious compatibility problems or crash npm. In ASP, security and updates are monitored by the Microsoft ecosystem. The libraries written by it and other large companies are carefully checked for errors and compatibility issues.

Despite many differences, one of the most important is a different approach to the distribution of computations. Node.js was a single-threaded language that used asynchronous I/O, while ASP was multithreaded and supported synchronous I/O. The first option shows great performance when working with the services that require a very intensive exchange, although your code becomes more complex. In the latest versions of the products, these differences are less visible. In Node.js and ASP.NET, the async\await pattern is used.

JS has significantly grown during its development. However, it remains a weakly typed language that is inferior to C#, which was originally developed under the direct influence of C++ that has always maintained strong typing and OOP. As a result, C# is more powerful and consistent, and it does not require such add-ons as TS. But on the other hand, due to its simplicity, JS is increasingly popular when programming microservices that do not require complex C# capabilities.

In addition to the differences in the programming languages ​​used, these platforms have different ideologies. In ASP.NET, many things are predefined and ready to use, including its file structure. But when you start working with Node.js, you have to independently select what you need, which gives a lot of flexibility but complicates development. However, ASP.NET has powerful debugging, testing, and refactoring tools.

The only thing ASP.NET is seriously inferior to Node.js is the ease of deployment. Node only needs an engine and a proxy or Docker. The platform can be configured either by yourself or you can take a ready-made VPS image, which is available from almost any hosting provider. Although ASP is cross-platform, here everything is not so easy, and only Azure users can afford ready-made images to set up servers.

Do you really need JavaScript?

Node.js was created as a runtime environment for JS since it is a simple and accessible programming language, which made it easy to run multiple scripts in parallel for the two-way communication of web application data between a browser and a server. ASP.NET was also created for writing web applications but using other methods. For instance, Deno consists of several layers above the virtual machine, which works directly with the server resources. But it is not necessary to use complex wrappers of those programming languages ​​that do not run on the server and require virtual machines.

Go

In 2007, the company’s engineers decided that C++ did not meet the current realities of computer technology. They needed efficient parallelization tools that would use the capabilities of multicore processors and distributed systems. What’s more, an automatic garbage collector and some simplifications were needed for better code readability and ease of working with types.

The goal of the developers was not to create a “better version of C++”, but to make a clearer language based on their programming experience. Go was publicly announced in 2009 and almost reached the top 10 programming languages ​​(13th in early 2012). Even Rayan Dahl said that he would rather use Go instead of Node.js. However, over time the language was almost forgotten until it turned out that its parallelization tools were well-suited for developing microservices in web applications. This returned the language to its former popularity.

Several web frameworks have been written for Go, although you don’t have to use them since the language has all the features that are necessary for programming web applications. Deno was originally written in Go.

Ruby

Unlike Go, this language is not new. It was released in 1995 and developed by a lone enthusiast, Yukihiro Matsumoto, who was eager to create an interpreted object-oriented language that would be better than Python. The language did not gain much popularity, not least because for the first couple of years, its documentation was only in Japanese. Books in English were only published in the early 2000s, and the language garnered much attention with the release of Ruby on Rails in 2005. This web framework quickly became popular, especially when Apple announced in 2007 that it would be included in Mac OS X 10.5.

As with all interpreted languages, Ruby’s speed was relatively slow, which greatly affected the performance of web applications written in Ruby on Rails. The author knew about this problem and began to develop the language version that would lose its backward compatibility but would run much faster, which he did in 2009. The speed increased significantly and was equal to web applications that supported .NET and JVM. Thanks to this, the popularity of the framework skyrocketed. In 2018, the author of Ruby released version 2.6, which implemented dynamic compilation and further accelerated the performance of applications.

Until now, the Ruby language is closely associated with the Ruby on Rails framework.

Elixir

Erlang is another programming language created by a large corporation. This time the Swedes from Ericsson did their best. In 1986, no one even thought about developing web applications, the Internet was only a project, and the language was created to run systems in real time. Erlang long remained unknown outside the company, which used it for its internal needs. In 1998, the management decided to stop supporting their language and banned its use, obliging developers to switch to Java. This led to the language being released under an open license, and it began to be distributed outside of the company that had developed it. At first, it was of interest only to a small group of scientists, until it turned out that its concept was well-suited for developing multiprocessor architectures.

In 2012, Jose Valim, one of the Ruby on Rails developers, got the idea to create a programming language for high-load systems and large websites. As a result, Elixir was developed. It is a functional programming language compiled to bytecode for the Erlang Virtual Machine (BEAM). Since the language is based on Erlang, which was developed for programming communication equipment, Elixir received some unique properties: fault tolerance, hot code replace (changing or rolling back the code of a running program, without restarting it), and the ability to work in real time. These properties allow you to create reliable high-load systems that support both horizontal and vertical scaling and operate 5–10 times faster than similar applications written in interpreted languages ​​(PHP, Ruby, Python). The creator’s place of work influenced the fact that the language used Ruby-like syntax. That’s why it is easy to learn for those who use Ruby on Rails.

Elixir is currently used by well-known companies such as Discord, Square Enix, PepsiCo, and Sketch.

But what if we use JavaScript?

But what if it is impractical to master a new programming language, as well as to bring the whole Node to the server? You can take a look at other JS runtimes.

RingoJS is a multi-threaded platform built on the JVM and optimized for server-side applications. The JS code is interpreted by the Mozilla Rhino engine, which has an impressive history. It began to be developed in 1997, back in the days of Netscape. Later the project was given to the Mozilla Foundation and posted in open source.

RingoJS applications can be deployed in any Linux platform, up to the Raspberry Pi, or on top of cloud platforms such as Google App Engine. The module system of RingoJS is based on CommonJS, and you can even use some Node.js modules. Also, the Ringo engine allows you to integrate libraries written in Java.

PurpleJS is another simple JS framework that runs on the JVM. Nashorn (also Rhino) developed by Oracle is used as the JS engine. It cannot be said that this is a full-fledged replacement for Node since the framework does not use the asynchronous mode and Nashorn has no CommonJS support, but it is very lightweight and does not require restarting the service after changing the code.

Vert.x is not a framework but a polyglot set of tools that allow you to create fully asynchronous reactive web applications, as well as microservices and network utilities that run on the JVM. The supported languages ​​are not limited to Java and JS. You can also write applications in Groovy, Ruby, Scala, and Kotlin. A module system with a centralized repository is supported. Vert.x can be easily expanded and scaled.

It’s funny that the project was initially named Node.x, then it was renamed to avoid legal issues since the goals when creating Vert.x were the same as those of Node.js. Tim Fox (creator of Vert.x) said that he was inspired by Dali’s success and wanted to create Node.js on the JVM.

--

--