less_retarded_wiki

main page, file list (582), source, all in md+txt+html+pdf, report abuse, stats, random article, consoomer version

Comment

Comment is a part of computer code that doesn't affect how the code is interpreted by the computer and is intended to hold information for humans that read the code (even though comments can sometimes contain additional information for computers such as metadata and autodocumentation information). There are comments in basically all programming languages, they usually start with //, #, /* and similar symbols, sometimes parts of code that don't fit the language syntax are ignored and as such can be used for comments (e.g. in Brainfuck anything that's not a command character is ignored).

While yes, you should write nice, self documenting code, you should comment you source code as well. General tips on commenting:

Way too many comments are sometimes considered bad, there shouldn't be more comments than code, unless maybe in some super complex assembly program :) There also seem to be controversial opinions around about comments being essentially harmful at least to a degree, for example Jonathan Blow said that "comments are code that never runs and code that never runs has bugs" { I think that's a bit misleading -- comments are never run by a computer but they are run by the brain, a kind of neural network that is tolerant to many bugs, so a comment that's been read by a few people who didn't find anything wrong about it is kind of tested. Besides that by definition the purpose of a comment is not to define algorithms, comments aren't code or at least shouldn't take such role, they're there for other purposes, e.g. declaring intent, putting a reference to something and so on. ~drummyfish }.


Powered by nothing. All content available under CC0 1.0 (public domain). Send comments and corrections to drummyfish at disroot dot org.