Which VM?
The question is the following: if you had to develop a new dynamic language, which Virtual Machine would you pick? It’s interesting because the VM market is probably going to consolidate in the coming years. Right now, there are several possible choices.
- The Java(tm) VM. Huge ecosystem, outstanding tooling (think parsers, bytecode manipulation) and Sun seems to be very motivated to improve it for dynamic languages and the next big thing. But I have mixed feelings. Strong corporate backing is a two sided sword. Things nowadays happen outside the Enterprise. There’s a big memory price which shows in the hosting market (compare to the unlimited possibilities of PHP hosting). And there’s a startup cost which makes scripting usage delicate.
- The .Net DLR on Mono. Another very good option. Except that betting big on Microsoft technology is very risky. And outside of C#, there aren’t that many robust languages implementations running on Mono.
- Tamarin (ex AVM2, think Flash player). An already fairly good VM that’s getting quickly even better. I would bet that most of the research development to optimize dynamic languages execution will happen there. Pushed by Mozilla which is definitely a plus. But here the problem is the ecosystem, outside of the browser there’s nothing. A whole purpose language would need to develop (or integrate) the whole backend (files, sockets, HTTP and XML stacks, …). That’s a lot of work.
-
The Parrot VM. On paper, it’s the ideal VM. Designed to be multi-language from the ground up, a powerful set of tools eases development (parser, AST, compiler), the libraries come from Perl, it’s fairly fast and it’s a register-based VM. Problem is, it’s been around for a while and they haven’t proven themselves so far. Even Perl 6, which was supposed to be the killer language, isn’t ready. They seem to be getting there though, they’ve progressed pretty nicely in the past year or two.
There are many other VMs out there but they’re often too tied to their hosted language or to their environment, like the Python VM or SquirrelFish (another register VM by the way). So I think those 4 are the main options.
My reason tells me JVM, my heart tells me Tamarin and Parrot falls in the middle. So what’s your choice?
Matthieu Riou on August 27th 2008 in Uncategorized
Paul Brown responded on 27 Aug 2008 at 8:33 pm #
What about LLVM (http://llvm.org/)? (See PyPy for an example.) Failing that, cross-compiling to Javascript as an intermediate seems like a good way to go, rather than direct to a specific VM.
Assaf responded on 27 Aug 2008 at 10:53 pm #
Whatever Mozilla uses.
a) it’s made for a dynamic language.
b) they pay attention to startup time.
c) and performance.
d) and memory (now that FF is going mobile).
e) cross-platform file I/O, HTTP, XML, SQLite.
f) security.
g) native UI.
h) momentum.
You’re assuming things like I/O, SQLite, native UI components, desktop integration, etc are not available to JavaScript because HTML scripts are sandboxes. But the chrome is written entirely in JS, all these features are accessible to the VM when running outside the sandbox.
Uli W. responded on 28 Aug 2008 at 4:16 am #
Think about the future.
What VM will dominate the future generation of multi- and manycore-processors? Simple answer: the best! And the best VM is the one with the most human and financial resources available. Let’s say it’s the one made by companies like IBM, Intel, Sun or Microsoft.
But there is no place for two different VM’s in the so-called “free world”. Mozilla/Adobe made an enormous mistake to go NIH and to reject the technology offered by the Java-community.
The successor of the JVM will win the race and not Adobe and Mozilla. Too bad that the OpenSource-community has NIH-problems like that.
Matthieu Riou responded on 28 Aug 2008 at 7:00 am #
@Paul: I’ve checked LLVM some time ago and they seemed more interested in low level languages like C, C++ and Forth. As a result they were missing higher-level features like a garbage collector. It seems that they’ve fixed that recently though so it might be worth another look.
And Javascript for now is still painfully slow…
@Assaf: If so, they’re far from ready. Last time I checked the Tamarin Javascript compiler (called ESC) didn’t work for even simple expressions. And they don’t seem to be working very actively on it (see https://bugzilla.mozilla.org/show_bug.cgi?id=451145). I think they’re barely recovering from ECMAscript 4 limbo and it’s going to take them a while to migrate away from SpiderMonkey.
@Uli: Actually the problem they had with the JVM is the licensing. They’re not comfortable with GPL, which I can understand. Also even if the JVM is supposed to be open source, it’s still not, a few years after the original announcement. Finally AVM2 is a conservative choice for them, it was already tailored for ActionScript which is very close to Javascript.
Cyrus responded on 28 Aug 2008 at 1:09 pm #
Second to LLVM. Language interoperability is only feasible if your virtual machine supports a superset of all the features of all the languages you want to support. LLVM can support everything from C (imagine that, C running within your VM rather than some crazy serialization scheme to call “native” code) to LISP (which requires an unhealthy amount of access to internals to support all the dynamicism it supports, particularly with regard to run-time modification of code.)
Apple is behind LLVM and many of the LLVM developers are now Apple employees. Its even deployed in some of Apple’s legacy interop code for their graphics subsystems.
What is really needed is a couple of killer apps. Show that Python can run faster in LLVM than the Python VM, for example. Build a Firefox LLVM plug-in that JIT’s Javascript faster than Spidermonkey, and lets you program the DOM with your choice of language at that.
Since it was originally an academic project, there isn’t a drive in the community to go through the “uninteresting” parts that would be required for a full implementation of a popular language. Apple might do it for Objective-C, but they don’t care about other languages. I’m hopeful someone will step up and give it some love, and if so it will be the next big thing. Otherwise, I’m going to have to go with the DLR unless the Tamarin teams puts in the effort to go language-neutral.
Chui responded on 04 Sep 2008 at 4:00 pm #
@Uli: If Flash had the same start-up time as Java applets, it would have been DOA years ago.
turtlewax responded on 16 Sep 2008 at 4:28 pm #
>>aren’t that many robust languages implementations
>>running on Mono
What about java; runs well enough in ikvm in both .NET and mono.I’ve had a lot of success running the java ant libraries in .NET via ikvm
Has the JVM design been holding back Java? | Chui’s counterpoint responded on 17 Sep 2008 at 5:58 pm #
[...] 1Update 5 Sept, I was wrong. See this 2Incidentally, addressing this use-case on the server-side could be a boon for Java on shared hosters. I would like to see the JVM be a viable competitor to PHP. See Matthieu Riou. [...]
Kirby Urner responded on 10 Feb 2010 at 10:42 pm #
The new Google Go language seems like it might serve as a basis for a new VM, including for Python. Languages and VMs jump around. Python currently targets the Java VM (Jython), the .NET/Mono VM (IronPython), plus has its own C language VM. Then there’s the PyPy VM and Unladen Swallow. Why stop there? A VM in the Go language would probably be at least as powerful as a VM in the C# language.