Earlier quoted context omitted.
Is there a particular benefit in writing a VM in AWK, placed in a big BEGIN block? Very similar code can be written in Perl or Python. Isn't the strength of AWK in its line-matching capability, being able to pattern-match a line against a block of code?
> Is there a particular benefit in writing a VM in AWK Not really. Later on the book just ran out of line-matching examples to go through and started doing regular programming instead :P. When I actually write AWK code I rely on line-matching and using a variable to handle state.
The Awk Programming Language
41–50 of 159 posts
Re: The Awk Programming Language
#42Earlier quoted context omitted.
This is exactly why I moved from AWK to Perl for these quick jobs a couple of years ago. If you stick to an AWK-like subset, Perl is also simple, fast and lightweight. If you want to grow your scripts (and you have a lot of discipline) Perl – in contrast to AWK – gives you enough noose to hang^W^W^W^Wthe tools you need.
Perl? Wow. Is that better than bash, python or even nodejs? Why write in Perl over these? Serious question, was propaghandized to hate Perl.
#!/usr/bin/perl
while () {
# various processing here
# $ARGV is set to either "-" for piped input, or the current filename
# $_ is the data of the current line
}
That () construct accepts data from stdin, redirection or file(s) named as arguments and iterates over the data. There's lots of things like that throughout the language.Re: The Awk Programming Language
#43Earlier quoted context omitted.
> but the fact that is simple, fast and lightweight I see awk as a DSL to be honest. Yes, it can be used as a general purpose language, but that quickly becomes, as you say, awkward :D Like many DSLs, it is simple, fast and lightweight as long as it is used for it's intended purpose . Once you start using it for something else, these advantages evaporate pretty quickly, because then you have to essentially work aroun…
DSL == Domain Specific Language?
Re: The Awk Programming Language
#44Earlier quoted context omitted.
This is exactly why I moved from AWK to Perl for these quick jobs a couple of years ago. If you stick to an AWK-like subset, Perl is also simple, fast and lightweight. If you want to grow your scripts (and you have a lot of discipline) Perl – in contrast to AWK – gives you enough noose to hang^W^W^W^Wthe tools you need.
Perl? Wow. Is that better than bash, python or even nodejs? Why write in Perl over these? Serious question, was propaghandized to hate Perl.
It can be very useful and they are pretty robust. I often found Perl scripts running for years and years without issues at different companies.
My main issue with Perl-scripts is that they often are not "readable" by anybody but the original creator. Which of course left the company. (not a fault of Perl itself tough)
But your millage may vary and any script can be made (un)readable.
Re: The Awk Programming Language
#45Re: The Awk Programming Language
#46Awk is awesome! Glad that they are looking to modernize the book. It wasn't really necessary, all the code examples in the original edition of the book still run just fine, although some are somewhat dated, like printing ASCII bar graphs. They also had examples of writing VMs, parsers and interpreters in the book, which run on modern implementations.[0] The language has some quirks. To declare temporary variables, it…
Is there a particular benefit in writing a VM in AWK, placed in a big BEGIN block? Very similar code can be written in Perl or Python. Isn't the strength of AWK in its line-matching capability, being able to pattern-match a line against a block of code?
> Hey you should read the AWK book, it even says how to write a VM!
> Why would I ever want to use AWK for that?
> Well, the input is a text file with one space-delimited instruction per line.
> Hmm... You have a point.
Re: The Awk Programming Language
#47Re: The Awk Programming Language
#48Currently looking @ alternatives (not that I dislike AWK, far from it): Tokay: https://github.com/tokay-lang/tokay frawk: https://github.com/ezrosent/frawk
Re: The Awk Programming Language
#49I was privileged to be one of the technical reviewers for this book. There's a fair bit of the original content (which is still great), but Kernighan's done a great job with some good restructuring and some significant updates, too. The early chapters are very hands-on, with something of a focus on "exploratory data processing", particularly with CSV files. Big data with AWK, you could say. Gawk and awk will soon hav…
Awesome!!!! Super excited to see this!
Re: The Awk Programming Language
#50I was privileged to be one of the technical reviewers for this book. There's a fair bit of the original content (which is still great), but Kernighan's done a great job with some good restructuring and some significant updates, too. The early chapters are very hands-on, with something of a focus on "exploratory data processing", particularly with CSV files. Big data with AWK, you could say. Gawk and awk will soon hav…