[erlang-questions] JavaScript compiler for Erlang

Ryan Rawson <>
Mon Jul 16 11:37:19 CEST 2007


I've been working with JS and Rhino quite a bit lately.  As I see it,
there are 3 levels to making JS work:
- Core language and semantics
- Basic libraries (Array and the like)
- DOM

Rhino goes one step further and defines a so-called "LiveConnect"
feature (which is part of the ECMA standard) that allows bridging to
Java types.

To get JS on Erlang, first is to define a similar feature to bridge to
Erlang.  Secondly, deal with some scary facts like there is only the
'Number' type in JS, and the language semantics makes it hard to
introduce different number types.  Be prepared to cry.

All said and done, JS is a pretty powerful and cool language.  Much
better than Java!

-ryan

On 7/16/07, Joe Armstrong <> wrote:
> I have on occasion thought that it would be fun to implement Javascript.
>
> The idea of having lot's of little javascripts running in process and
> message parsing
> would be fun.
>
> The first step would be a simple interpretor - from that the compiler
> is easy :-)
>
> The difficulty of wring an interpretor seems mainly to do with getting
> an accurate
> parse tree of the js source into Erlang - the interpretor should be pretty easy.
>
> So now I wonder "how can I get a parse tree of some javascript" - Ideally
> there would be a javascript-parser-in-javascript that produced a JSON
> parse tree.
>
> If such a parser exists please tell me where to find it !!
>
> Failing this I guess the easiest approach is to take spidermonkey make
> the stand-alone
> version and fix the parser to dump the parse tree in some suitable
> format. Unfortunately
> I suspect that spidermonkey make C data structures suitable for
> compiling/interpreting
> rather than parse trees as such.
>
> The next alternative would be to find a yacc grammar for javascript
> and put this into yecc
> but I suspect this would be out-of-sync with real javascript.
>
> Failing that it's back to the ECMA-262 spec ( I suppose) and try to convert the
> grammar in the appendices to something sensible.
>
> In projects like this I always think that writing an accurate parser
> is the tricky bit.
>
> /Joe
>
>
>
>
> On 7/14/07, Joel Reymont <> wrote:
> > This is the reason I asked.
> >
> > Think scalable web development for the masses.
> >
> > In Javascript.
> >
> > On top of Erlang.
> >
> > On Jul 13, 2007, at 8:11 PM, denis wrote:
> >
> > > We are building an infrastructure allowing giving some services to our
> > > users. But external developers (same company, but other teams)
> > > could build
> > > their own custom services inside the infrastructure. Having these
> > > new users
> > > to learn a new language to build a custom services (which can be quite
> > > simple) can be badly perceived.
> >
> > --
> > http://topdog.cc      - EasyLanguage to C# compiler
> > http://wagerlabs.com  - Blog
> >
> >
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list