Live data from Hacker News

Destroying C with 20 lines of Haskell: wc

0xd34df00d.me

11–20 of 74 posts

Re: Destroying C with 20 lines of Haskell: wc

#12

This doesn't seem to be comparing anything like the same thing. Does the Haskell version really do the same thing as the C version? Does it handle all of the same error cases, providing the same quality of error messages if they occur? Does it handle localization? If not, that makes the comparison very skewed, as unhammer already pointed out. Sure, if you strip out all of the things that the people who wrote wc actua…

Does it handle multiple files, and stdin?

Anyway, destroying Haskell with 100 lines of C :-)

https://raw.githubusercontent.com/gdevic/minix1/master/comma...

Re: Destroying C with 20 lines of Haskell: wc

#13
The post is very insightful and well written. The title is provocative which is very common nowadays. However, there should be a "serious" section that puts things into perspective. As others have pointed out it leaves a bit of a taste otherwise.

Re: Destroying C with 20 lines of Haskell: wc

#14

Not being great at reading Haskell, I have some questions I was hoping people here could answer: * Does this cope with different whitespace, such as tabs? * Does this cope with different settings of locale? * Does this include the option of the "longest line"? * Does this perform the character counts? I'm pretty sure wc does all these, and that stripping them out would make it faster. If this Haskell version doesn't…

The source code of GNU wc:

https://github.com/coreutils/coreutils/blob/master/src/wc.c

The word counting algorithm does seem to be much more complex.

Re: Destroying C with 20 lines of Haskell: wc

#15

He is comparing a multi-threaded haskell version against a single-threaded C version??? "...There’s also a parallel version that relies on the monoidal structure of the problem a lot, and that one actually beats C" coreutils wc is single-threaded, just checked.

Yes, your skimming was inaccurate.

Re: Destroying C with 20 lines of Haskell: wc

#16

He is comparing a multi-threaded haskell version against a single-threaded C version??? "...There’s also a parallel version that relies on the monoidal structure of the problem a lot, and that one actually beats C" coreutils wc is single-threaded, just checked.

  But that post left me wondering: is it possible to do better without resorting to parallel processing?
  Turns out the answer is yes.
From the introduction

Re: Destroying C with 20 lines of Haskell: wc

#18
I don't think it is very "hard" to "destroy" most of these programs, they were written a long time ago, they evolved with backwards compatibility or portability in mind, these can run on pretty much any system. It does seem a bit unfair to compare it to a quickly hacked together program that you test against one use case.

Like the other said, the second article will probably be more interesting.

Post reply on HN