Technology, careers, life and being happy

Programmers, please take five minutes to provide some data for an experiment

Whenever people talk about ack, there’s always a discussion of whether ack is faster than grep, and how much faster, and people provide data points that show “I searched this tree with find+grep in 8.3 seconds, and it took ack 11.5 seconds”. Thing is, that doesn’t take into account the amount of time it takes to type the command.

How much faster is it to type an ack command line vs. a find+xargs line? I wanted to time myself.

Inspired by this tweet by @climagic, I wanted to find out for myself. I used time read to see how long it would take me to type three different command lines.

For me, my timings came out to average about 1.4s for A, 6.1s for B and 8.6s for C. That was with practice. I also found that it is nearly impossible for me to type the punctuation-heavy B and C lines without making typos and having to correct them.

So I ask of you, dear readers, would you please try this little experiment yourself, and then post your results in the comments? Just give me numbers for A, B and C and then also include the name of your favorite Beatle so I know you actually read this. Also, if you have any insights as to why you think your results came out the way they did, please let me know.

At this point I’m just collecting data. It’s imperfect, but I’m OK with that.

Yes, I’m sure there’s another way I could do this timing. It might even be “better”, for some values of “better”.

Yes, I know that I’m asking people to report their own data and there may be observational bias.

Yes, I know I’m excluding Windows users from my sample.

Yes, I know it’s possible to create shell aliases for long command lines.

Yes, I know that the find command lines should be using find -print0 and xargs -0.

Yes, I know that some shells have globbing like **/*.{pl,pm}.

Note: I’ve heard from a zsh user that time doesn’t work for this because it’s a shell function, but /usr/bin/time does work.

The thing is, its easy to type the find commands when you’re just copying them. Likewise for the ack command. Another test would be to give someone an example of what you’re trying to do and see how quickly they could come up with the command to solve that problem. If you already know ack, you’ll probably do it quickly, but if you’re new to it, you’ll take time to read the man page. Likewise for find, you may stumble a bit with getting the right syntax for the expressions and then deciding how to use xargs.

ack can be like any other command where once you get used to it your muscle memory starts to kick in. Obviously it has for you as I couldn’t even get close to 1.4sec on multiple tries. Something else that bothers me with ack is that it tries to do a lot and you don’t really have full control over it. For instance, one may have to check what –perl really means and if that means also including .cgi files and perl scripts without extension and if it doesn’t what can I do for it to also check .cgi files in addition to using the –perl flag. Just some things to consider.

And the thing is, sure, you can make shell aliases and stuff to make long commands shorter. But to get as many features as ack has (like coloring and match highlighting), you need to essentially re-invent ack in shell. At that point, it’s easier to just help improve ack than rolling your own solution.