Live data from Hacker News

Why don't they implement Python and Ruby on the web browsers?

stackoverflow.com

61–70 of 144 posts

Re: Why don't they implement Python and Ruby on the web browsers?

#61
post #57
post #54

Earlier quoted context omitted.

> 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?…

Your 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 I've used it to run user-supplied JS inside the JVM. PHP is pretty easy too: http://quercus.caucho.com…

> 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.

Re: Why don't they implement Python and Ruby on the web browsers?

#63
post #42

Earlier quoted context omitted.

> True, but the JS VMs we have today have been refined over 15+ years and switching to another risks breaking the web in profound ways. Even Google would be against dropping V8 for JS use. And yet, Google, Apple, AND Mozilla have all successfully introduced entirely new or significantly refactored VMs in the past few years. This is solvable; it HAS been solved. > JavaScript still has a lot of room for improvement. Pu…

> And yet, Google, Apple, AND Mozilla have all successfully introduced entirely new or significantly refactored VMs in the past few years. Yes, because the old VMs were critically slow. Things like DOM manipulation aren't blocking problems the way they used to be. > This is solvable; it HAS been solved. Why? What critical problem requires a bytecode VM? Developers refusing to write in anything but their favorite lang…

> Why? What critical problem requires a bytecode VM? Developers refusing to write in anything but their favorite language?

Your argument was that it wasn't technically achievable because it would break the web, yet it's clear that it can be done and HAS been done.

I'll try to address this new argument.

JS isn't perfect, it will never be perfect, and the lack of a bytecode VM is a hindrance to experiments and production language implementations that can lead to better solutions for developers.

Look at the language design that has occurred elsewhere. I may not use Erlang, but I learned a lot from it. Clojure introduced a ton of interesting concurrency constructs (among other advances). C# demonstrated LINQ, and F# is OCaml revisited.

In all of these cases it has nothing to do with whiny developers "refusing to write in anything but their favorite language". We're simply attempting to advance the state of the art, because nothing is perfect, especially JavaScript.

> This is solvable without alternative VMs. WebKit is working on CoffeeScript/other language debugging:

It's a work-around, not a solution. JavaScript still isn't an efficient bytecode format, this won't solve performance issues. We've seen similar work on languages that compile down to C, and it's not an adequate solution to debugging, especially when the debuggers benefit from language-specific enhancements.

Re: Why don't they implement Python and Ruby on the web browsers?

#64
post #57

Earlier quoted context omitted.

Your 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 I've used it to run user-supplied JS inside the JVM. PHP is pretty easy too: http://quercus.caucho.com…

> 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.

Both directions. There are impedance mismatches, of course, but it's nothing like the doomsday scenario he's claiming.

Re: Why don't they implement Python and Ruby on the web browsers?

#65
post #24

Earlier quoted context omitted.

> JavaScript doesn't have to go anywhere, it can run on a shared VM like any other language. JS running on a general VM would be slower. That's against the interests of the user. People should stop caring what language it is. If you really don't have the skill required to use Javascript, use something easier for you and get it to compile to JS. I've really never understood developers that bitch and whine about progra…

> JS running on a general VM would be slower. That's against the interests of the user. What do you base this on? It's sounds like an unsupported assumption regarding the complex technical constraints involved in implementing a general purpose VM and JIT. Putting the technical specifics aside, intuitively, why would the general VM be slower, especially since the requirement to support JavaScript would be obvious to e…

>> JS running on a general VM would be slower. That's against the interests of the user.

> What do you base this on? It's sounds like an unsupported assumption

No, he is entirely correct.

JavaScript and most dynamic languages do not run at full speed on static-language VMs like the JVM and .NET. This is despite tremendous efforts and motivation to run those languages quickly on such environments, see for example Microsoft's SPUR paper and everything it has done in the CLR to speed up dynamic languages.

The fact is, despite all those efforts, even Microsoft did not implement JS on .NET in IE. This despite Microsoft more than anyone having the capability and moreso the motivation ("everything on .NET"). Microsoft gave up and implemented a new JS engine in native code, and it made that new native JS VM a peer of .NET in Windows 8.

