Nectar : a native cross-platform javascript/ECMAscript compiler inspired by Crystal Lang and Nim Lang

I didn't make C, Crystal, NodeJS and Golang benchmarks (and much more I didn't post) just for fun : I'm finishing Nectar, a native cross-platform compiler for javascript/ECMAscript.

Why a javascript native compiler ?

Javascript is everywhere : browser, server, IoT. NodeJS is fast, and slow. Fast, because it's a way faster than Python or Ruby, orhers interpreted languages. Slow, because compared to C, Crystal or Go, it's slow. There are a lot of advantages to truely compile javascript :

  • Speed (development && execution)
  • Size
  • Efficiency
  • Ecology
  • No need for Obfuscation
  • Web Assembly (wasm)
  • Fast coding and Fast execution
  • IoT
  • And much more ...

What is supported ?

A lot of ECMAscript 5 is currently supported : functions, variables, objects, arrays, standards functions/properties (typeof, .length, .toString()). I'm making a solid basis for the compiler be fast and secure.

For example, this is currently supported :

var a = 10;
console.log(a); // print '10'

a = "a string";
console.log(a); // print 'a string'

a = 10.01231;
console.log(a); // print '10.01231'

var human = { fname: "John", name: "Doe", age: 10, type: "human"};
var robot = { name: "Bot", type:"robot", battery:90};
console.log(human.fname) // print 'John'

var nestedArray = [0,"b",2,"d",["e","f",7],["i"]];
console.log(nestedArray[0]); // print '0'
console.log(nestedArray[4][1]) // print 'f'

callit(human); // print 'Hey Doe'
callit(robot); // print 'Hey Bot'

// definition of the function after the call
function callit(obj)
{
  console.log("Hey " + obj.name);
}

Which platforms does Nectar support ?

Nectar currently support all platforms. It has been tested on Windows, Mac, Linux, x86, x64 and ARM. Executables size is low (for the example above < 10 ko). And Nectar is fast, really, really fast. Benchmarks are coming soon.

Cross-compilation

The better part is the cross compilation : it's possible to compile JS with Nectar from a supported platform to any other supported platform. We successfully compiled a "helloworld.js" from a Raspberry pi3 to a Windows 7 x86, a Windows 10 x64, and a Linux x64.

Adrien