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.