Skip to content

Comment on Beating Decades of Optimized C with 80 Lines of Haskell

Comments

What a clickbait indeed. The end version is still eating 3 times more memory, but the worst is that it just doesn't work in the general case.

The way I generally use "wc" is inside a somewhat complex command line, with commands preceding it. As in "feeding characters" to it.

There is a reason why "wc" is not multithreaded: it just can't. It must work sequentially, because in the general case the input of "wc" cannot be skipped over.

This is one of the two big assumptions that are made by the author ("wc works only for files, so we can lseek") -- the second, identified by the author, being that the underlying hardware and filesystem must support concurrent access to the same location efficiently.

Don’t forget: the best case (where it can be parallel), is still only slightly faster than the single threaded version.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.