January 25, 2020

Node.js for Python programmers



The main reason, why Python has a large amount of users is because it combines a prototyping language with object oriented programming. Similar to C++ and Java the user can create objects and classes which allows to realize more advanced projects compared to purely procedural programs. On the other hand, Python is more easily to learn than C++ because the syntax is a high level one. The combination of both feature explains most of today's widespread usage of the Python language.

What many people doesn't know is, that node.js and Javascript is the better Python. Similar to Python it can be used as a prototyping language. An easy example is the canvas element in HTML which allows to program graphics and even graphics animation. At the same time, Javascript is capable of object-oriented programming which allows to create large scale apps. It's main advantage over Python is, that the underlying virtual machine is really fast. It outperforms Python easily.

It's not very hard to predict, that Javascript will become the most successful language which will get used by more users than Python, PHP and Java combined. The only language which can't replaced by Javascript is Forth. Forth is a different language which is more powerful than Javascript but more complicated to learn. The reason is, that Forth can be realized on different machine architecture and provides it's own operating system. This is not possible with Javascript.

The reason why Python but not Javascript is widespread used in the year 2020 has historical reasons. Javascript and especially node.js are very young projects. The 1.0 version of node.js was released in 2010 and most programmers have decided to ignore it because they are familiar with classical back end language like C++, Java or Ruby. The comparison between classical language was focused on the question if compiled or modern scripting languages are the prefered choice. C++ programmers are convinced that only compiled languages are providing the maximum performance, while Python developers emphasize the advantages of an interpreted easy to learn language. The discussion about the pros and cons was easily because both paradigm had clear features. Python is a slow language, but can be written fast. While C++ is complicated to learn but can be executed fast.

The node.js framework is something which outperforms both languages. It's easier to program than C++ and it's faster then Python. This makes node.js the perfect choice for all applications. Additionally it runs under all operating systems, can be used for backend and frontend development, supports object oriented programming and has a large amount of libraries. The only thing what is missing in the node.js ecosystem is a long history and reference handbook which are introducing the subject to a larger audience. What we see today are some quickly created examples of Javascript code distributed over the internet. The result is, that the average user thinks, that Javascript isn't a real programming language but something which can be ignored.

From a birds eye perspective, node.js is the successor to Python 3. The virtual machine was programmed more efficient and it runs on different operating systems. The main feature is, that Javascript is used for creating productive code. That means, it's a prototyping language and a practical language at the same time. There is no need to rewrite existing Python code in C++, but the same Javascript code is used at the production server. This simplifies the programming workflow.

From the technical perspective it's pretty easy to write a hello world program in node.js. All what the user has to do is to type in the sourcecode into the normal programing IDE and configure the execute button with the nodejs interpreter. A click on run will work similar to execute a python program. That means, no webbrowser is needed, and if an error is there is will be shown in the console log. The difference between Python sourcecode and Javascript is minimal. The user has the choice if he likes to introduce functions or complete classes into his project. He can create a GUI application in html javascript or he can decide to write a GTK+ application for the normal desktop environment. That means, nodejs can be used outside the context of web-programming very well for normal desktop applications. If the user likes he can create additionally complex LAMP applications which are utilizing an SQL server and multithreading. But newbies can start with a normal logo graphics project as well.

The good news is, that in the past it was tested by different user how nodejs performs in comparison to Python 3. The answer is, that nodejs is 20x faster than a Python 3 program, https://stackoverflow.com/questions/49925322/significant-node-js-vs-python-3-execution-time-difference-for-the-same-code That means, nodejs is at the same speed like C or even a bit faster. And the examples measures only the cpu performance not the performance of a webserver which is working with parallel threads. The advantage of nodejs is here much more visible.

A personal tiobe index

The original tiobe index with the most famous programming languages is given here https://www.tiobe.com/tiobe-index/ My personal ranking looks different:

1. AutoIt. A macro language used for Windows scripting. The Autoit community is building aiming bots for the purpose of leveling and harvesting videogames.

