Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Why don't browsers just build a non-JS interpreter?
7 points by spprashant 9 months ago | hide | past | favorite | 19 comments
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!




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


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

Java technically was released earlier, on May 23 of that year (https://www.forbes.com/sites/oracle/2015/05/20/javas-20-year...), but (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?


That particular claim is from one of the articles sourced in the Wikipedia entry: 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.


Thanks. My guess was that Java was released only for Sun hardware first, with the public release being more cross-platform.

I also just read the link to https://web.archive.org/web/20070916144913/https://wp.netsca... “Netscape and Sun announce JavaScript”. Didn’t know that.

Funny to read that they positioned it as “complementary to and integrated with Java” and “on the client, the scripts would glue together an assortment of Java applets and HTML form elements”.

They also (“Java programs and JavaScript scripts are designed to run on both clients and servers”) mention running JavaScript server-side.


> Netscape and Sun announce JavaScript

That's a fun trip down memory lane...

From the article:

> "JavaScript is a great way to get cross-platform scriptable access to databases and move the resulting data into Macromedia Shockwave, where it can be rendered, animated and made into live interactive multimedia for the Internet. JavaScript is also a promising core technology for the new multimedia publishing tool that Macromedia is building." - Bud Colligan, President and CEO, Macromedia

Heh, either he was thinking REALLY far ahead to HTML5, or maybe at one point JS was supposed to power Flash, instead of ActionScript?


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


JS 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://coffeescript.org/

- https://clojurescript.org/

- https://www.transcrypt.org/

I wrote https://multi-launch.leftium.com, which is only 6% JS. The majority is Svelte (65%) + TypeScript (27%). (https://github.com/Leftium/multi-launch)


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


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


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


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

We've had and discarded, that already. Flash was a different platform, much more powerful, better UI, very good response times, and so on. It was supported in every browser. Building a Flash app was common, done a lot, and well paid.

But there were unexpected consequences.

Flash apps were not searchable, or deep-linkable. (It turns out, that's a big deal).

Their UI was "fixed". You might not love CSS but it's amazing when it comes time to refresh the look of a site.

Accessibility for less-than-perfect-ableness was non existent. HTML has accessibility front and centre. Screen Readers, zooming etc.

Maintainence sucked. Change the source, recompile, redeploy. Whereas HTML, CSS and JavaScript are all source that can be edited on the fly, on the server. Sure, you're not doing that on big production servers, but for the long, long, tail of small sites, it makes maintainence a lot easier.

Learning is harder. To learn Flash I have to learn Flash. To learn CSS,if I see something I like, I can inspect it to see how it's done. (Oh, line-spacing, good to know you, I like what I see you doing.)

HTML is easier to scrape, and automate. That may be good, or bad depending on your perspective, but there's no shortage of "we integrate with x" (where x has no API) by "driving" the web site externally.

So yeah, I can see the value in talking about JavaScript, but the benefits of HTML and CSS are well understood. We tried replacing them. It didn't go well.

(I've avoided talking about the security nightmare that adding a Flash, ActiveX, Java Applet, caused. Or CPU usage. Those are issues with implementation, not the concept. But for those who weren't around, it ultimately killed all of them.)


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


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


It'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?


Yep, definitely easier said than done


JS is a beautiful language to me. In just 200 lines of code, i could build my own imaginative apps at scale.


Instead they fixed (mostly) everything that was initially wrong with JS (and now typescript).

Which is fine by me and seemingly every stakeholder out there.


I'm guessing you did not live through the hellscape of browser compatibility issues at the turn of the century.


In ancient times, some people actually scripted with BASIC in internet explorer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: