One of the best uses for Java virtual machine programming is translating languages other than Java into virtual machine code. Compiled programs run faster than interpreted ones, and compilers are often easier to write than interpreters. By taking advantage of the JVM's built-in debugging features, you can even use standard debuggers for your new language.
There are many different kinds of languages. Some are complete in the sense that they are powerful enough to write programs for any computation. In this sense, Java, C, Lisp, and Basic are all complete. Completeness in this sense refers to the ability of a language to compute mathematical functions, not to its ability to manipulate hardware (such as graphics) or whether hooks are provided to a particular operating system feature.
Each of these languages includes features not included in the others, which gives each language a different flavor. A language designer carefully chooses the features to include in a language to make it powerful enough to write concise programs but not so complicated that it is hard to learn or hard to implement.
The Java language designers chose a set of features appropriate to general-purpose programming:
Other languages have features not included in Java:
It is possible to design a translator from any of these languages into JVM code. Sometimes the mapping from one language into JVM features is easy. For example, it is easy to see how the arithmetic instructions of the JVM instruction set can be used to implement numerical calculations of any language.
Other features, like pointer arithmetic in C++, are considerably harder though not impossible to implement using the JVM instructions.
A language does not have to be computationally complete to be useful. For example, regular expressions are widely used in search engines, although it is not possible to do general computation with them. Another example is SQL, the database query language, which is well suited to joining tables together but not for general-purpose calculations. The limited scope of these languages allows them to be better suited to a particular task than a general-purpose language like Java or C++.
This chapter suggests how some of these languages may be compiled into bytecodes and executed on any JVM implementation.