Would it not make sense to support a set of languages (Java, Python, Ruby, etc.) by way of a standardized virtual machine hosted in the browser rather than requiring the use of a specialized language — really, a specialized paradigm — for client scripting only?
I suspect, in time, it will become the “Machine language” for the web, with other better designed languages and APIs compile down to it (and cater for different runtime engine foibles).
- Google Native Client: technology for running native code in the browser.
- Idea: .NET CLI in the browser, by the creator of Mono: http://tirania.org/blog/archive/2010/May-03.html
Answering the question – No, it would not make sense.
Currently the closest things we have to a multi-language VM are the JVM and the CLR. These aren’t exactly lightweight beasts, and it would not make sense to try and embed something of this size and complexity in a browser.
Let’s examine the idea that you could write a new, multilanguage VM that would be better than the existing solution.
- You’re behind on stability.
- You’re behind on complexity (way, way, behind because you’re trying to generalize over multiple languages)
- You’re behind on adoption
So, no, it doesn’t make sense.
Remember, in order to support these languages you’re going to have to strip down their APIs something fierce, chopping out any parts that don’t make sense in the context of a browser script. There are a huge number of design decisions to be made here, and a huge opportunity for error.
In terms of functionality, we’re probably only really working with the DOM anyway, so this is really an issue of syntax and language idom, at which point it does make sense to ask, “Is this really worth it?”
Bearing in mind, the only thing we’re talking about is client side scripting, because server side scripting is already available in whatever language you like. It’s a relatively small programming arena and so the benefit of bringing multiple languages in is questionable.
What languages would it make sense to bring in? (Warning, subjective material follows)
Bringing in a language like C doesn’t make sense because it’s made for working with metal, and in a browser there isn’t much metal really available.
Bringing in a language like Java doesn’t make sense because the best thing about it is the APIs anyway.
It doesn’t make sense.
The Python win32 extensions allowed one to add Python to IE like this quite easily, but it wasn’t really a good idea as Python is quite difficult to sandbox: many language features expose enough implementation hooks to allow a supposedly-restricted application to break out.
It is a problem in general that the more complexity you add to a net-facing application like the browser, the greater likelihood of security problems. A bunch of new languages would certainly fit that description, and these are new languages that are also still developing fast.
I would definitely welcome a standard language independent VM in browsers (I would prefer to code in a statically typed language).
I admit that the “standard” part would be quite tricky, though. Also there would be conflicts between language features (eg. static vs. dynamic typing) concerning the library (assuming the new thing would use same library). Therefore I don’t think it’s gonna happen (soon).