Skip to content

haxe forked for node.js

February 4, 2010

I’ve forked haxe for experimentation with a node.js target on github. I’ll keep the hxNode project as an easy entry to the node target, as a haxelib maybe, but this will be the main project where all the elements can be kept in sync better.

I want to optimize the haxe code generator for idioms specific to V8 javascript, e.g. take this thread on v8-users , unintuitively, s+=”” is faster than an array join in V8. The relevant snip:

When you do += in V8 you create a ConsString, which is a tree node
that takes up 20 bytes on 32 bit or 32 bytes on 64 bit.  This is a
relatively fast operation.  The first time you use the string for
things other than consing up results it is converted into a flat
string in much the same way as join would do it.  The ConsString nodes
become garbage which we can collect quite quickly.  Join is subject to
some pretty arcane specifications about how it has to work (eg on
sparse arrays) so that’s not a completely trivial operation.

There’s also native JSON.stringify and parse, foreach, folds, getOwnPropertyNames; in short lot’s of ways to take advantage of V8.

bd

Advertisements

From → haxe, javascript, node.js

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: