Multilanguage (programming) comments

Last week at work, I sat down and wrote a quick little Perl utility.

I tried to run the script, but got an error message. I looked at the code and realized that I had used "//" as a comment indicator. Too much PHP and JavaScript and, lately, Java.

So, only half paying attention, I changed the comment-start string to "/*". But that didn't work either.

Oh, of course, I thought: I forgot the close-comment string. So I added a "*/" at the end.

Bizarrely, that didn't work either.

I looked at my code again.

Then I thought, Wait, what's the comment string in Perl?

And lo and behold, when I changed the comments to start with "#" (and took out the extraneous "*/"), everything worked fine.

Moral: There should be only one programming language.

No, wait, that can't be right. Maybe:

Moral: All programming languages should use consistent and/or interchangeable syntax.

No, I don't think that's right either.

Got it:

Moral: Jed should pay more attention when writing code.

2 Responses to “Multilanguage (programming) comments”

  1. Ted

    Some might conclude that the moral is, don’t comment your code. 🙂

    reply
  2. Michael

    Moral 1: Do all your commenting in the variable names.

    Moral 2: Only write programs in Forth.

    There’s a book called Language Myths from Penguin Books which tackles various wrong ideas about human language and answers them in 5-8 pages each. Your post makes me think you should write something similar for programming languages: Why does C++ sound so fast? Which programming language is best? Doesn’t including comments in my code just make my code run more slowly/provide more space for bugs to hide/only make sense for open source software?

    reply

Join the Conversation