3 ms·
A couple of times I wrote the same thing in both bash (pure, no externals) and awk just for the heck of it, and the end result was the 2 programs were practical
by Brian_K_White 2y ago
A couple of times I wrote the same thing in both bash (pure, no externals) and awk just for the heck of it, and the end result was the 2 programs were practically the same.
I didn't expect that!
Maybe I'll dust that off and make it intentional just to see how small I can get the diff. Maybe even manage to make a polyglot.
- RodgerTheGreat 2y agoThe biggest difference for general-purpose programming is that AWK supports floating-point arithmetic (and in some implementations arbitrary-precision arithmetic), while bash does not. Shelling out to AWK is a much more portable approach to performing floating-point calculations in bash than "bc" or "dc", since it's available in more environments. Older versions of bash also have extremely limited or nonexistent support for associative arrays, which can pose challenges compared to AWK. I think AWK has much nicer, less surprising syntax than bash, but that's just a subjective opinion.
- Brian_K_White 2y agoDefinitely to get power out of bash, you end up with write-only code with half the logic in all the exansions and word splitting hacks.