On comments

Jeff Atwood: Code Tells You How, Comments Tell You Why.
Indeed, this is a fantastic comment:
/* A binary search turned out to be slower than the Boyer-Moore
algorithm for the data sets of interest, thus we have used the more
complex, but faster method even though this problem does not at
first seem amenable to a string search technique. */
However, I would suggest not to add the comment

# Reverse the string

to document the Pearl statement

$string = join('',reverse(split('',$string)));

I would prefer to wrap the code (even if it is a one-liner) into a function `reverse_string()` instead. That way, we got rid of a comment and reduced duplication in the code.

Comments are closed.