10 ms·
Why don't they implement Python and Ruby on the web browsers?
- reaktivo 15y agoI remember being impressed by a Microsoft project[1] a few years ago that did exactly this, it seems it never took off. [1] http://visitmix.com/labs/gestalt/ http://visitmix.com/labs/gestalt/
- BrianLy 15y agoIt's based on IronPython/IronRuby/DLR. I've been to a few PyCons and the CPython-based developers never seemed all that interested in it due to library support, and the majority of work happening on UNIX platforms. At the same time .NET developers didn't know what to do with this great set of tools.
- hannibalhorn 15y agoOne point not in the existing comments is the event driven nature of the browser - even if you're eventually able to have good support for other runtimes in the browser (e.g., you can use Python via the Native Client plugin) most of them have such a large existing codebase of blocking code that I think you'd run into a lot of the same issues that you do now with Ruby & EventMachine, or Python & Twisted. It's what made Javascript such a great fit for nodejs - no big existing libraries of blocking code, and everybody was already accustomed to doing things in an event driven style due to the browser.
- dextorious 15y agoThat doesn't make any sense. Javascript libs are just as blocking as any python or ruby lib. "no big existing libraries of blocking code" (for js) just translates to "no big existing libraries", period. It's not like javascript has any special support for non blocking code --or that any code that does anything useful and specific (ie. not just handling out work to be done and callback/returned but actually doing the work) can ever be non blocking.
- mhansen 15y agoJavascript has anonymous function closures - nice sugar for a non-blocking API. Python doesn't have them.
- tolmasky 15y agoNothing in these languages prevents them from being event-based or non-blocking. All these languages have perfectly fine callback architectures. Javascript wasn't magically designed to be event-based, its just that the DOM APIs (which have nothing to do with JavaScript) were written in an event-based way because it really couldn't have been done in any other way. Similarly, if you were to put Python or Ruby in the browser you would necessarily need them to have some sort of DOM APIs (or there wouldn't be very much they could do in the browser). Those DOM APIs would once again be written in an event-based way. The "big existing libraries of blocking code" would be inconsequential since they would for the most part have nothing to do with the kinds of things you are doing on the web. Who cares if theres some file reading code in Ruby that is blocking? You don't read files in browsers. Think of the opposite proposal: if I went and implemented these same libraries in the same blocking fashion in JavaScript, it wouldn't all of a sudden become a worse language for the browser.
- doublerebel 15y agoThe browsers themselves are already built and powered using JS. Maintaining a comprehensive API at the speed that web tech advances in more than one client-side scripting language would be hellish -- browser vendors already have enough trouble agreeing on CSS and JS standards. The Stack Overflow article already raised a number of good reasons why not. Not sure why this is garnering so much attention from HN.
- dman 15y agoWhy arent browser UI's created using HTML, CSS and JS ?
- wwweston 15y agoI think the various Mozilla projects actually do have facilities for this, and that some significant portion of the chrome is done this way. Where browser UIs aren't done this way, though, I suspect it's because the APIs are for components that aren't markup based -- you write the software for the platform with the APIs it provides, or (as I believe Mozilla has done) you write your own platform on top of something else. I think the real question to ask yourself is -- if the conventional patterns of the desktop API that we'd more or less laid down by the mid 90s were so generally awesome, why didn't some universal client based on them take off instead of the web? It's not as if we didn't have network aware desktop-style clients at the time...
- dman 15y agoI think we are asking opposite questions - if web based UI's are so awesome and have no caveats attached for display based apps then why are browsers not written using HTML, CSS and JS ? I am asking this question because I know at least one person from mozilla has replied to this thread.
- randomdata 15y ago"why didn't some universal client based on them take off instead of the web?" Because you had several companies all fighting to have their desktop platform be the standard. The web slipped in the back door because nobody felt threatened by a hyperlink document publishing system. As such, it was the only platform that was available everywhere. Worse is better. Interestingly, the web is starting to adopt the old desktop model. If you look at many of the emerging frameworks for web development (talking client side here), they all seem to be loosely based on the work of OpenStep. It is actually a really great question posed by dman. If the web is suitable for applications, the browser chrome should be one of those such applications.
- nupark2 15y agoThe top comment states that any other options are impossible: "At this point we must concentrate on improving the language." I can't stand this willfully defeatist attitude. It's also not restricted to stack-overflow participants -- this position is pervasive at Mozilla. 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? Can you imagine if we had locked desktops and mobile only a single implementation language? Google seems to be the only company actively looking for a solution via NaCL. Most of the web community, on the other hand, regularly opposes efforts to move away from JavaScript as the one true language.
- johno215 15y agoI think the reluctance comes from being burned by Microsoft infusing their own technologies into the web browser in the past. I realize that Python and Ruby would be standard and open but people still fear the possible fragmentation.
- nupark2 15y agoIf the browsers were to implement a general purpose VM, the choice of actual high-level languages would be distinct from the browser maker, and open to experimentation and competition.
- chollida1 15y agoI don't think it's as cut and dry as that. What if we do have a general purpose vm. Doesn't each browser still need to implement language compilers for all languages to that vm? ie what if Microsoft supports langauge foo but not language baz. Chrome supports language baz but not foo and Mozilla only supports their own proprietary language. All of which compile to the common vm. How do websites written for IE work on Chrome, and visa versa? Do all sites have to have their code byte compiled before shipping? Then your stuck with performance differences and byte code incompatibilities at best, which is about where we are now.
- 15y ago
- chops 15y agoHere's an announcement for a project implementing the Erlang VM in the browser: http://erlang.org/pipermail/erlang-questions/2011-November/062879.html http://erlang.org/pipermail/erlang-questions/2011-November/0... While not exactly what the OP is calling for, this is interesting nonetheless, and it does provide a mechanism for using at least one other language in the browser, even if it uses JS as the platform, rather than natively supported.
- Tobu 15y agoTons of languages are doing that: OCaml, Python, Java (and Dart and GWT), C, C++ off the top of my head. I don't think it will catch on, because Javascript has been good enough and these runtimes have overhead.
- VikingCoder 15y agoMono (actually a fork of it) can already compile C# to run on Chrome NativeClient. So, you're very close, there. Also, this: http://mail.python.org/pipermail/python-dev/2009-June/090038.html http://mail.python.org/pipermail/python-dev/2009-June/090038...
- yalogin 15y agoThe other way to put this question is - Is there sufficient reason/motivation to try to replace Javascript with something else? What does JS lack or what are its limitations?
- tikhonj 15y agoProper tail-calls! Of course, I think neither Python nor Ruby support them either, but one can dream...
- mixmastamyk 15y agoThe lack of keyword default arguments drives me nuts, python just does it so well. Not to mention ===, etc, etc. None of these things are a showstoppers, but rather amount to "death by paper cut" that in my mind that make the language unsatisfying to use.
- danmaz74 15y agoYou can just use CoffeScript for those little problems.
- mixmastamyk 15y agoI've looked at it, and while nifty, makes me worry about leaky abstractions and future support. Now that you mention it if I'm going to do that, why not use the python-to-javascript compiler from pyjamas? ... hmm.
- danmaz74 15y agoThe difference is that CF is very close to javascript and makes it very easy to transition. But of course, if you prefer python, why not :) Talking about future support, as CF is included in Rails 3.1, I guess that it should be guaranteed enough.
- mixmastamyk 15y ago
- GigabyteCoin 15y ago"closed as off topic by casperOne♦ 8 mins ago" ... The number of programming topics I have had closed on that site angers me. They are becoming Wikipedia.
- tikhonj 15y agoI'm also annoyed by the overly eager closing, but in this case I think it's justified: it's a relatively argumentative question with no real answer. The goal behind StackOverflow is to be something vaguely like interactive documentation for all of programming, so something like this doesn't really fit in. I imagine it might fit better with a site like programmers.stackexchange.com.
- d0mine 15y agoThe question is not closed at the moment.
- GigabyteCoin 15y agoLooks like Casper really is a cowardly ghost.
- Tobu 15y agoIt's justified. The site is used for problem solving. Here the problem isn't the asker's, it can't be meaningfully solved by anyone on the site, and it is a matter of opinion whether any answer comes closer to solving it, or that there is a problem at all.
- GigabyteCoin 15y agore: "The site is used for problem solving." So says YOU. What's so inherently wrong with letting the people decide? Obviously, a few hundred people found that post quite relevant to the website's topic, helpful, and interesting. What gives Casper the right to destroy hundreds of people's discussion on a topic that they all deem relevant. The "vote" on that action was approximately 300 to 1. That 1 vote of no confidence by Casper counts more than everybody's for some reason. That is what really gets me.
- ebbv 15y agoIf you spend all your energy complaining about JavaScript and demanding the browser vendors provide you with a better replacement the problem here is not JavaScript, it's you. JavaScript is far from the best language ever created, but it's also far from the worst. The biggest pain in the ass working with JavaScript on a day to day basis is not JavaScript itself -- most of its follies can be avoided by good programming practices -- it's the DOM.
- winteriscomming 15y agoJS has lots and lots of fundametal issues. Weird OO implementation (argue all you want but prototype inheritance is not what the prevailing wisdom is on how to do OO), no type system (at least give the option!), no packages/modules, no generics. Don't people want dev tools to better help them building and refactoring web code? Web dev is like 15 years behind server development.
- bzbarsky 15y agoOf course some of these things are being fixed (e.g. modules are being added; there has been talk of optional types). At least when Google or Microsoft aren't dragging their feet and sabotaging the process. As for generics, I'm not sure what you're looking for there; it's pretty simple to write generic functions in JS, or indeed any language with duck typing, no?
- slurgfest 15y agoI really don't think it's fair to insist that if anyone doesn't think Javascript is the optimal solution to every client-side web programming problem, they are themselves 'the problem'. "There are worse things than Javascript" is not a great argument for why nobody should ever try to improve the situation.
- zeeone 15y agoIf Python uses indentation rather than curly braces or keywords, then it would not allow for minimization or obfuscation when used in the browser. This is the main reason IMO Google chose to design Dart with curly braces.
- tikhonj 15y agoPlaying the devil's advocate, if the browser just had a VM and ran bytecode, the syntax wouldn't matter.
- mixmastamyk 15y agogzip will negate a great deal of that advantage.
- munificent 15y ago> IMO Google chose to design Dart with curly braces. I don't think minification was a concern. Familiarity was: the world's most popular languages are curly-based so adopting that makes the language easier to learn for millions of coders.
- whalliburton 15y agoJavascript is a perfectly reasonable underlying language. Nothing that I know of stops people from compiling python or ruby into javascript. I would never write pure javascript, but using languages that compile to javascript has been pure joy. See http://common-lisp.net/project/parenscript/ http://common-lisp.net/project/parenscript/
- mbowcock 15y agoThis is an interesting implementation of python in the browser. It's a python interpreter written in JS, so you wouldn't need any new software on the users end. http://www.skulpt.org/ http://www.skulpt.org/
- Pedrom 15y agoI would prefer a standard byte-code VM inside of every browser so we could just make compilers targeting that VM. Then anyone could choose their preferred language :)
- slurgfest 15y agoI would too, but what will be the characteristics of that VM? And who 'owns' the technology?
- sampsonjs 15y agoJust don't tell me we need to have JavaScript on the server side too, for like, consistency, man.
- winteriscomming 15y agoA byetcode/VM approach would be an improvement on the web client. This has been used successfully for 10+ years on the server (JVM, CLR), so why not learn from things and advance the state of web development. I don't understand why people defend JS so passionately. It was build in like 2 weeks, wasn't designed to build large complex applications, and hasn't really advanced at all since its inception. There are better options out there and the web development community should welcome any improvements to close the gap from Native to web.
- stephth 15y agoQuoting a comment under the question: Language preference aside, the fact that no language has good support in the browser, the server and stand-alone totally baffles me. I do wonder about this. I don't think the challenge of the task is the only answer. I think - guess - the rest of the answer might be that in practice, most developers focus on one of those, maybe two (most probably server and browser), rarely the three of them. I know first hand that some do work on the three, but they must be rare, seeing the interest in this. Maybe the momentum of the app stores bringing web devs to work on apps could gradually make people more aware of the benefits of having a universal language. Don't get me wrong, I enjoy the variety of languages, but I would be very happy to be able to focus and become proficient at one only language, even if that means giving up on some language specific advantages. Ironically (given of the context of the comment), javascript might be what comes closest today.
- rbanffy 15y agoThe shortest good answer I can come up with is reducing security exposure. Ending support for JavaScript is not an option, so browser makers would have to deal with the surface of one or two extra languages in addition to JavaScript. I don't think they need the extra work.
- stock_toaster 15y agoThose languages (which I both quite enjoy) are a bit slow though. Maybe something like Lua which already has a pretty amazing JIT available?
- elchief 15y ago1. why does stackoverflow close all the interesting questions? 2. fuck is wrong with javascript?
- htilford 15y agoInteresting questions don't have definitive answers.
- DanielRibeiro 15y agoWell people are doing something: http://repl.it/ http://repl.it/ http://syntensity.com/static/python.html http://syntensity.com/static/python.html https://github.com/replit/emscripted-ruby https://github.com/replit/emscripted-ruby