Angular shitstorm: What's your opinion on the controversial plans for Angular 2.0?
Have we met?

Introducing Erjang: Erlang for the JVM

JAX Editorial Team
erjang

Where have you been all this time? Erjang takes the nifty language of Erlang to the JVM.

You’ve probably heard of Erlang, the programming language and runtime system. But have you ever come across its Java half-brother?

Any developer that appreciates a good old word play (most) will remember the name: Erjang, the runtime tool that takes Erlang programs and runs them on the Java Virtual Machine.

With built-in support for concurrency, distribution and fault tolerance, Erlang has established itself as an effective language for scalable real-time systems in industries like e-commerce, banking and instant messages. Seems logical to introduce it to the wonderful world of Java, right?

Erlang for the JVM

This is how it works: Erjang loads Erlang’s binary .beam files and converts them into the Java .class file format. The Java classes are then transferred to the JVM and executed. There’s also a BEAM interpreter, which is still rather slow, but at the same time, it uses less memory than the official equivalent.

But wait, does this really work? If you ask the Erjang virtual machine’s official website “Yes! It does actually work. Though there are exceptions…”

There’s a couple of restrictions that Java developers need to stomach when working with Erjang. For example, runtime support is missing from several of the BEAM instructions. On top of that, some of the built-in Erlang functions (BIFs) are not yet, or only partially, available. Nevertheless, the goal is to continue expanding Erjang to allow for Java implementations of all BIFs.

Why the need for Erjang?

Erjang was unveiled in 2009 by its creator Kresten Krab Thurup, and since then it’s been continuously developed. Even back then, Java developers were discussing why even bother porting Erlang for the JVM. Isn’t BEAM already a good enough virtual machine for Erlang?

Kresten said the main reasons were the quality of the JVM, the potential for better performance, the enhancement of Erlang with an alternative implementation and the besser availability of the language for the Java community. Beyond that, the desire to experiment and mess around with modifications proved enough of a motivation for Kresten:

Why are you doing this? Good question. Well, I just wanted to learn Erlang, and it seems to be working!

Erjang is available for free at http://erjang.org/. The most recent version is 0.2, which is designed for Java 7. If this introduction has whet your appetite, check out the video below for a nice introduction from the creator of Erjang, Kresten Krab Thorup himself. You can also take a look at the readme on GitHub and the following video introduction.

Feature image: Satisfied customer via Shutterstock / copyright: Everett Collection

Author
JAX Editorial Team

JAX Editorial Team

All Posts by JAX Editorial Team

Comments
comments powered by Disqus