August 31, 2019

What can we learn from node.js and golang?

Every programming language which is developed from scratch is telling a story to the audience. In case of mainstream languages like C++ and Python the plot is well known. C++ is the defacto standard for creating super efficient software, while Python can be utilized for prototyping new sourcecode. The story of some recent languages like node.js and golang is not told very often but they have contributed a lot to the overall domain of computing.

Node.js and golang have become famous, because they support the idea of creating a RESTful API. RESTful is a network interface to connect existing programming infrastructure. It solves basically the problem how the different coding standards like C++, Java, Python, PHP and Lua can communicate to each other without convince the other side to switch the programming language.

To understand why this is important it make sense to describe the typical programming dialect controversy. The standard problem for newbies is, that there are around 50 different languages available and it's not possible to become familiar with all of them. So he have to pick one and hope that his language of choice will solve it's problem. Because most programmers have chosen a different language, there is a need to compare the language which results into a question like “is C++ or C# the better language?”. The problem is, that even somebody is able to answer the question he will fail in predicting the future development. It's unlikely, that C++ is able to repress C#, because both languages have a certain niche.

Instead the number of languages has grown rapidly, In contrast to the homecomputer scene in the 1980s which evolves into a single standard, called the IBM PC, there is no sign, that a single programming language will dominate all other. From the aspect of performance, C++ is often called the queen in programming, but the C++ is not strong enough to convince the other communities to switch to the language.

And exactly this is the reason why a network protocol like RESTful is an option. It helps to connect all the different languages into a single standard. The most interesting feature of RESTful is, that no one is forced into a single programming language, but it's ok to combine different languages. That means, user1 is prefering Windows 10 together with C#, user2 has chosen Ubuntu with Python, user3 has installed objective-c on a Mac OS X system and all the written code is able to talk to each other over the RESTful interface.

Sure, it's possible to create a REST server without node.js and without golang as well. Most languages like Java or Python are providing a library for this reason. But node.js and go have introduced the concept first. And that is the story they are selling to the public. And it make sense to follow the idea.

Literature

In the manual about the “8th programming language”, there is short notice about using RESTful words, https://8th-dev.com/manual.pdf (page 58)

Motivation

Why it make sense to send RESTful json formatted data over a network instead of using a single programming language for all purposes? To answer this problem we have to understand what make C# unique from Python, and what is the difference between C++ and Javascript. All of these languages were developed with a certain need. In case of C++ the motivation is well documented, because C++ is one of oldest languages available. The idea behind C++ was, that the user gets the maximum performance of a compiled language. In theory, everything can be written in C++ and the language is used today very often.

But if C++ is so great, why is the C# alternative available? The needs of C# are different from C++. C# was developed by the Microsoft company as a centralized platform for running applications. From the perspective of Microsoft it make sense to promote C# over C++. And this results into a paradox situation. It make sense to program in C# and C++ at the same time. Which results into complex infrastructure in which community A has written wonderful libraries and compilers, but community B has written different libraries and compilers.

But this is not all. Additionally to C# and C++ there is also space for another programming language called Python. The Python VM works different from the C# one, and brings it own libraries and documentation. It is easier to build different programming communities over convincing the existing programmers to stay in the same ecosystem. That means, Python programmers are not interested in writing C# libraries and C# compiler developers have no motivation to contribute to the upcoming C++20 standard. The prediction is, that his kind of heterogeneous infrastructure will grow in the future. That means, in the next 10 years, new programming languages will upraise but existing one will become used more often as well.

An inofficial clearing house which mirrors the existing programming ecosystem is https://repl.it/ It's a website which allows to run sourcecode from different programming languages. Today, around 60 languages are supported. It starts with some oldies like BASIC, Forth and APL, goes over mainstream languages like C++, C#, Java, Python and Javascript and supports also specialized languages like F#, NodeJS, Go and Haskel.

Many important languages like Matlab and Assembly language are missing on the list, but it shows very well what programming is about. Not a single language but around 50 different languages are used in reality. The problem is, that it's not possible to delete some entries from the list, because each of them fulfills a certain need. The only working mode which make sense is to add more languages to the list. This will increase the confusion and makes it harder to unify existing source code infrastructure.

REST in Assembly language

As a proof of concept it might be interesting to write a RESTful server in Assembly language. Not because it's superior to the alternative written in C, but to demonstrate, how to interconnect assembly language programs with high level programs.

How can an assembly program and a Python interact without RESTful? There is no way in doing so, because both languages are quite different. They have no common standard. Python can't execute assembly, while assembly can't parse python code. None of them is wrong. Assembly language is a here to stay but Python too. The problem is, that in general it's not possible for two languages to interact with each other. The same problem is there between Turbo Pascal and C, between Java and Lua, and between AutoIt and C++. The problem get more complicated, if the sourcecode runs under different operating systems. For example, the Java programs runs on a smartphone while the server database runs on a Linux headless server.