views:

392

answers:

13

Why are comments different colors in different programs? Is it just aesthetic or is there an actual reason?

+11  A: 

It depends on the settings in your IDE or editor. Comments don't have a set colour. They are just letters.

Aiden Bell
Thanks Cyclone!
Aiden Bell
What, you've never put terminal control characters in your comments?
Joshua
+3  A: 

purely aesthetic

ghills
+7  A: 

I assume it is to make them stand out so people do not easily confuse them with code.

JD
Well yes, but I really just wanted to know why some IDEs use green versus gray or any other color.
Cyclone
A: 

It's just for aesthetics and usability, it makes it clear what will and will not be compiled into code, and what's important to read to understand what's going on.

Marc Charbonneau
+3  A: 

Comments are colored differently to make them stand out from the rest of the code (making it easier to read and follow along the comment trail).

Why they are certain colors is entirely up to the makers of the editor in question (usually based on usability studies), but you can almost always change these using the settings of the IDE.

TheTXI
A: 

I'm not really sure what you mean, but I'm assuming you are wondering why different IDEs use different colors for comments in their syntax highlighting. It's mostly just aesthetic, but you can usually change the colors if you want.

Zifre
+1  A: 

It is strictly aesthetic. If you use a good IDE or text editor, you can change the color of the comments to be whatever color you like!

I use Visual Studio 2008 at work and I see a lot of the guys changing the colors for reserved words, to class names, to you name it.

Artel
+1  A: 

Most programs allow you to customize color schemes, including the color of comments. Coloring source code, comments and other things, allows the code to be more readable. The choice of particular colors is personal and aesthetic.

Robert
+2  A: 

As Aiden said, it's really up to whoever is implementing the IDE to choose. I'm familiar with green code comments, as both SQL Server Management Studio and Visual Studio are green by default, but there's no reason why a developer couldn't (for instance) choose fuschia, or lemon yellow, or chartreuse, in their IDE. Loaded into another IDE, the "code comments" would display in that IDE's colour.

Aaron Alton
Actually, I don't believe chartreuse is allowed. By any IDE. Anywhere. Ever.
Oh no, chartreuse is preferred by the most discriminating programmers. Only because IDEs haven't yet implemented the "marquee" font, which would clearly win out over everything else ;-)
Aaron Alton
Can I make code comments <blink> ??
Wouldn't `<marquee>` be better?
Eric
+1  A: 

I am assuming you mean "development environments" when you say "different programs".

But in general, you are correct. There is an aesthetic, as well as usability, component to it. Development Environment (IDE) makers (e.g., Microsoft's Visual Studio) do usability studies to determine what colors are "best" for development. Like what color to make keywords, comments, etc.

But these default color preferences are generally easily changeable by the user.

Joel Marcey
+3  A: 

To confuse color-blind managers.

Nikolai N Fetissov
A: 

back in the day, the screen was black and all of the letters were green! they are various colors to help you determine the usage of each (comment, command, variable, etc.) isn't progress grand!

KM
+1  A: 

Gray or green are used for comments, as the other colours have more desirable properties and so are reserved for more impactful areas of the code.

For example, tight loops are often in red to make them go faster, and code for children is often blue (for the same reason they learn handwriting in blue), to make it less difficult and more familiar. Blue is often also used for language keywords and APIs to make them easier to understand.

Very important code or comments are in green, due to the increased ability of the human eye to discern green.

Black and grey are used for tedious and boring areas of the code, to encourage you to look elsewhere, such as the bright and exciting interfaces and documentation (which are in blue and green as above).

Viruses, trojans and the like are always written in white, so they can evade detection by the majority of desktop themes.

Matt Joiner
http://www.colorforth.com/cf.htm
Michael Myers