Quantcast
Channel: Hacker News
Viewing all articles
Browse latest Browse all 25817

Nectar: A Native JavaScript Compiler Inspired by Crystal Lang and Nim Lang

$
0
0

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.

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 ...

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);
}

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.

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


Viewing all articles
Browse latest Browse all 25817

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>