6 ms·
Ask HN: Why don't browsers just build a non-JS interpreter?
This is definitely a super noob question and possibly misguided. I don't work front end at all. But I am quite aware of the mountain of frameworks built on JavaScript to support modern web applications.
I was reading up on WebAssembly and how one of its intentions was to allow people to write browser code in other languages of their choice. However it seems that is proving to be quite difficult and you still have to fall back on JS at some point.
It got me thinking why don't Google, Mozilla, Apple (and Opera?) come together and build a non-JS interpreter into the browser? Google apparently tried to put Dart interpreter into Chrome but gave up somewhere along the way. So it seems possible, but just a matter of tremendous effort.
Obviously right off the bat I can think of dozen issues with this suggestion.
- This is huge engineering task, maybe impossible to achieve. Maybe it not feasible to have more than one interpreter in a browser without crashing the entire system.
- Maybe big browser vendors have no interest in doing so. They actually prefer JS?
- JS is actually fine, and any other language runtime will run into the same issues.
I am just looking for someone to explain to me at a high-level why this is a terrible idea. Thanks!
- austin-cheney 3y agoDart was dead on arrival because it was controlled by one browser vendor and everybody else refused to support it. If you wanted a non-JS alternative what would it be? Everybody has their own opinions, so… chaos. Yes, there are giant frameworks all over the place for JavaScript and the browser environment is generally feared or loathed. That is not a technology failure. It’s a training failure. You can only fix a tiny bit of that with any alternative technology. Without proper training people will find a way to fear and abuse any alternative just the same.
- ativzzz 3y agoBecause outside of a few really passionate people who hate JS with all their heart, the rest of us are really just fine using JS. It's a fine language. It does the job. Sure it can be better - everything can be better, but is it worth the cost to switch to something else?
- revskill 3y agoJS is a beautiful language to me. In just 200 lines of code, i could build my own imaginative apps at scale.
- Leftium 3y agoJS isn't perfect, but it's good enough. And there is ongoing effort to make it even better. Also, many other languages compile to JS (without WASM). Notably: - https://www.typescriptlang.org/ https://www.typescriptlang.org/ - https://coffeescript.org/ https://coffeescript.org/ - https://clojurescript.org/ https://clojurescript.org/ - https://www.transcrypt.org/ https://www.transcrypt.org/ I wrote https://multi-launch.leftium.com https://multi-launch.leftium.com, which is only 6% JS. The majority is Svelte (65%) + TypeScript (27%). (https://github.com/Leftium/multi-launch https://github.com/Leftium/multi-launch)
- pmontra 3y agoIt's not a terrible idea but it's difficult to make it work. First, they have to agree to work together. Then they have to decide which language to implement and write a spec. It must also support what browsers do in JS (DOM manipulation, APIs, etc.) Finally they have to implement it in an interoperable way. All of that costs money and what is the advantage over JS to justify those costs?
- KomoD 3y agoYep, definitely easier said than done
- uberman 3y agoI'm guessing you did not live through the hellscape of browser compatibility issues at the turn of the century.
- thot_experiment 3y agoThe new language would have to be truly transformative and revolutionary to justify the switching costs. JS is pretty good and it gets better every year. I would love nothing more than a world with LISP in the browser and everywhere else but even if everyone agreed with me, the cost of getting there from here is far too great for even my unrealistic love for parentheses.
- x1Oy6 3y ago[dead]
- wmf 3y agoLet's assume all the browsers did this. Developers still have to target older browsers, so they'd wait years before even starting to use the new language (unless maybe there could be a polyfill). So you're talking about a pretty large amount of work that simply wouldn't be used for years.
- spprashant 3y agoI thought about it briefly before about this issue I posted. If you target Chromium, Firefox, Safari you hit close to 95% of the web traffic. It is one of the "pros" of a oligopoly in the browser space. I would reckon most websites would be okay with this reach. Just a guess.
- solardev 3y agoI think the main thing here is that it isn't just Javascript that would need to be replaced. Honestly, the entire web stack isn't great: HTTP, HTML, CSS and JS were all designed in an era where websites were documents viewed on desktop computers, not responsive interactive apps that can replace everything from email to Photoshop. A truly clean and modern solution might look something more like the native platforms, or one of Microsoft's failed next-gen Windows frameworks. But to get something like that on the web, we'd end up with a completely new, separate system anyway, so might as well just use the app stores for that. There have been some attempts in at least offloading large parts of that to WASM, similar to how Figma does it, but they still use some JS and HTML too. I guess the ongoing advantage of the web is that it runs everywhere, on everything, even if the devex isn't great and the UX isn't native-like. Every time people tried to drastically "improve" the web by introducing a totally new paradigm, it has to compete against the inertia of not just browsers but also existing developers trained on HTML/CSS/JS and entrenched metalanguages like React. It's a really saturated space, users by and large don't care as long as the final product somewhat works, and whatever solution we come up with here is unlikely to beat native mobile apps anyway, so why not just go straight to that if that's the intent...? It's a lot of effort for not a lot of gain. What I do wish is that the major browser and OS vendors would get together and just drastically improve Javascript itself, adding a built-in type system, a better standard library, a standard API across browser/server/serverless/anything else, a well-designed web component system, package managing, etc., then compete on performance and support etc.
- fsagx 3y agoIn ancient times, some people actually scripted with BASIC in internet explorer.
- solardev 3y agoEarly on, in the browser wars of the 90s, this WAS what they tried. Netscape and Sun worked together to bring Java to the browser, leading to infamous "applets" that would take forever to load and have terrible UX, etc., but that ran in the browser in Java. Then they decided to create Javascript to give the browser itself a scripting language, then Microsoft copied them with JScript and VBScript, then Macromedia (later Adobe) made Shockwave and Flash, then Microsoft made ActiveX and later Silverlight... but plain old Javascript remained the lowest common denominator that ran everywhere and eventually overtook all the other attempts. Then when half the users moved to Android and iOS instead of web browsers, well, they each have their own native stacks that completely bypass the Web. And these days there are wannabe-native-for-web-devs like React Native, so even less of a reason to add another language to the Web proper, I guess.
- Someone 3y ago> Early on, in the browser wars of the 90s, this WAS what they tried. Netscape and Sun worked together to bring Java to the browser, leading to infamous "applets" that would take forever to load and have terrible UX, etc., but that ran in the browser in Java. > Then they decided to create Javascript to give the browser itself a scripting language, I don’t see how that’s a correct description of history. JavaScript is from December 1995 (https://en.wikipedia.org/wiki/JavaScript https://en.wikipedia.org/wiki/JavaScript). Java technically was released earlier, on May 23 of that year (https://www.forbes.com/sites/oracle/2015/05/20/javas-20-years-of-innovation/?sh=73cd474311d7 https://www.forbes.com/sites/oracle/2015/05/20/javas-20-year...), but (https://en.wikipedia.org/wiki/Java_(programming_language)#History https://en.wikipedia.org/wiki/Java_(programming_language)#Hi...) “Sun Microsystems released the first public implementation as Java 1.0 in 1996“. That’s after JavaScript became available on Netscape. Also, who would be “they”? Sun created Java and the JVM, but Netscape created JavaScript. I also don’t know whether Netscape helped Sun in bringing applets to the browser. Didn’t Sun use an existing API for browser plugins?
- solardev 3y agoThat particular claim is from one of the articles sourced in the Wikipedia entry: https://exploringjs.com/es5/ch04.html https://exploringjs.com/es5/ch04.html It was so long ago that my memory isn't very reliable anymore, but I do remember that Java came out first and that's why they called it Javascript (to mooch off its popularity). Then as now, it was confusing and silly. Maybe Java came with desktop applets first, or released beta versions before 1.0? I can't remember for sure. But it was definitely a thing before Javascript.
- aristofun 3y agoInstead they fixed (mostly) everything that was initially wrong with JS (and now typescript). Which is fine by me and seemingly every stakeholder out there.