Friday, January 21, 2011

About erlang callbacks from within SpiderMonkey

Now, about those callbacks.. We are planning to use ETS to store data. This data is to be manipulated from the JSVM. There is no support (according to Sean Cribbs, again, great guy, very helpful) for calling Erlang code from inside the JSVM (SpiderMonkey). The proposed way to do this is to implement a C(++) function (example code), which will interface with our Erlang code (I believe I have seen this been done - I'll drop an anchor if I find it, EDIT: Found it. See link.) and then call this C function from inside our JS. That is: JS -> C -> Erlang From a speed point of view, I don't really see this as really slow if it's done right. All we would need is a small C application which somehow interacts with our Erlang VM. The implementation of this C code is dependent on SpiderMonkey, and has nothing to do with our erlang_js bindings. The erlang_js fellows seem to be defining their own native functions for use within the JSVM. There might be a possibility to extend erlang_js with our native functions as well, and thereby not need additional C/++ code, but route everything through erlang_js. See here for example.


  1. You guys should listen to this podcast:

    money qoute: "The biggest thing I was able to run was, lets see, about 5500 JavaScript VMs (virtual machines) inside of a single erlang VM and it all worked."

  2. And btw. we discovered today that we don't want ETS but Mnesia

  3. I talked to Kevin Smith, the erlang_js developer, via Twitter:

    Me: @kevsmith we're trying to use erlang_js but can't figure out how to call a erlang function from javascript (callback), any suggesions?

    Kevin: @jeena unfortunately that's not supported. something i wanted to add but never had the time, alas.

    Me: @kevsmith ah damn it, ok thanks.

    Kevin: @jeena i could give some pointers on how to implement it if you're feeling adventurous

    Me: @kevsmith hm yeah, I'll talk to the guys first, thanks.

  4. I might be feeling adventurous....