A lot of new features in NectarJS
NectarJS adds QuickJS as a new backend to compile your JS code
For iot or micro-controllers, NodeJS is too heavy. Since 3 years, we are working on differents solutions to reduce the JS executables size. Our C++ backend is not ready yet, that's why we included QuickJS as a new compilation Backend for NectarJS.
A presentation of QuickJS
QuickJS is a powerfull and compact JS engine written in C. It means that it can compile in a lot of modern OS with GCC.
Its included BigNumber library makes mathematical operations really fast. Check the bench : QuickJS Benchmark
Starting with NectarJS compilation
To install the new version of NectarJS, you need NodeJS and NPM. You can download and install it from this webpage : Install NodeJS
Once NodeJS installed, you have to install Cygwin to compile with GCC. You can download Cygwin from the official webpage : Cygwin project
Now open a shell and type :
npm install -g nectarjs
Currently, the new NectarJS version only supports Windows OS. We will add support for linux (x64 and arm) very soon.
You can check that everything is working fine by executing in a shell :
If you see the NectarJS version, you are ready to compile.
To try a little example, create a folder, test for example, and create a new file name hello.js in it, with this content :
Now, use NectarJS to compile it in a executable file :
nectar -c c test.js
You should have a file name test.exe in your folder. You can now execute it with the command :
Now, you can tweak your application, for example, reduce its size by compiling it with the size preset :
nectar -c c test.js --preset size
The size of your executable should be reduced by 3 or 4 now.