– Comments!

In the picture below, there is a lot of writing that’s in green

This writing is green because they are “comments.”
Comments are the parts of the code that the compiler ignores, but is essential to good programming. The comments allow the programmer to make notes, both to communicate to other programmers and to remind him/herself of what the program does and what each part does.

There are two ways of making comments.

End of Line Comments:

When you type // the compiler ignores everything after the two slashes for the rest of the line.

The next line is not ignored.
For example:

 motor(0,50); //This is a comment that is ignored

Everything before the // is part of the program, everything after // is a comment, but only for that line.

If you want to make several lines of comments, you will need to do a block comment which is indicated by the slash-star: /*

Actually, /* starts the block comment and */ ends the comment – no matter how many lines it takes.

For example:

/* Below I have a program, but here is a block ** ** comment. I can write * as many lines and write

whatever I want in this kind of comment, *and it will be ignored by the compiler as long as it is between

the two symbols. */

printf(“Ignore My Comments”);

Integrated Development Environments (IDEs) like KISS, provide extra help by turning your comments a different color – green is a common color for comments.

Uses for Comments

One highly recommended use of comments is the “Boilerplate.” A “Boilerplate” is a block comment at the top of all your programs that follows a specific guideline. The most recommended form is as follows:

  ***** Name Of Program "by" Programmer's Name, Date*************
 ***** Purpose of program - what's the point?      *************
 ***** What changes were made if this is a revision*************
  ***** Any additional, important information.      *************

Notice all the *’s?

Theses are used as a way of decorating the boilerplate to let other programmer’s know: “HEY! THIS IS IMPORTANT!!” It’s also to make it look like the headline of an article – like a title page.

Another, somewhat sneaky way of using comments is to “comment out” a line of code.

Let’s say that you are trying different things out and experimenting with different lines of code, instead of erasing something, them putting it back in, then erasing it again, you just type // before that line of code and it’s instantly turned off.

To bring it back, just erase the // characters.


If it’s a big block of code, just use the /* and */ symbols.

void spin_right()
     /*motor(0,-100); motor(2, 100); */

Again, to re-activate those lines of code, just erase the /* and */. In KISS you will see everything is written in green between these two symbols to tell you that they are comments and ignored by the compiler.


3 thoughts on “– Comments!

  1. Cynthia Wong

    Don’t forget to mention somewhere what a compiler is! Most students reading this probably won’t know.

    1. nasarobotproject Post author

      Cynthia, if you could write a good description of what a compiler is that would be very helpful. I have only a fuzzy idea. Something that turns code into 1’s and 0’s right?

  2. Cynthia Wong

    A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).

    So yes, it turns the code into 1’s and 0’s. It’s just like a translator. You can write code in many different languages as long as you have a compiler to turn it into the binary computer language so that the program can be executed.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s