2. Forth (the most powerful programming language ever invented, it's widely used by expert programmers and difficult to learn)

3. Javascript (the nodejs runtime engine has introduced Javascript to a wider audience and can replace outdated languages like PHP and Java)

4. PDDL, a planning language for building advanced robots

The Commodore 64 lives forever

Sometimes it was argued, that the Commodore 64 homecomputer wasn't a big innovation at this time. Other computers for example the Apple II was more impressive, and the Unix system V operating system was superior over the Commodore 64. But can we compare the C-64 only by it's technical specification? It's important to mentioned the complete picture. Most users are not interested in the machine itself, but they are were fascinated by the additional equipment.

In the basic form this is equal to some games, a device for making punches into the floppy disc and a joystick. But the most interesting equipment for a Commodore 64 was the books published in that time. If we are taking a look into the journals and printed books of the 1980s we will perceive a surprisingly powerful community. There were books available how to program text adventures in Basic, how to use the Geos software, how to make music with the SID chip and even graphics programming in Assembly language was explained in the books.

What is often ignored is, that it's possible to read such books without using a real commodore 64. That means, the books but not the 6510 cpu was the most fascinating part of the Commodore 64 legend. These books wasn't available before the Commodore 64 was realized. They are discussing subjects like a database, game programming and mathematics from a certain standpoint which was the beginning of the home computer revolution.

Another interesting fact was, the books about the Commodore 64 were available in normal bookshops and even in public libraries. The 1980s was the first decade in which such literature was produced.

The future of Open Source licenses

There are two major Open Sources licenses available, the MIT License and the GPL license. The advantage of both licenses is, that the user get access to the sourcecode. He can read the code and he can compile the binary file from scratch. The disadvantage is that problems are upraising if the end user forks an existing software project. Let us go into the details.

In the easiest case, the enduser is interested to download, read and execute existing sourecode. This is possible with the MIT License and the GPL license very well. Both licenses are written for exactly this purpose. The created code can spread freely over the internet and the costs for the end user is low.

The bottleneck is visible if the end user tries to do more with the sourcecode than only execute it on his computer. This is called forking. Forking means, to build on top of the sourcecode a new program. In the domain of software engineering, a library is linked into the own program and then the new software is distributed. If the end users is planning to do such things, he will run into a lot of trouble.

This is the case of the MIT License and the GPL license as well. The reason is, that every piece of code was written by a person, and the person holds the copyright on this code. Suppose, the idea is to use the libc library in the own project. The libc library is copyright protected. That means, a person in the world holds the copyright. And what is allowed and what is forbidden with the code is defined by this person. In case of the libc, the LGPLv2.1 license is valid https://en.wikipedia.org/wiki/GNU_C_Library Other library are available under a MIT license. What will happen in any case is, that after the library was used in a new project, the original author will check if the new project is fulfilling the license. That means, the enduser is not really free, but he has to negotiate with the license holder.

Suppose, the enduser is not interested in doing so. Suppose the idea is to fork an existing project and do not talk to the original author. Unfurtunately, such a software license is not available. No matter if the project was licensed under MIT, GPL or anything else, in all the cases, the copyright is reserved for the original author. The reason is, that it is a demanding task to write software. If the sourcecode contains of 100k lines of code, many manhour were invested in the past. And the copyright is protecting this invested time.

The only option for the end user to become independent from the original author and the Open Source license is to reinvent the code from scratch. That means, the user has to program it's own libc library from scratch which doesn't use the original sourcecode. That's the reason why the SCO vs. Linux case was openend a long time ago. Reprogramming software from scratch is the only option if somebody needs completely freedom from the original author.

The problem is, that even with modern software development tools like compilers and well documented sourcecode it's a demanding task to reprogram a software project from scratch. In a science fiction movie, the programmer would start a code generator which will produce it's own version of the Linux kernel. That means, the code generator gers some constraints as input and it will produce software from scratch. The software is different from existing sourcecode, so it's not copyright protected. This gives a hint how the future of Open Source will look like.

Today's licenses like the GPL license are protecting fixed code stored in files. The more advanced technique is to develop code generators who are able to produce unlimited amount of code. The generated code is new and it's not protected by the copyright law at all. This can be imagined as an advanced level generator in the Mario AI challenge. A level generator is able to produce a meaningful map from scratch which is different from any level created before. This newly generated game-map isn't protected by a software license. The problem with the Linux kernel, the glib library and most other Open Source projects is, that tha code wasn't generated automatically but it was typed in manually, and therefore it's possible for the original author to protect the code with a software license.

January 24, 2020

Node-js with gtk plugin



Installing the nodejs programming language is surprisingly easiy in fedora. A simple “sudo dnf install nodejs” will make the job. Additional packages can be installed with “npm node-gtk”, which is not recommended from the official fedora manual https://developer.fedoraproject.org/tech/languages/nodejs/modules.html but on my local PC it works.

What the user gets in return is a python like envirionment for creating easily GUI applications. But it's not normal python code, but it was written in node-js. The advantage is, that the underlying just-in-time compiler is more efficient. It has the same – or even a better – speed than C code and it can outperform Python programs easily. It's not very hard to predict, that nodejs is the next big thing in programming, or it has even reached it's height, but some programmers have ignored the situation in the past.

The full potential of nodejs is that it can be easily combined with existing browser plugins, for example threejs, webgl and similar projects. This allows to write operating system independent software. So we can say, that nodejs is the better Java? It's unclear how to define the language, becaues it's very new. In contrast to most of the other languages like C++, Java, Python and C# the amount of literature is small and many things are changing. What we can say for sure is, that serious security bugs are available, https://linuxsecurity.com/advisories/fedora/fedora-31-nodejs-fedora-2020-595ce5e3cc-12-08-57

What makes nodejs so interesting is, that it tries to reinvent the wheel at many places at the same time. There are tutorials available in which PHP programmers are teached to switch to nodejs because it's the better programming language. Ok, many languages are arguing in this way. But there are also books available in which Java programmers are educated that nodejs is a here to stay. The same is true for C programmers, Python programmers, go programmers and so on. Basically spoken, nodejs promis to become the better alternative for all programming language, except Forth ;-) That means, nodejs isn't working with the inverse polish notation which makes it a poor choice for professional programmers, but this is the only disadvantage available.

January 23, 2020

Creating DOI spam in Wikipedia

Hello world,

today i'd like to show how to use a bibtex converter for insert DOI spam into the wikipedia. What we need as input is a long bibtex file which contains a lot of bibliographic references.



This file is copy&pasted into the Bibtex-converter which was written in the famous Javascript language.



The resulting text is copied&pasted into the sandbox.



Is node.js the hidden champion?

The javascript language is used routinely in the Internet, but compared to other programming language the public awareness is a clumsy. A detailed look into node.js shows that it's surprisingly powerful concept. According to Stackoverflow, it outperforms the C language easily, https://stackoverflow.com/questions/27432973/why-is-this-nodejs-2x-faster-than-native-c/30058978

And it outperforms also old school website programming tools like PHP. The wordpress software is the most widespread blogging software in the world. A possible replacement, called Ghost, was written in node.js and according to the user it's easier to install and has a better performance. So let us analyze the facts: Node.js is better than C, and node.js is better than PHP. Does this mean, that both languages are obsolete? It's to early to answer the question, but it seems, that the project should be taken seriously.

A possible approach to replace a python gui app with node js is described here https://www.npmjs.com/package/node-gtk#example it is based on the node-gtk library and the sourcecode for the hello world app is only 11 lines in total. The only difference to python is that node.js needs normal curly brackets.

January 18, 2020

The old debate about which software license is more free

In the development of open source software licenses, it was sometimes questioned if the GPL license is really the most open license. Sometimes the BSD license is called more open because it doesn't force the other side in doing something.

The short answer to the conflict is, that only the GPL v3.0 license is the most open license available. If somebody likes to get more rights, he has to reverse engineering software from scratch. This allow him to become the owner of the code. Let us go into the details.

Suppose somebody takes the Linux kernel which has a GPL license, puts the sourcecode into the own closed source project and sells the software on the market. This is a clear violation of the GPL license and the user/company will have many problems. Critics of the GPL license argue, that this example show, that GPL is not really a free license. What they forget is, that with a MIT license the same problem is there. The MIT license works similar to the GPL license with ownership. That means, user1 creates the software and he holds the copyright. IF user2 tries to do something with the software he may violate the copyright.

To overcome the conflict, user2 has to create the software from scratch. That means, the sourcecode of user2 needs to be different than the sourcecode written by user1. Let us construct an example. User2 takes the Linux kernel. He reprogramms the software from scratch. He is not using the C language, but the C++ language for doing so. The resulting sourcecode is not the same like the original Linux project. So the original GPL license is no longer valid. User2 can choose any license he likes for the C++ software and he is allowed to use it in a closed source project.

Basically spoken the bottleneck is not the license agreement which is formulated in the GPL license, but the bottleneck is the question if user1 and user2 is using the same software. If the software is different, user2 can choose a new license. To understand the situation we have to analyze the technical aspect of coping a software. The easiest way in doing so is to use the Unix cp command:

cp file1.c file2.c

If file1 was licensed under the GPL license, then the file2 can be used only with restrictions. That means, it's possible to use the file2.c in a wrong way and a copyright violation may be the result. To overcome the issue, a more powerful tool than cp is needed: Unfurtunately, there is no computer program available which can convert C-code into C++ code. But if a company starts a project to reprogram given c code into C++ code manually, the resulting file2.cpp is independent from the original one:

file1.c -> manual reprogramming -> file2.cpp

The user can do with the file2.cpp what he likes. No matter which license was used for file1. The only thing what is important is, that file2 is very different from file1. That means, it should be a different programming language, different subfunctions and also a different GUI interface. This is similar if an artist redraw an existing photograph with a pencil. The handdrawn image can be licensed from scratch.

Risks of software licenses

The debate around Open Source licenses contains of theoretical explanation plus the real world scenario. In most cases only the theoretical side is discussed. For example, somebody may ask if GPL or the MIT license is more open. The focus on theoretical definitions is not enough, because in the reality the world is working quite different. If somebody tries to minimize the risks of copyright violations the easiest way in doing so is:

1. use a gpl licensed software as template, for example the latest version of the linux kernel

2. reprogram the software from scratch in a different programming language and with some modifications

3. give the newly created software any license you want

A possible copyright dispute is only the case if software1 is equal to software2. if both projects are using different sourcecode it's a different project and the license is different. If the step #2 (reprogram the code) is missing it's possible that in the reality some problems will be there. For example, reusing a GPL licensed software in a commercial context will produce a gpl violation and re-using a mit licensed software will generate also some trouble with the copyright owner. The reason is, that each piece of software is linked to an author. If user1 has created the software, he can define what user2 is doing with the code. The only option to real freedom is not the GPL license, but it's a situation in which user2 reprograms the code from scratch. This will produce a new copyright which is owned by user2.

The question left open is, under which constraint software1 is different from software2. For example, if in the code only some comments are different, than the software2 is not different. But if it's code rewrite from scratch in a different programming language and with different features, than the new project stands by it's own and it can be licensed from scratch.