A Language-Agnostic Java?
In a recent post by Tim Bray, a Technology Director at Sun Microsystems, he describes a “summit” held in which the leading developers of popular dynamic languages were invited to Sun to spend the day discussing issues in and surrounding the use of their languages and the projects created to make them work on the Java platform. I speak mainly of Jython (Python on Java) and Groovy (a mixture of Python, Ruby, Smalltalk, and Java).
Attending this summit were people from the Perl camp—Larry Wall and Dan Sugalski (Parrot)—and the Python camp—Guido van Rossum, Samuele Pedroni (Jython), and Sean McGrath. James Strachan of Groovy was present, as well as Graham Hamilton, Gilad Bracha, Martin Buchholz, and Tim Bray of Sun.
Specifically, the topic at hand dealt with these languages that are designed to run on the JVM (Jython and Groovy) and how Java can be made in such a way to make it easier to allow dynamic languages to run on it. I found it particularly interesting in light of my recent article on Parrot and the Pint compiler for running PHP on Parrot.
What does a future with a cooperative Java that’s language-agnostic and runs popular dynamically typed languages mean for the future of these languages? Probably not much since the languages themselves won’t change—only the machine that runs them. Yet, I found myself wondering what this means for the future of Parrot. Imagine a JVM with the ability to run Python, Ruby, Perl, and even PHP. This doesn’t go as far as one interpretation that PHP would become Java, but rather each language maintains its own identity, yet they’re all sharing the same living space—in a sense, they become roommates.
6 Comments
So would the idea be that code written in PHP/Python/Perl be able to run on any computer that has JVM installed? This would be nice for WIndows users since they are more likely to have Java installed than any other scripting language...
Lewis -- You would still need each language installed on the machine/server in question. The idea is more that each language would be able to utilize constructs from the other languages present in the virtual machine. Thus, if perl and PHP are both present, PHP would have access to perl objects and vice versa.
Another benefit of the system is that the developer would target the virtual machine, not the OS; this would make the application portable cross-platform without needing to do anything special in the language itself.
Matthew's right. You would still need the interpreter/compiler for the language installed. That compiler would process the language so that it could run through the VM. I suppose, however, that the popular languages would come packaged with the installer for the VM, giving users the option to install those languages they want to use or just to install all of them by default.
PHP can integrate with Java, which means that it can be used as the scripting language for activating Java logic, just as much as JSP can. Unlike JSP, however, PHP also integrates with other component models, such as Microsoft's COM, and adding support for new object models is extremely easy. This means PHP's extensibility is infinite. JSP, on the other hand, is completely dependent on Java.
It would be really nice to see this work in both directions... go Sun!
Bear with me, I am not too familiar with java, I grew up with C++. From what I understand of the language is that the written code gets compiled into bytcodes...alot like PHP I guess. So what I am asking is would you beable to compile PHP or Python or any of these other languages into the bytecode? I'm guessing not based on what I have read so far. Like I said, not too familiar with the scene just looking to becmoe that way.
Java is much like C++. It gets compiled to bytecode and executed the same way. PHP is much different. It is an interpreted language (like Perl, Python, Ruby, etc.) and only gets compiled at run-time by the interpreter.
Running any of these languages through a single VM means writing an interpreter that converts the language (PHP, Python, etc.) into either the VM's assembly code or intermediate code -- in either case it's something that the VM can natively understand. Then, the VM compiles that to bytecode either for later execution or immediate execution.
So, in a sense, the answer to your question is "yes."