Touchtyping analogy

Today I engaged in yet another discussion about the need of touchtyping for programmers with few of my collegues. My position on this issue is ver well known – I think that touchtyping is a requirement for a good programmer. I accept, of course, that there are few good programmers out there who can’t touchtype, but they are very few and they are only an exception that supports the rule.

While in said discussion, I was trying to come up with a good analogy from a non-IT area for a programmer who can’t touchtype. I know of two ways to come up with a good analogy.

Continue reading Touchtyping analogy

Upgraded to WordPress 1.5.1.3

I have finally upgraded to this blog to WordPress 1.5.1.3. A couple of security issues with XML RPC are fixed by this release. I was a bit slow, since the fixes were released for over a week now, but not to worry – my PHP installation already had all the fixes for XML RPC installed.

Slashdot is running a story on the issue. One of the comments shows an easy way of upgrading PEAR that not everyone might be familiar with:

pear clear-cache
pear upgrade XML_RPC

Char or trout

Consider the joke told by Richard Stallman that I read in this article:

Once I was eating in Legal Sea Food and ordered arctic char. When it arrived, I looked for a signature, saw none, and complained to my friends, “This is an unsigned char. I wanted a signed char!” I would have complained to the waiter if I had thought he’d get the joke.

Until today, the word “char” had only one meaning to me. It was a computer term, which is used as a declaration of a character or string variable in some programming languages. Such as C, for example.

It turns out, that there is another meaning. Here is a quote from the dictionary for you:

also charr (n. pl. char or chars also charr or charrs)

Any of several fishes of the genus Salvelinus, especially the arctic char, related to the trout and salmon.

Wikipedia entries for those of you who want to learn more on this fishy subject: Salvelinus, Arctic char.

Analysis of two perl lines

Today I saw these two lines in one backup script that was written in perl:

my $d = (localtime())[6];
$d = $d=~/[067]/ ? 0 : $d % 2 + 1;

Does this look cryptic to you? Probably not. But I wanted to write something and thought that these two lines won’t be that obvious for everyone out there. So I decided to explain exactly what goes on.

Before I start, I have to say that these are not just any two random lines of perl code. These are very useful lines that provide a short and elegant solution to a rather common problem. Read on if you interested.

Continue reading Analysis of two perl lines

Profiling perl

After I’ve complained on #perl channel that dprofpp (perl profiler) dies on me, I received a number of suggestions on how to profile the code without using dprofpp. Ideas ranged from elemetary insertion of ‘print “Started”, time,”\n”‘ to all sorts of dynamic subroutine overloading. Here is one elegant solution that was suggested:

sub foo { print "foo (@_)\n" }
sub bar { print "bar (@_)\n" }

for (qw(foo bar)) {
  my $name = "main::" . $_;
  my $old = *$name{CODE};
  *$name = sub {
    print scalar(localtime), " Started $name\n";
    &$old;
    print scalar(localtime), " Finished $name\n";
  };
}

foo(qw(one two));
bar(qw(three four));

Oh, and someone also mentioned that dprofpp is known to be buggy. Here is a quote from the “Profiling Perl” article at perl.com:

The other problem you might face is that Devel::DProf, being somewhat venerable, occasionally has problems keeping up on certain recent Perls, (particularly the 5.6.x series) and may end up segfaulting all over the place.