4 ms·
> But IMHO AWK takes the crown here. :) Agreed! AWK is still the king of this stuff. For tasks like this, I kinda think AWK is nigh-unbeatable: so simple to wr
by OskarS 4y ago
> But IMHO AWK takes the crown here. :)
Agreed! AWK is still the king of this stuff. For tasks like this, I kinda think AWK is nigh-unbeatable: so simple to write, so obvious what's going on (even if you've never seen any AWK program before, you're probably going to be able to figure out what's going on there), and decently performant.
AWK is the bee's knees.
- moffkalast 4y agoOn the other hand, I'm rather surprised that the Go version is almost as long and opaque as C.
- benhoyt 4y agoAre you looking at the "simple" or the "optimized" versions? For the optimized, yes, the Go one is very similar to the C. For the simple, idiomatic version, the Go version [1] is much simpler than the C one [2]: 40 very straight-forward LoC vs 93 rather more complex ones including pointer arithmetic, tricky manual memory management, and so on. [1] https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc30a9c95226575df1e5e1c5a/simple.go https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc... [2] https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc30a9c95226575df1e5e1c5a/simple.c https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc...
- moffkalast 4y agoYeah I meant the optimized versions.