Other Programming Languages for the Java Virtual Machine

Did you think the Java Virtual Machine was only for running Java programs? Think again. There’s a reason it’s called a virtual machine. By itself, the JVM doesn’t run any Java code. All Java code must first be compiled into bytecode which is then executed by the JVM. This system means that any programming language that can be compiled into bytecode can be used with the JVM. What follows is a brief list of some other languages that can be compiled to run on the JVM.

1. Java

This is the one that started it all. Java is one of the most widely used languages today, especially in developing corporate back-ends. Predominantly object-oriented, but with a syntax that should be familiar to anyone with some amount of experience with C/C++. It fulfills a wide variety of roles which is made possible due to a large and well-documented API and also a growing number of extensions for a variety of purposes. Being the language native to the JVM, it’s development is in sync with that of the JVM, with obvious benefits.

2. BeanShell

BeanShell is not strictly a language: it is a java interpreter which allows quick execution of Java code without actually compiling it.  However, BeanShell adds features like closures and commands similar to those found in scripting languages like Perl. BeanShell can be easily integrated as part of any Java program allowing it to be easily extended by writing new code without having to recompile. BeanShell is now destined to become an official part of the Java platform which means that it will be faster to extend already written applications.

3. Groovy

Groovy recently launched its 1.0 release and it is meant to be a full-fledged language capable of being used interchangeably with Java. It uses Java syntax but it is dynamic in nature and adds feature that are part of languages like Python or Ruby. Of special importance are its inclusion of both static and dynamic typing, closures and native syntax for lists, maps and arrays. Also of interest is built-in support for markup syntax like XML, which would make it handy for writing AJAX backends.

4. F3

It is a compiled scripting language, with an emphasis on graphics manipulation.  F3 is still in heavy development and has not been officially released. However, it looks promising and is capable of being used intimately with Java itself. It can call Java classes and create Java objects as well as calling their methods. This is certainly something tokeep an eye on if you are interested in user interface design and implementation.

5. Scala

As the website says: ” Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages.” Scala is mainly of interest if you are a computer science student. However it deserves mention because it is not tied to the JVM, but can run on Microsoft’s Common Language Runtime as well.

6. JRuby and Jython

These are implementations of Ruby and Python on the JVM. Though both are entirely usable, each has it’s specialities. JRuby in particular has ambitious goals of being more than just a port: it aims to allow tight integration with the JVM in turn allowing two-way communication between Java and Ruby code. Currently only interpretation is supported, but a compiler is being actively developed. Jython on the other hand has more conservative goals, but a lack of experienced developers with enough time means that it’s implementation of Python is at 2.1 while Python itself is approaching 2.5. So any code containing more recent features will not run.

7. Rhino

Once again, not really a language. It is an engine for JavaScript running on the JVM, capable of running in both interpreted and compiled mode. It is now a part of Java SE, thus making it easier to integrate JavaScript with Java programs and use JavaScript’s features with Java programs.

That’s a brief overview of what’s currently available on the JVM, and there should be something there formost programmer’s needs. In case you want to do the opposite: run Java programs without the JVM, the GNU Java compiler lets you compile Java code directly to machine specific binary.

6 thoughts on “Other Programming Languages for the Java Virtual Machine

Leave a Reply to Jeff Reaf Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s