PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Does every programming language have line comments?

Does every programming language have line comments?

by Breck Yunits

July 13, 2022 โ€” About 85% of the languages in PLDB have line comments.

A language supports line comments if it defines a special token (nowadays usually // or #) where everything after that token until the end of the line becomes a comment. Example:

print "Hello world" # this is a comment

These are different from multiline comments which are delimited by a pair of tokens (such as %{ and }%).

The majority of languages use // or # to start a line comment

38% of programming languages take after C (1972) and use //. 22% use #, which has become very popular thanks to languages like Python, Perl, and Ruby.

The SQL languages all generally use --.

The era of experimentation with line comment tokens appears to be over: the last time a new line comment token appeared in the top 250 was 1993.

15% of languages don't have line comments

About 15% of the languages in PLDB don't support line comments. These include some of the key markups for the web like HTML, CSS and SVG.

JSON famously does not support comments. But a number of its derivatives do, such as JSON with Comments.

A few general purpose languages don't support line comments including Mathematica and OCaml.

A few exceptions

Like everything, there are exceptions to the common cases. A few languages, such as SPSS, have a more restrictive form of line comment where the line comment token has to be the first token on the line.

A few languages also support multiple line comment tokens. The Ini config format supports both ; and #.

Analyze this data yourself in Observable
Analyze this data yourself in Ohayo

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements ยท Email ยท GitHub