4 ms·
> Why can't we have a standardized generic bytecode and VMs to run it? Why should the web be locked to a single language forever? In the beginning, this was th
by maratd 15y ago
> Why can't we have a standardized generic bytecode and VMs to run it? Why should the web be locked to a single language forever?
In the beginning, this was the intended design. Which is why you still specify the language when injecting code into the page.
That original design is flawed and does not work well on the web. Adding other languages is a horrible idea.
> Can you imagine if we had locked desktops and mobile only a single implementation language?
Apples and oranges. On both platforms, programs rarely interact with each other and when they do, it's through the OS using a standardized API.
The web is different. One piece of code is always interacting with another piece of code, that is interacting with a third and so on. There is no standardized API. You just call the appropriate function, if available.
To implement other languages, not only would you need to compile to bytecode, add VMs, etc. you would also need to add APIs that would allow communication between different pieces of code, written by different people, in different languages. Even if implemented, which would be a nightmare, it would still stifle the very nature of the web, the very dynamism that makes web apps different.
I don't want the web to become like the desktop or mobile space. I want to pull in code from twitter, facebook, my code, etc. and have it all work together, communicate with each other, and create a dynamic environment, all on one page, client-side. This is only coming into reality now.
- nupark2 15y agoThe JVM and the CLR have already adequately demonstrated that multiple languages can easily (and with adequate performance) share common libraries and APIs. Mixing Scala, Java, Ruby, JS, and PHP -- all in one process -- is simple and straight-forward on the JVM. That said, the language of the web is HTTP and REST and open APIs, not injection/eval of JavaScript.
- maratd 15y ago> The JVM and the CLR have already adequately demonstrated that multiple languages can easily (and with adequate performance) share common libraries and APIs. Please tell me how code in PHP can get a response from a function in JavaScript? What if that response is a Date object? What if that Date object was extended with additional functionality? What if that Date object stored additional values in unexpected places? A huge advantage of Javascript is that everything is an object and everything can be modified. When you try to make that work, you'll start placing restrictions on what can and what can't be passed. Global scope will be a nightmare. You'll try to hack together a scheme that casts responses into primitives. In the end, you'll end up with a stifling environment where interoperabilty is a theory that is never used in production because it was crippled to make it functional to the point of being useless.
- nupark2 15y agoYour concerns seem ill-founded given that these are solved problems. There are working implementations of low-barrier cross-language compatibility, today, for both the JVM and the CLR. Here's one example; Rhino provides pretty seamless bridging from JavaScript to Java: https://developer.mozilla.org/en/Scripting_Java https://developer.mozilla.org/en/Scripting_Java I've used it to run user-supplied JS inside the JVM. PHP is pretty easy too: http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp#JavaPHPintegration http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp#JavaPH... Scala is even more lightweight here: http://www.codecommit.com/blog/java/interop-between-java-and-scala http://www.codecommit.com/blog/java/interop-between-java-and... Bear in mind that these are all for the JVM, which wasn't even designed with the intention of being a general-purpose multi-language VM.
- MatthewPhillips 15y agoI can't speak to the JVM, but I know for a fact that some CLR languages have incompatibilities (C# and F# specifically).
- MatthewPhillips 15y ago> I've used it to run user-supplied JS inside the JVM. Have you used Java libraries in JS or vice-versa? That's the problem the parent is referring to.
- nupark2 15y agoBoth directions. There are impedance mismatches, of course, but it's nothing like the doomsday scenario he's claiming.
- maratd 15y ago> Your concerns seem ill-founded given that these are solved problems. Then solve the problem I put before you. It's an easy one. I want to pass a modified Date object with stored procedures that modify the value based on geolocation. I want to pass it from a Javascript function to PHP/Java/whatever. Make it work. Please.