The reasons for this are technical: We do not know how to make a single VM that runs all languages quickly. It's very difficult to do! Dynamic languages need hand-crafted PICs for example, which are extremely difficult to make portable and safe, which is necessary for a VM on the web. Also, low-level details like even how to implement numbers are significant: NaNboxing for example is used in most JS engines, but it probably doesn't make sense in a static language VM. Having both NaNboxed numbers and 'normal' ones in one VM is cumbersome and complex.

Re: Why don't they implement Python and Ruby on the web browsers?

#67
post #57
post #54

Earlier quoted context omitted.

> 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?…

Your 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 I've used it to run user-supplied JS inside the JVM. PHP is pretty easy too: http://quercus.caucho.com…

> 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.

Re: Why don't they implement Python and Ruby on the web browsers?

#68
post #49

Earlier quoted context omitted.

If this is a complete puzzle to you, you might spend some time meditating on a parallel issue: why have we spent 20 years iterating HTML rather than proliferating various hypermedia schemes? Or "better" yet, some real universal client that works like Display Postscript or X-Windows? Also consider that there have already been two freely targetable VM plugins which have had near total market penetration at various poin…

> why have we spent 20 years iterating HTML rather than proliferating various hypermedia schemes? You have to remember that HTML is predated by SGML, and that HTML and its precursors were designed for the purpose of providing document markup. We've continued to evolve these solutions for document markup, and in this regard, they do an adequate job. However, what we've seen in recent years is a rapid emergence of the…

People who complain that js is ugly have no idea how ugly native X development is - I am just glad that the BT/MIC deal fell through so I never had to open that can of worms.

Re: Why don't they implement Python and Ruby on the web browsers?

#69
post #65
post #24

Earlier quoted context omitted.

> JS running on a general VM would be slower. That's against the interests of the user. What do you base this on? It's sounds like an unsupported assumption regarding the complex technical constraints involved in implementing a general purpose VM and JIT. Putting the technical specifics aside, intuitively, why would the general VM be slower, especially since the requirement to support JavaScript would be obvious to e…

>> JS running on a general VM would be slower. That's against the interests of the user. > What do you base this on? It's sounds like an unsupported assumption No, he is entirely correct. JavaScript and most dynamic languages do not run at full speed on static-language VMs like the JVM and .NET. This is despite tremendous efforts and motivation to run those languages quickly on such environments, see for example Micr…

> JavaScript and most dynamic languages do not run at full speed on static-language VMs like the JVM and .NET. This is despite tremendous efforts and motivation to run those languages quickly on such environments, see for example Microsoft's SPUR paper and everything it has done in the CLR to speed up dynamic languages.

I'd argue the opposite regarding tremendous efforts and motivation; dynamic languages were an after-thought for both the JVM and .NET, and on the JVM side you've only seen any attempts to improve performance recently, with invokedynamic for Java 7.

The investments here occurred long after the VMs were developed.

> The reasons for this are technical: We do not know how to make a single VM that runs all languages quickly.

The same applies to compilers across the board; we do not know how to make a compiler that applies all possible optimization available to code always, either. I still have to manually vectorize critical paths, re-order code (sometimes in C!) to help the compiler avoid pipeline stalls, etc.

Instead, we do the best general purpose job we can, and it's usually more than fast enough.

What we're talking about here is a VM that has JS support as its first-order target. Using the JVM and CLR as performance examples here -- given what they were built for, and when -- is not particularly valid.

Speaking to NaN-boxing in particular; it's one solution to the problem, but not the only one. I'm going to remain unconvinced here, given that dynamic languages have almost always been a late, second-tier concern for anyone investing serious R&D in the development of a VM/JIT/compiler.

All that said ...

> The fact is, despite all those efforts, even Microsoft did not implement JS on .NET in IE. This despite Microsoft more than anyone having the capability and moreso the motivation ("everything on .NET"). Microsoft gave up and implemented a new JS engine in native code, and it made that new native JS VM a peer of .NET in Windows 8.

Even given the above, implementing a custom optimized JavaScript VM -- even if it was only available in JS-only case -- would not be a failure scenario.

Re: Why don't they implement Python and Ruby on the web browsers?

#70
post #59
post #54

Earlier quoted context omitted.

> 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?…

This generally isn't the case with disparate languages on the JVM. Unless you have a concrete objection with a scientific basis, you're just spreading FUD, and I don't think that contributes to the conversation.

> Unless you have a concrete objection with a scientific basis

I did. Please solve the problem I put forward. If you solve it, you win.

Post reply on HN