NectarJS is a transpilator / compiler project. Its objective is to compile js code in a native application by transpiling in c ++.
This new version comes with a significant improvement: NectarJS now has its own memory management system. It is still very young but its ease will help us to provide a production ready version as soon as possible.
We have also made some improvements with FFI by creating macros that help define the functions that can be integrated into JS var.
Working with FFI
The new C++ Macro is :
__NJS_FFI_FUNCTION(function_name, var one, var two ...)
You can then embed this into a var :
var myFunction = __NJS_Create_Function(function_name);
Then, you can call this fonction in your js program as a normal js function :
var ffiCall = myFunction(_arg1, _arg2);
Registered Memory Manager
The new memory manager we are testing works with two simple arrays: REGISTER and FREE. Two pointers, REGISTER_PTR and FREE_PTR will follow where we are in the registry and free memory to use an empty memory location each time whe want to create a new var. Our benchmarks show that for NectarJS our registered memory manager is more efficient than new / delete or shared_ptr. We will continue to improve memory management in future versions of NectarJS. Another track is to modify the way var is implemented and use a unique_ptr.
Size of binary files
One of our goals is to be able to create smalls binaries and be able to embed them is Arduino, Espruino STM32 boards, and more. (I bought this to test NectarJS on it : https://shop.espruino.com/banglejs)
Right now, some of the examples file of NectarJS are compiling in binaries smaller than 50Kb.
Babel and the visitors
The versions of NectarJS < 0.3 were using an (ugly) custom code parser and visitors difficult to extend and manipulate. To let developpers help us easily, we decided to add Babel as the code parser and generator. The visitors model of Babel is extremely reliable and allows to extend NectarJS functions very quickly.
Installing NectarJS with NPM:
npm install -g nectarjs
The way is long, stay tuned !