Hooray Node 22!!
The new version of Node is out!
Node is the runtime engine for Javascript. Emphasis on "the". The Node runtime environment.
node index.js
What happens there?
Node reads the source code, index.js
The code gets compiled, and executed within the Node environment.
Looks promising. I am still out there to grasp the full release details, but what I understood from initial reviews on Youtube, this version packs nice clean-ups and solidifies the Node ecosystem.
Node is originally a project written in C++ (or C?), by Ryan Dahl. It is one of the pieces of technology that was a bold move: at the time, Javascript, even though it had existed for a long time, was still in its infancy. The great Javascript boom of 2010s was oncoming. In 2009, Dahl liked to do code in Javascript but saw that the usefulness of the language seemed to be limited to browser-only: as web browsers all had a decent Javascript-engine in them, it was almost too easy to forget that you could not run Javascript on the CLI (shell), on your own machine.
That's when Dahl whipped up the code for first Node release. In fact, the engine that did Javascript compilation and the interiors or heavy-lifting with language compilation, was the Chrome's V8 javascript engine. Node made this available to CLI. So node itself, the engine, could take in a Javascript source file, compile it, and run the program.
Single-threaded execution model means that Node's execution model of Javascript code was.. well, we know it: Node-based apps take a request, serve it, and exit the loop. It does not get 'blocked´ by any operations. This makes the code execution also highly asynchronous, which is something that needs to be taken into account.
You should thus write JS code for Node, thinking that the interpreter keeps "passing over" the code, all the time. Nothing "blocks".
Javelins!
We wrote a piece of POC -level Javascript code, for a server called Javelins. Javelins uses express, and it listens on port 3000 for HTTP connections. Then it throws out blog posts. Basically whatever you want the routing to do. It's a simple but so far effective way to
a) get started with Node coding
b) get your hands-on with using express
c) see how a web server typically routes HTTP requests
Top comments (0)