@mdhughes Are you sure Perl is a loser here? One thing it WON'T be doing is spawning yet another processs and writing all those lines to it, just to get a line count. ffs.
@mdhughes Of course, to do this The Right Way, you wouldn't load the entire set of lines into memory anyway.
@fleegman There's other stuff around it that'll live in shell, repeated a lot. Input corpus may be hundreds of lines. It needs to be a little performant.
So a new perl every call's a bad move, wc takes nanoseconds. I'd have to write the outer part also in Perl, or in that case more likely Python or Scheme, to justify launching an interpreter.
@mdhughes Well that's unfortunate. shell is a horrendous language to try to write in. The fact that you can't reduce that trivial little function to a one-liner exemplifies.
@fleegman Oh, it can be a one-liner, except the N assignment. But it's barely readable now, even if you know zsh. Beats tens of lines of C or hundreds of ASM, as I did in the day.
@mdhughes I admit I don't know the peculiarities of zsh; I'm used to bash and ksh, which are blecherous. while loops fork? whose idea was this? 😛
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.