wc in D: 712 Characters Without a Single Branch

sarn sarn at theartofmachinery.com
Tue Jan 28 22:11:50 UTC 2020


On Tuesday, 28 January 2020 at 14:01:35 UTC, Mike Parker wrote:
> Robert Schadek was inspired by a post he saw on Hacker News a 
> while back showing an implementation of wc in Haskell totaling 
> 80 lines.

I enjoyed the article overall, but I think this part lets it down 
a bit:

> Is the Haskell wc faster? For big files, absolutely, but then 
> it is using threads. For small files, GNU’s coreutils still 
> beats the competition. At this stage my version is very likely 
> IO bound, and it’s fast enough anyway.

Admit it, "my version is very likely IO bound" is hand-wavey.  
The top comment on HN right now is pointing out that it doesn't 
make sense.

It would be a better tech article if it stuck to the facts by 
either cutting out the hand-wavey bit (and just saying "it's fast 
enough anyway") or doing a test.  (Quick and dirty way: running 
the code on a large file and seeing if it maxes out a CPU using 
the "top" command.  More elegant way: using tools like these 
https://github.com/sysstat/sysstat/)  Remember: plenty of us on 
the forums are happy to help make a D article more interesting.


More information about the Digitalmars-d-announce mailing list