, 8 tweets, 2 min read
My Authors
Read all threads
The 'wc' (word count) program that comes with most Unix/Linux systems is inexplicably slow. I mention this because people like to implement it using other languages to demonstrate why they are just as fast as C.
news.ycombinator.com/item?id=215597…
It's a simple program. It just counts the number of words in a program, where a "word" is anything separated by space.
In other words, the previous tweet has 1 lines, 22 words, and 117 characters, according to 'wc':
So 'wc' is trivial. I write very complex parsers. So I often test my parsers against 'wc' for laughs. They always end up being at least ten times (10x) the speed of 'wc'. For example, I wrote a DNS server that needs to parse the "zonefile", the text file holding all the records.
This parsing task can be slow. The BIND DNS server can take 20 minutes to parse the 8-gigabte .com zonefile. My DNS server does this in under 20 seconds, so it's fast. Running 'wc' on the file takes a couple minutes.
I haven't really looked into 'wc' to see why it's slow. I suspect part of the answer is that the problem is more complex than is it seems at first blush. It has a lot of options, and can parse Unicode.
I suspect the other part of the answer is that it's dumb. The way people are taught to parse files/packet in college is dumb, helladumb, by dumb professors. So it tends to be slow, so anybody doing not-dumb stuff is sure to be an improvement.
I suppose I need to simply write a 'wc' program in C in order to prove that code written in C can be faster than C.
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Rob ☃️ Graham

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!