4 ms·
Huh. Did not know Awk could be so similar to Javascript. I certainly haven’t seen it written in this way before, as usually I only see it used for simple one-li
by srgpqt 4y ago
Huh. Did not know Awk could be so similar to Javascript. I certainly haven’t seen it written in this way before, as usually I only see it used for simple one-liners.
- czx4f4bd 4y agoAwk is a fun, surprisingly powerful language. Even plain mawk can do a lot, but gawk has debugger support, profiling, namespaces, and even network support. (I wouldn't necessarily go out of my way to use most of those features, but it's possible!) It's honestly worth giving the mawk and gawk manual a skim just to see what all they can do. I want to read through The AWK Programming Language as well. https://invisible-island.net/mawk/manpage/mawk.html https://invisible-island.net/mawk/manpage/mawk.html https://www.gnu.org/software/gawk/manual/gawk.html https://www.gnu.org/software/gawk/manual/gawk.html
- tannhaeuser 4y agoJavaScript syntax clearly is derived from awk's: the function keyword, regexp literals, for (x in a), optional semicolons, (associative) arrays, ... Brendan Eich said as much: "JS’s function keyword did come from AWK" [1]. [1]: https://brendaneich.com/2010/07/a-brief-history-of-javascript/ https://brendaneich.com/2010/07/a-brief-history-of-javascrip...
- benhoyt 4y agoYeah, they're both languages which are quite unlike C in operation, but both (by design) use C-like syntax to be more familiar to existing developers. I think AWK has survived incredibly well for a language that's 46 years old.
- jhbadger 4y agoThere is so much about Awk that just seems more modern than Perl, which largely replaced Awk in common usage in the mid 1990s. Maybe the similarity to Javascript (which as others have mentioned isn't coincidental) will encourage younger people to take a look at it.
- pmarreck 4y agoAwk is super interesting if you peel away a little. One nice thing about it is that the amount of code it takes to do something seems to scale quite linearly with the complexity of the thing you need to do. Which is exactly why you often see it in one-liners, but it's so much more. Recommend a deeper look at it.
- detrites 4y agoSurprised this hasn't been ported to JS, at first glance it already looks 90% done.