Monday, July 5, 2010

Erjang - No, its not a typo and its Erlang-on-JVM

There's a new Erlang language in town built on-top of the JVM. Its Erjang. I seem to experience a explosion of hosts of languages built on-top of the Java Virtual Machine from Scala (my current favourite), Clojure (Lisp clone), Jython (Python clone), Groovy and JRuby to name a few; for a developer like myself, i do find myself suddenly swamped with a huge list of flavours in which to train myself in. Enough about me.

So Erjang is a runtime which basically loads the Erlang's BEAM file into the JVM and creates Java classes and its instances. Check out the project's homepage here. Like all languages, it'll need time to be adopted and adopted. Personally, i'll stick to Erlang since it fulfills most of my use cases from bit-hacking (which i absolutely adore) to general purpose computing and i'll love to listen to the use cases in which the author built Erjang. There's always something to be learned.

And i found it! Here's the rationale from the Creator which is ossm (check out the video)

Over the last few years, I have been meeting "Erlang people" more and more often, and I was getting this clear impression that "you people" have some kind of magic ability to reason intuitively about concurrent systems in a way that I could not. That bothered me, so I wanted to learn Erlang. Being a language implementor, the most obvious way to do that is to just go ahead and implement an Erlang VM, right?

The result of this "little exercise" is Erjang, an open-source JVM-based Erlang VM, which I think has potential to be useful as a means to push Erlang into new areas of application, help grow the Erlang community, and most importantly make all those Java-heads out there willing to learn how to do concurrency right. In this "brave new world" of networked services and multi-core everywhere, there are a lot of people who are challenged in providing even basic reliability, efficiency and correctness. My hope is that Erjang's existence can influence some of those outside the Erlang community to do better.

In technical terms, Erjang reads .beam files and compiles them to Java's equivalent .class files which are then read into the running JVM. It runs off a plain Erlang/OTP distribution - it only requires the beam files from there; Erjang itself is written in Java. As off this writing, it can run some non-trivial erlang programs, but is not yet capable of booting OTP [will have to update this abstract as we go along - follow updates on my blog]. Comparing the BEAM virtual machine and Erjang, the most obvious differences are that (a) Erjang will not be able to provide [soft] real-time guarantees since it uses Java's garbage collector, and (b) it has limited support for native code and port drivers (other than file and network I/O). The upside is the new ways this allows us to deploy Erlang systems.

In this presentation I will talk about how Erjang works, what behavior to expect from Erlang programs running on top of Erjang, what I learned along the way, and demonstrate [live] that Erjang runs well enough to be obviously useful.

No comments: