Multilanguage (programming) comments
10 February 2006, 9:28 PM
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.
Comments
Some might conclude that the moral is, don't comment your code. :)
Posted by: Ted (mail) | February 11, 2006 12:09 PM
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?
Posted by: Michael | February 12, 2006 8:11 AM