Codementor Events

A Quickie -- # // on Comments

Published Jul 28, 2017

When you wright code you are giving instructions to somebody or something. That somebody is either the computer or the human. All the code instructions written for us humans we needed to call something, so we decided to call these COMMENTS.

A Comment WILL NOT be interpreted by the computer, again it is only for us humans to interpret. Comments help us to understand what all the surrounding code we wrote for the computer actually does (or should do).

Now since the computer will read all the code line by line no matter what, we had to tell the computer which code is for 'it' and which code is for 'us'. We accomplished this separation using special characters.

Of all the special characters the computer language writer could have choose from, he or she just had to pick something, some character and not change it. This special character would then tell the computer to stop interpreting the computer code, ignore and skip the meant-for-human code, and then start-up once again interpreting the meant-for-computer code.

This start and stop process was what these special characters actually did.

Because many different humans wrote many different computer languages, there exist many different differences among each. For this topic on Comments this means that there are many different Commenting styles. Sometimes this, sometimes that.

There came into existence therefore many different styles of special characters used to separate the 'code for the computer' and the 'code for us'.

If one line of code wasn't enough space for us humans to write all the instructions we needed, we would have to continue to wright on the next line, the one right below it. If one line was enough space, then all of our instructions would simply and only be located on that one line.

Thus was born two types of Comments, both inline Comments and multi-line Comments.

An inline Comment told the computer that everything on this line was just for us humans. And when it got to the end of the line, right before it starts to read the next line, to stop interpreting the code as meant-for-the-human and start, on this new line, interpreting the code as meant-for-the-computer.

A multi-line Comment told the computer that everything on this line including the next and the next, so on and so forth, was only for us humans. A multi-line Comment therefore had to do two things, it not only had to start the Comment, but also had to stop it. Some special character had to be designated to both tell the computer where to begin and tell the computer where to end the Comment.

And here they are. Commenting styles for some popluar computer languages.

JavaScript inline Comment: // ...
JavaScript multi-line Comment: /* ... */

MATLAB inline Comment: % ...
MATLAB multi-line Comment: %{ ... %}

Pascal inline and multi-line Comment: (* ... *)

Perl 6 multi-line Comment: #`{{ ... }}
Perl inline Comment: # ...
Perl multi-line Comment: = ... =

PHP inline Comment: # ...
PHP multi-line Comment: <# ... #>

PowerShell inline Comment: # ...
PowerShell multi-line Comment: <# ... #>

Python inline Comment: # ...
Python multi-line Comment: """ ... """

Razor inline and multi-line Comment: @* ... *@

Ruby inline Comment: # ...
Ruby multi-Line Comment: =begin ... =end

SQL inline Comment: -- ...

Swift inline Comment: // ...
Swift multi-line Comment: /* ... */

Visual Basic .NET inline Comment: ' ...

XML inline and multi-line Comment: <!-- ... -->

If you know more, add more to this post.

Discover and read more posts from Shayne Sprenkle
get started
post commentsBe the first to share your opinion
Larsen Lola
a month ago

Computer programmers are professionals that create instructions for a computer to execute by writing and testing code that enables applications drift hunters and software programs to operate successfully.

Solar
3 months ago

The author’s passion and knowledge shone through every paragraph. It was inspiring. <a href=“https://evolveenergysystems.com” target="_blank" rel=“noopener nofollow ugc”>Solar</a>

salmawisoky85
4 months ago

Drift Boss is a drift racing game played by pressing a single button. In this game, you will drive your car around difficult edges and overcome obstacles until you fall off the platform.

Show more replies