PLDB
Languages Features Calendar CSV Lists Blog About Donate Add Language
GitHub icon
languages-of-the-year-1972-2022.html · does-every-programming-language-support-line-comments.html · a-language-without-comments.html

Does every programming language have line comments?

by Breck Yunits

January 1, 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 follow C and use //. C (1972) follows B (1969) which follows BCPL (1966).

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

View source

PLDB - Build the next great programming language · v2023 · Day 153 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com