You are not logged in.

#1 2012-04-14 15:02:48

peterb
Member
Registered: 2011-10-05
Posts: 27

An implementation of concurrency for JavaScript / CoffeeScript

Hi,

i've experimented with Google's v8 engine and the result is a little extensible scripting environment that offers a simple interface for running code in parallel.
In detail there is a 'concurrent' namespace that allows you to spawn a JavaScript function in a new process. Processes can send messages to each other.
Messages are just normal JavaScript data like arrays, strings, functions...

It does not run in the browser. It's executed, like shellscripts (#!). There are also some modules for basic stuff (like filesystem, shell...) and a repl but don't expect much wink
It does also implement (a part of) CommonJS, so there is a 'require' based module system that allows you to load JavaScript or C++ Modules. Oh and it comes with the
CoffeeScript compiler, so you can do all this things in CoffeeScript if you like.

I know there is Node.js and I don't have any plans to make a similar product. This is really just a little experimental project that i made to learn and because it was fun to program.
Note that it comes with precompiled binaries of v8 and protobuf (a serialization lib by Google) for i686 and x86_64. Not sure if this is the best way...

If you wan't to take a look at it or if you are working with v8 yourself, here it is:

https://bitbucket.org/pb82/asteria/overview

(The code base is quite small, some examples of how to use it are provided, but unfortunately there is no documentation yet)

Any feedback / critique welcome.

Offline

#2 2012-04-14 15:24:39

Nisstyre56
Member
From: Canada
Registered: 2010-03-25
Posts: 85

Re: An implementation of concurrency for JavaScript / CoffeeScript

I'd rather use a continuation based approach in pure JS, and an API similar to that of Racket's threading (allows for channels and messages using a concept called mailboxes).


In Zen they say: If something is boring after two minutes, try it for four. If still boring, try it for eight, sixteen, thirty-two, and so on. Eventually one discovers that it's not boring at all but very interesting.
~ John Cage

Offline

#3 2012-04-14 16:00:21

peterb
Member
Registered: 2011-10-05
Posts: 27

Re: An implementation of concurrency for JavaScript / CoffeeScript

Yes that would probably be a better fit to a language like JavaScript. The idea to build a message-passing system came to me while reading the Erlang chapter of 'Seven languages in seven weeks'.
Interesting that you mention Racket. I've played with it and i really liked it. But i never got so far as to use threads. But i would really like to use Racket more.

Offline

Board footer

Powered by FluxBB