The first language I dabbled in was Java and that was for a class in high school. Commenting in Java is pretty much the same as commenting in C, C++, C#, and Obj-C. Example:
/* Block Comment */
After receiving the first assignment for the class, I glanced through it and everything seem well. Although there was no specification for comments, I had to add some anyways since ever since I started coding the idea of commenting and documenting your program was pounded into my head. So of course, by reflex I commented all my programs using the double slash even though I knew Python used a different syntax and of course I got errors. So I simply had to Google up real quick how the commenting syntax for bash and Python which luckily used the same syntax for commenting using the number sign.
Bottom line is I wish all languages just use the same syntax for commenting, even though I’m sure that there are different functionality of the characters in other languages. Here is a list showing the some of the different ways to comment in different languages:
Python and Bash: # Comment
Lua (A scripting language): — Comment
Ruby: Ruby is weird since you use the number sign for single comments but block commenting requires this:
=begin comment block =end
I clicked on your post because of the catchy title, but I have to agree with the content. While doing the mult assignment I had to look up the different ways to comment in bash and python, and was frustrated that I had to do it. I too wish that there was a single commenting character. I think that there are far too many languages for this to ever be the case, but a programmer can dream..
ah yes, it’s one of those things that we just have to get used to and learn to live with. One thing that can be handy is that most programming aware text editors such as vim or emacs will have an editor command to comment out a highlighted block of code, and since the editor generally automatically knows what language you are writing in, you then just need to learn one keyboard command to comment ALL THE THINGS. See http://www.emacswiki.org/emacs/CommentingCode for details of the emacs method. I will leave the vim solution as an exercise for the reader.
Also, side comment. On the comments feed on the mother blog, the title of this comment was “comment on A comment on commenting”. How could I not click?
I completely agree that it is annoying trying to get used to different ways of commenting. Besides the commenting, the syntax is completely different which makes it really confusing after learning just one language. I guess it gets better after learning 2 or more, but besides the commenting, how python does not use semi-colons completely bugs me.
떨리는기분을 느끼시려면 에볼루션카지노 앞으로도 자주 방문할 예정입니다