This was an approach a long time ago, when Internet Explorer supported VBScript alongside JScript. Right now we still live in times when JS engines differ, some are stuck in the past and we have to somehow account for that (IE11, but also Safari on iOS if you have an outdated phone).
In the past I thought that it would be logical for web browsers to bundle jQuery as a de facto stdlib. Times have changed, jQuery brought new - incompatible - releases, now it's rarely used for new projects, becoming slowly superseded by "vanilla JS". No longer do we need Sizzle (at that time it was an internal part of jQuery), as it's now integrated into core APIs like document.querySelectorAll. Also, new methods were introduced, like Array.prototype.map, Array.prototype.forEach, Array.from, which mostly even negated the need for jQuery if you want to write some concise code.
And unlike many other languages, JS has aged extraordinarily well regarding backward compatibility. Old websites, mostly still work today. Even though I don't really enjoy writing JS, I respect many early choices in the language. It was designed as a Scheme virtual machine, only at the last time it changed a syntax to C-like, but unlike languages like PHP, there is a clear design here and it stayed consistent, mostly. And, after all, JS is surprisingly very similar to Ruby at it's core, but unlike Ruby, there are no breaking changes possible at all.
There is one big problem with JS in my opinion and it's the size and quality of it's standard library. It mostly stems from the process of creating it. And today, even if some standard library would be created, for a good couple of years we will be relying on polyfills. There is one clear benefit of a standard library - there's one, standardized way of doing things - and not hundreds of competing environments that don't necessarily mix and match well enough with one another - at the well established core. I understand the idea of the free market of open source and it's good, we are allowed to showcase hundreds of competing ideas and if one will win, it will probably be because of its superiority (or because of inclusion of a bunch of marketable words in its description), but the main question is - why should this apply to obvious things like leftPad or isOdd? This is where Ruby excels and it excels due to a good design of stdlib/corelib from its inception, but also because of its freedom to break backwards compatibility.
You probably remember Ruby 1.8 -> 1.9 migration. It wasn't perfect, but thanks to it we have good encoding support. How about JavaScript - well, it's stuck on UCS-2 strings that are interpreted by some of the functions as UTF-16 (akin to how ASCII was extended to UTF-8). And JS will be stuck with it _forever_. Sure, the engines are optimized for its internal representation, but I don't think UTF-16 is in any considered modern - and you will have to deal with its weirdness when you expect it the least. There are other classes of issues that are considered now features rather than bugs.
And about the point of "hard drives are terrabytes nowadays" I must disagree. Chromium already needs a whole day to compile and not all machines are created equal. Some contemporary mobile devices have like 32GB of flash drive and 512MB of RAM and it'd be hardly ideal to put every minor version of every programming environment. Why not include every version of a JS library while we are at it. And we would still need to polyfill those for older environments. Looking at it this way, an idea of CDNs that are well cached is a lot better, but there's an issue with centralization.
But there is another issue than storage for which there is no clear solution. In a way, it isn't warranted everywhere. If you expect your users to have powerful hardware or to wait longer than usually - and depending on a profile of your application, you can - it's not an issue. But if you expect your webpage to load and work instantly... WASM environments won't give you it - regardless of if it's already loaded to disk or not. On every page load it takes 1s to load the Ruby WASM on powerful hardware, even 5s on a less powerful hardware. And it will take 64MB of RAM from the get go. Once better hardware is thrown at the problem It will improve with time, also one site won't ever be a problem. But let's consider you have 20 tabs open, each using a barebones WASM environment and we are already talking of gigabytes.
···
On 2/21/22 16:35, Andy Maleh wrote:
WASM CRuby is 2.88MB
I think web browsers should just include the implementations of the
most popular languages out of the box, like Ruby, Python, Perl, Swift,
Crystal, etc...
That way, using languages other than JS with WASM becomes more
practical without waiting for users.
I mean, hard drives are terrabytes nowadays, so it shouldn't hurt if
browsers grow bigger a little to support languages other than JS out
of the box. Heck, maybe they can include ALL available WASM languages
out of the box, not just the common ones.