Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Wednesday, October 5, 2011

Choice of language

Perl is my first choice of language for writing tools for my own use. But recently I've been using C++ more instead, because I get an executable which can be stored on the PATH and is therefore quicker to invoke than typing the path to Perl and the path to the scripts directory.

But... The last tool I needed was a program to rewrite a list of files in order so that their modification time order was the same as their name order. This took 12 hours' C++ development time - I had to write a Directory class, a string class and a Rewriter class as well as debug my memory allocation.

For comparison, I wrote the same thing in Perl and it took 2 hours. I still had to write a Rewriter class but of course the Perl version took much less time to create.

Now, assuming each invocation of the C++ version is 10 seconds faster to type, I've got to use the tool 3600 times to get back the extra development time I invested in the C++ version. Which I'm probably not going to do as I only need it for reordering image files so they come out right in gallery viewers.

Of course, the C++ version runs faster, but I don't need it to run faster. The sole gain was in the experience of writing C++, which I haven't done in earnest for about 15 years.

So the moral of the story is not just to consider development time, or execution time, but also how often you're going to use the program you're writing.

Followers

Blog Archive