Writing an RTL is not easy. It’s not something you slap together over a few weeks, but requires a lot of research and testing. I wanted an RTL that was unmistakably object pascal, yet in a flavor that interfaced neatly with the reality of JavaScript. If you have no background in web development it’s easy to forget that JavaScript is no longer confined to the browser, it is also a bonafide JIT compiled and highly capable system script courtesy of node.js.
There is a reason companies like Netflix and HBO abandoned the traditional, monolithic service model (i believe they used C/C++ and Python earlier) for the more flexible and flamboyant node.js model. If you consider the data volume these companies handle worldwide, it should hint to what node.js is capable of in the right hands.
Factoid: Node.js is Javascript designed to write servers, system services and apps that run like a normal, non visual program. So once you have node.js installed on your system, you can write scalable servers that utilize both CPU and machine clustering. Using QTX you can further write the HTML5 front-end that interact with these services – resulting in a “full stack” development paradigme.
Implementing an RTL that is capable of working with both technologies is not as easy as it might sound, especially since node.js has nothing in common with browser code (except the language itself). Node.js is package based, supporting both clean JS packages (or libraries) as well as native modules. It has access to the filesystem, memory and is multi-process rather than multi threaded.
This last part, multi process, often confuse and annoy Delphi developers to no end, but keep in mind that node.js is meant to scale from tiny ARM SBCs (single board computers, like a Raspberry PI) to multi-million dollar server environments. It is tailored to happily run inside docker containers yet be at home in huge AWS cloud architectures. When you look at the big picture of industrial scale clustering, shaving 2 ms off a task with a native thread is quite frankly irrelevant.
What blew my mind with node.js is that when you install the full system, it also downloads and installs a Clang C/C++ compiler (which one depends on the OS, for Microsoft Windows it downloads the C/C++ compiler for Visual Studio community edition). Why? Because whenever you install a native package for node.js, the runtime will re-compile itself so that the native module becomes a part of the executable – and thus executes code at optimal speeds.
That is extremely powerful and impressive, especially since node.js covers more or less every operating system known to man.
Node also has a package system called NPM, which acts as a hub for literally millions of ready to use, free packages. Being able to tap into that technology and use it from Object Pascal is both exciting and a wonderful benefit. There are even drivers for good old Firebird on NPM, so using QTX to whip up some database driven back-end services is possible.
Obviously someone has to write a wrapper unit that maps the js objects so they can be used by pascal, but this is much easier than you think. It’s not like doing DLL wrappers or anything like that. Once the module is loaded you just look at the documentation for the method names (or do a writeln to the shell of the object itself) and define a pascal class that match.
So yeah, there is a lot of cool stuff available to QTX and object pascal developers that has previously been completely off limits.