Sunday, May 1, 2011

Erlang on a JVM/CLR

I've just started reading Joe Armstrongs book on Erlang and listened to his excellent talk on Software Engineering Radio.

Its an interesting language/system and one whose time seems to have come around with the advent of multi-core machines.

My question is: what is there to stop it being ported to the JVM or CLR? I realise that both virtual machines aren't setup to run the lightweight processes that Erlang calls for - but couldn't these be simulated by threads? Could we see a lightweight or cutdown version of Erlang on a non Erlang VM?

From stackoverflow
  • Nothing at all, actually. You might have a look at Clojure, which is an interesting functional language built on the JVM.

    Fortyrunner : I've been looking at Scala as well. Have ordered the forthcoming Clojure book as well. Clojure does look interesting..!
  • I don't know of any technical problem inhiting this.

    Actually Scala (a JVM functional language) uses what is called an Actor Model that is very similar to, and as I understand it borrows heavily from, the Erlang model of shared-nothing concurrency. Threads could not simulate Erlang processes. They're much too heavy-weight.

  • You could not use JVM/CLR libraries, given their reliance on mutable objects.

    Erlang exception handling is quite different from JVM and CLR exceptions, you would need to handle this somehow.

    Implementing processes as threads would mean that any sizable Erlang system runs out of memory pretty fast (process size on my machine on creation: 1268 bytes, thread stack size in CLR: 1 MB) and communication between processes is much slower than in Erlang.

    What you probably want is an Actor Model implementation on JVM or CLR.

    Scala and Clojure have already been mentioned. In addition, there are many Actor implementations for JVM: Kilim, Functional Java, Jetlang, Actors Guild, ActorFoundry, and at least one for CLR: Retlang, which can be used from any JVM/CLR language.

    Fortyrunner : Interesting - thanks for the links
  • This is a well trod-discussion. Some context might be useful.

    From the Erlang mailing list last November:

    My contribution to the debate about Erlang on the JVM? No, not a good idea :(

    Fortyrunner : Thank you for the links. The context is that I am just plain interested!
    Gordon Guthrie : You misunderstand me, I understand why people are interested, I just wanted to give you/Stackoverflow the benefit of the bigger discussion...
  • Possible? Yes. Practical? Well, probably not; they solve different problems in very different ways, and thus have lots of major differences in the way they do things. This would make porting hard, and performance would likely suffer severely. That doesn't mean it can't be done, just that there are better ways to accomplish what such a port would bring to the table.

  • Just for completeness additional source about topic.

  • Axum -- an incubation project on the CLR -- was clearly inspired by Erlang.

    Fortyrunner : Yes. I saw some stuff on Axum this week and immediately thought of Erlang!
  • For educational reasons, we are implementing a subset of ErlangVM for CLR. We were highly inspired by Kresten Krab Thorup and his project Erjang, a JVM based Erlang VM. Erjang uses kilim framework for representing lightweight processes, and it starts to attract attention.

    Javalimit - Erjang's author blog.

    Erjang repository

0 comments:

Post a Comment