Comment (computer programming)

commentcommentsREMcode commentscommented outcommentedsource code commentcode commentCOMcomment feature
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.wikipedia
230 Related Articles

Source code

codesourcesource file
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.
In computing, source code is any collection of code, possibly with comments, written using a human-readable programming language, usually as plain text.

Delimiter

delimiter collisiondelimiteddelimit
Block comments delimit a region of source code which may span multiple lines or a part of a single line. Line comments generally use an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment, and a newline character to indicate the end of a comment.

Computer programming

programmingcodingprogrammable
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.

Comparison of programming languages (syntax)

comment syntaxStatement terminatorBasic syntax
The syntax of comments in various programming languages varies considerably.

Documentation generator

documentation generationembedded documentation generatordocument generation
Comments are sometimes processed in various ways to generate documentation external to the source code itself by documentation generators, or used for integration with source code management systems and other kinds of external programming tools.
Some generators, such as Doxygen or Javadoc, use special comments to drive the generation.

Docstring

docstrings
Forms of docstring are supported by Python, Lisp, Elixir, and Clojure.
In programming, a docstring is a string literal specified in source code that is used, like a comment, to document a specific segment of code.

PHPDoc

PHP Doc comments
Examples of documentation generators include the programs Javadoc for use with Java, Ddoc for D, Doxygen for C, C++, Java, IDL, Visual Expert for PL/SQL, Transact-SQL, PowerBuilder and PHPDoc for PHP.
It is still an informal standard for commenting PHP code, but it is in the process of being formalized.

Lexical analysis

tokenslexical analyzertoken
Line comments generally use an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment, and a newline character to indicate the end of a comment.
In older languages such as ALGOL, the initial stage was instead line reconstruction, which performed unstropping and removed whitespace and comments (and had scannerless parsers, with no separate lexer).

Shebang (Unix)

shebanghashbangshebang line
The shebang line is usually ignored by the interpreter, because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose.

Visual Basic .NET

VB.NETVisual Basic.NETVisual Basic
C#, F# and Visual Basic .NET implement a similar feature called "XML Comments" which are read by IntelliSense from the compiled .NET assembly.

Syntax highlighting

syntax highlightColour highlightinghighlighting
These may include insert positions for automatic header file inclusion, commands to set the file's syntax highlighting mode, or the file's revision number. They may then be able to be searched for with common programming tools, such as the Unix grep utility or even syntax-highlighted within text editors.
The comment at the beginning is also highlighted in a specific manner to distinguish it from working code.

Design by contract

contractscontractdesign contract
Comments are sometimes used to document contracts in the design by contract approach to programming.
Contracts can be written by code comments, enforced by a test suite, or both, even if there is no special language support for contracts.

Self-documenting code

self-documentingself-describing
Some assert that source code should be written with few comments, on the basis that the source code should be self-explanatory or self-documenting.

Directive (programming)

directivedirectivescompiler directive
There are cases where the normal comment characters are co-opted to create a special directive for an editor or interpreter.

Text editor

text editorstext editingeditor
They may then be able to be searched for with common programming tools, such as the Unix grep utility or even syntax-highlighted within text editors.

JavaScript

Server-side JavaScriptclient-side JavaScriptJS
JavaScript uses // to precede comments and /* */ for multi-line comments.
Note the comments in the example above, all of which were preceded with two forward slashes.

Lua (programming language)

LuaLua programming languageLuaJIT
The Lua programming language uses double-hyphens, for single line comments in a similar way to Ada, Eiffel, Haskell, SQL and VHDL languages.
A comment in Lua starts with a double-hyphen and runs to the end of the line, similar to Ada, Eiffel, Haskell, SQL and VHDL.

Annotation

annotatedannotationsannotate
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.

Computer program

programprogramscomputer programs
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.

Compiler

compiledcompilerscompile
They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.

Interpreter (computing)

interpreterinterpretedinterpreters
They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.

Programming tool

Software development toolssoftware development toolsoftware tool
Comments are sometimes processed in various ways to generate documentation external to the source code itself by documentation generators, or used for integration with source code management systems and other kinds of external programming tools.

MATLAB

alternativesfilem-script
Some programming languages (such as MATLAB) allow block comments to be recursively nested inside one another, but others (such as Java) do not.

Java (programming language)

JavaJava programming languageJava language
Examples of documentation generators include the programs Javadoc for use with Java, Ddoc for D, Doxygen for C, C++, Java, IDL, Visual Expert for PL/SQL, Transact-SQL, PowerBuilder and PHPDoc for PHP. Some programming languages (such as MATLAB) allow block comments to be recursively nested inside one another, but others (such as Java) do not.

C++

C++ programming languageC++98C with Classes
Examples of documentation generators include the programs Javadoc for use with Java, Ddoc for D, Doxygen for C, C++, Java, IDL, Visual Expert for PL/SQL, Transact-SQL, PowerBuilder and PHPDoc for PHP. For example, C++ has block comments delimited by and that can span multiple lines and line comments delimited by.