5 ms·
I wonder how much of this can be blamed on JS being a relatively gentle and forgiving codegen target.
by VyseofArcadia 3y ago
I wonder how much of this can be blamed on JS being a relatively gentle and forgiving codegen target.
- ElfinTrousers 3y agoI suspect that if some accidents of history hadn't left JS as the only language you can use to script a Web browser, it would have died off long ago.
- VyseofArcadia 3y agoI've been wondering about that lately. What is the rationale for making it necessary to run WASM binaries through JavaScript? Seems like a missed opportunity to not be able to just point a script element at a WASM blob, but I'm sure I'm overlooking something.
- dunham 3y agoWhen I last looked, it seemed like WASM blobs just take arrays of numbers and return arrays of numbers. No objects, strings, or DOM elements, so I think it'd be tough to do web dev in wasm as it stands. And you need javascript glue if you want anything in the way of side effects. There is, however, quite a bit you can do in it. TeX has been compiled to wasm[1], it's about 600kb uncompressed 90k compressed (the memory image with latex loaded is about 6MB compressed though - latex is a beast). I think anything computationally intensive would be a good candidate for wasm (it has int64). 1: https://github.com/kisonecat/web2js https://github.com/kisonecat/web2js
- VyseofArcadia 3y agoRight, yes, that's how WASM is now, but what I'm asking is why didn't we give WASM access to the DOM? We could have, and we just didn't.
- dunham 3y agoSounds good to me, I was disappointed when I learned that wasm didn’t do this already. (It’d be nice to have tail call optimization too.)
- marcosdumay 3y agoIt is one of the many things being worked on. The truth is that no part of the web standard bodies has WASM as a priority, so it moves slowly. Anyway, on practice all that means is a bit of lost performance on the DOM interaction. It's a big deal if you do a react-like framework, but the DOM has bad performance anyway, so people tend to not create react-like frameworks.
- wolpoli 3y agoGoogle already tried the blob with Native Client, but I recall Firefox decided not to support it.
- cout 3y agoI want to disagree, but I think you are right. Java and Flash were the only alternatives to javascript that ever gained a foothold, and both of them were second class citizens. Circa 2001 I tried to use Java to interact with the DOM and ran into a browser bug that iirc took about a decade to fix. If the technology had ever been usable things might have turned out differently (or it might have turned out the same, who knows).
- NoMoreNicksLeft 3y agoWhat else was there, besides VBscript, or whatever Microsoft was calling it then? Even if we're only talking hypotheticals, at what point would anyone have attempted to release an alternative? Everything was mucked up well into the 2010s with everyone chasing IE compatibility. And not even 3 years later, Chrome had taken over the world. That's a really brief window for anything to happen.
- VyseofArcadia 3y agoWhat else was there? Plenty of stuff! It could have been a lisp, it could have been a flavor of pascal, python was around even if it wasn't popular yet. Thank heavens we didn't end up with a flavor of BASIC, although as you point out it could have happened.
- hnal943 3y agojs is pretty lispy. Crockford is pretty compelling that the reason js survived (and beat Java which was the heir apparent) is because of the attributes it inherited from Scheme.
- hnal943 3y agoThe idea at the turn of the century is that Java Applets would be the way web applications would be developed. That was a disaster for security, ux, etc.
- hnal943 3y agoI don't think that's true. I find Crockford's argument compelling that js is misunderstood and that the core of the language is a diamond in the rough. https://youtu.be/47Ceot8yqeI?list=PL7664379246A246CB&t=3792 https://youtu.be/47Ceot8yqeI?list=PL7664379246A246CB&t=3792
- ragnese 3y agoHow is it a better codegen target than any other language? That's not intended with an argumentative tone- I'm genuinely curious as to what you mean.
- VyseofArcadia 3y agoIt's only a half-informed thought. I work on a project that compiles a domain specific language to C and C++. When I think about JavaScript as a codegen target, all I can see is all the problems I wouldn't have.
- anon291 3y agoJavascript benefits from the major efforts put into its JITs. No other scripting language really has that.
- marcosdumay 3y agoHum... A lot of people is working on JS codegen, so there are all kinds of knowledge bases, libraries, and standards for it. Also, JS itself got some changes to support it better. So, yeah, it's a better target than most general purpose languages. It's surprisingly simple to generate, much simpler than to write on. It is also a worse target than most languages specialized on being generated.
- brundolf 3y agoI think what makes it a popular codegen target has more to do with - The places it can run - The ecosystem it can interop with Not that it's a bad codegen target otherwise- it's high-level but performant for being so high-level, it's garbage collected, first-class functions, low-level primitives are available for optimizations, etc. But these on their own don't make it super unique