2 ms·
Note Awk does have a special value for uninitialized variables—its distinguishing feature is that it compares equal to both zero and empty string simultaneously
by mananaysiempre 2y ago
Note Awk does have a special value for uninitialized variables—its distinguishing feature is that it compares equal to both zero and empty string simultaneously. (No official way to spell that value, but you can spell it e.g. “undefined” if you never initialize a variable called “undefined”.) It’s really really close to old JS in that respect, and no wonder, given that Awk was an explicit inspiration for JS. But somehow it works for Awk and not for JS, even at the hundred-line scale that’s common and reasonable for both languages.
- rusk 2y agoI never considered that awk was a precursor to JavaScript but I can certainly see that
- mananaysiempre 2y agoFound it! Wirfs-Brock & Eich, “JavaScript: the first 20 years” (HOPL ’20) [1], §3.1: > The syntax of JavaScript 1.0 was directly modeled after the statement syntax of the C programming language with some AWK inspired embellishments. (the rest of the section is also interesting in that respect). [1] https://dl.acm.org/doi/10.1145/3386327 https://dl.acm.org/doi/10.1145/3386327 (CC-BY open access)
- rusk 2y agoI could feel it all along!