zlacker

[parent] [thread] 0 comments
1. chrism+(OP)[view] [source] 2022-10-20 10:55:28
> I wish they had frozen a primitive version of JS and added a marker at the beginning of scripts to switch out which language is used, much in the way #lang does in Racket.

JavaScript has had basically this several times (though not after the extreme flexibility of Racket’s #lang).

• In the context of HTML, there was <script language="…">, with a variety of unstandardised values for the language attribute, e.g. javascript1.0, javascript1.4. I think there were also unofficial MIME types that worked too (something like <script type="text/javascript;…">), but it’s hard finding documentation for this ancient history and I haven’t tried for more than half a minute. In the end, it died for lack of utility and because in practice new versions didn’t break anything worth mentioning so it was all just the one thing under the hood.

• Strict mode <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...>, via the "use strict" statement at the start of files and functions. Also "use asm" as another pragma that opted out of most of the language for performance reasons.

• And ECMAScript Modules are to some extent a new file format, and a module’s contents are automatically in strict mode.

Suffice it to say: they can remove stuff if there is any will too. But there is not.

[go to top]