What Does “One JS” Mean in a World of Transpilers?
tc39.github.io
tc39.github.io
I do like the idea presented of having a transpiler track and a JS engine track. Keep the ES spec for the JS engines simpler and hoist all the syntactical sugar onto the transpilers.
JSX by comparison seems much more stable than the class and decorator proposals, although arguably its features are much better optimized by a transpiler rather than a native JS engine.
There is a circular dependency: TC39 wants new language changes to be prototyped and proven in compiled-to-JS languages but the transpiler developers don't want to implement language changes that are not already on the standards track.
Alternatively, if you focus on getting web assembly up to speed, you can compile any flavor of JavaScript you want directly to web assembly. You wouldn't need transpilers at all except for backward compatibility (which would eventually fade).
At least that's the future I'd like to see.
I don't follow. Why would losing optimizations from one language prevent optimizations from being done in an IL? Are you saying that Web Assembly can't be as fast as JavaScript? If so, why?
> There is literally no benefit, aside from being able to implement non-backwards-compatible features
You ignored the benefit I outlined above. Why would you want a single scripting language to be the only one to ever be used in a web browser? Heck, web assembly can even make the ECMAScript iteration loop tighter if you really wanted to.
I'm having trouble seeing the downsides to this approach.
Even if WASM had APIs for GC, interaction with the DOM and browser APIs, interop with JS, etc, you would still have to compile the JS ahead of time into a static binary, and so the browser would not be able to apply its JIT magic to your code.
I'm all for the dream of running any arbitrary language in the browser, but it's simply not realistic for any language that has a large runtime, which is most dynamic languages.
They also unveiled Autocad running on WebAssembly.
... and I didn't spot any mention of "WebAssembly 2.0", whatever that might mean...
Or how the Autocad guy explains the C++ code is exactly the same as on the core product.
We might loose the battle against Electron, but in the end the browser will be just yet another general purpose VM.
It will be a long time for it to be possible for JavaScript to "just be compiled" to WebAssembly while keeping the same performance characteristics, if it ever happens.
[0] https://github.com/WebAssembly/gc/issues/32 has some concerns from language implementors.
The only similarity, really, is that they're both binary formats.
Just like Unity is already doing with their Lightweight Components and HPC#.
Oh, and:
> Alternatively, if you focus on getting web assembly up to speed, you can compile any flavor of JavaScript you want directly to web assembly
You can already compile any flavor of JavaScript to... JavaScript. It even maps better than wasm. wasm really doesn't help there. Today's ecosystem _is_ that ecosystem. Except there's some hope that some variants become future core language, unlike if you were using wasm, where you wouldn't even have such a thought because you'd be using a compiler forever. But... If you're ok with that, why wouldn't you be ok with transpiling forever?