4 ms·
> When someone says "write it in POSIX shell for portability," they mean well. > POSIX is a specification. Not a program. The thing that actually runs your scr
by paulddraper 3mo ago
> When someone says "write it in POSIX shell for portability," they mean well.
> POSIX is a specification. Not a program. The thing that actually runs your script is bash, dash, ash, ksh, yash, or one of a dozen others.
“When someone says ‘write it in ECMAScript,’ they mean well.
“ECMAScript is specification. Not a program. The thing that actually runs your script is Node.js, Bun, Deno, Rhino, or one of a dozen others.”
See how silly that sounds?
- gaigalas 3mo agoNo one says "Let's write ECMAScript for portability". If someone did, I would probably be writing about that too.
- hnfong 3mo agoHey guys... I have a wonderful idea. ... Let's write ECMAScript for portability.
- gaigalas 3mo agoCan you imagine? Using that fancy new gen JavaScript today? Oh wait, that's exactly babel's headline! It's just so old now that people don't need to say what it does. Actually funny that the spec drift got solved by polyfills and transpilers.
- paulddraper 3mo agoAre you serious? People say that all the time. People use JavaScript everywhere.
- gaigalas 3mo agoNope, implementors are worried about shaping the spec (which iterates much faster than POSIX) and the overall community around JS has plenty of portability solutions. That simply doesn't happen with portable shell script. There's a lot of misconceptions (people can't distinguish between shell/terminal, shell/coreutils, etc), implementors don't talk to each other. "People use JavaScript everywhere" means nothing for this discussion, it's about whether the ecosystem grasps fundamental portability questions. The JS ecosystem does (now, after some decades), the shell one does not. We have babel, core-js and many other libs. It's just a bunch of trick compilations (Ubuntu's dash vs bash page, Rich's shell tricks), nothing actually sturdy. You can try to bend the discussion to make them closer, but it doesn't survive a critical analysis.
- dzaima 3mo agoECMAScript has a pretty massive amount of fully-specified behavior though; the things that differ between those implementations is nearly-entirely limited to fresh additions like `require` or whatever. The echo thing would be like if ECMAScript allowed stuff like `"123" == 123` to give either false or true; and then indeed many things would probably break if moved across implementations. C is the closer comparison, and indeed much software that could easily be portable (and might claim it is) often depends on implementation-specific things like 8-bit bytes, 32-bit int, assuming int8_t/etc in stdint.h exist, twos complement (before C23 at least), arithmetic shift right, etc.
- 1718627440 3mo agoBecause both POSIX and C are descriptive rather than prescriptive. When people have different ideas, and others already depend on both behaviour, that's the best you can do, without breaking compatibility.