January 26, 2020

Building a simple webserver with node.js



The node.js virtual machine is a practical tool for creating server applications. A simple hello world example is given in the screenshot. To make things more interesting a for loop is used to generate a list which is redirected to the webbrowser. The most advanced feature of nodejs over normal Javascript is, that the program can be tested and improved in the IDE. It's possible to bugfix the function until it works great, and then the webbrowser can show the output from the user perspective.

The workflow for creating sourcecode is very similar to Python, that means, node.js is able to replace the Python language. The only disadvantage is, that the amount of Python tutorials is higher and they have a better quality than the few node.js tutorials. That means, the nodejs community isn't available but it has to built from scratch. To shorten the explanation a bit we can say, that the programming language in 2020, in 2021 and in 2022 as well is node.js/Javascript. That means, the advantages over normal Python is so overwhelming that every Python user will migrate to Javascript in the future. The same is true for C++ programmers, Java programmers and of course all the C# programmers.

To understand the node.js ecosystem we have to focus on failed classical programming languages. The Python language was an early to attempt to build a scripting language which supports object oriented programming. Before Python was there, object oriented programming was the same as compiled programming with C++. The perl language was known, but it wasn't supporting classes. Python has replaced Perl entirely.

But Python struggles in the performance. The Python virtual machine was always too slow. It was not able to compete with Java or C++. So the community was divided into users how are preferring Python and other who not. We can say, that node.js has solved a lot of problems. It contains of the following features:

- the performance is very fast

- it is a scripting language with fast edit-run-cycles, no need for compilation

- it runs under different operating systems with the same code

Basically spoken, nodejs combines the advantages of Python, Java, C++ and PHP into a single language. Similar to Python it can be mastered by beginners. Similar to Java it runs everywhere, similar to PHP it is very good in creating websites and similar to C++ it is very fast. The prediction is, that nodejs will replace all these languages. Or let me explain it the other way around. It's not possible that a node.js programmer will switch back to PHP if he is familar with Node.js already. That means, there is only one option towards node.js but not the other way around.