Comp Lang: Comment Syntax

By Xah Lee. Date: . Last updated: .

a survey of computer language comment syntax

Warts of C (1972)

/********************
* ASCII art idiocy. *
* cannot be nested. *
\*******************/

Warts of Cpp (1985)

// Warts of Cpp

The C lang, like a virus, it spread to all other langs.

Single Char Line Comment

Bash (Bourne Shell, 1979)

# bash comment

Python, ruby, perl, bash, are the same.

Lisp (Stanford Lisp 1.6. 1962)

Insulting is that lisp's comment syntax is line-based, which breaks the syntactic regularity of lisp's nested syntax.

;; this is line comment

;; no block comment.
;; lisp should have block comment.
;; (* something like this *)
;; or
;; (cmt "like this")

(+ 3 4) ; by lisp convention, use one semicolon for comment at end of line.
;; 2 semicolon for a comment line by itself

;; this convention is idiotic

Clojure (2007)

Clojure fixed the lisp comment by having (comment ), however, it still supports lisp's semicolon, which is used most of the time, and defeats the purpose of the paren comment syntax.

;; line comment

(comment
block comment
(comment can be nested)
)

Symmetric Delimiters

Pascal (1970)

(* cumbersome but systematic.
(* can nest*) *)

Haskell (1990)

-- line comment

{- block comment
can be multiple lines.
{-can nest.-}
-}

Julia (2012)

#= block comment
can be multiple lines.
#= can nest. =# =#

PowerShell (2006)

# line comment

<#
block comment.
complex and hard to type
cannot be nested
#>

Comment Syntax with English Words

these type of comment are idiotic, cannot be nested.

Ruby

=begin
block comment
cannot be nested
=end

Perl POD comment (Perl 5.0, 1994)

=pod

block comment
cannot be nested

=cut

Microsoft COMMAND.COM (1980)

rem line comment
rem stand for remark
REM Case-Insensitive

Complex Ad-Hoc Crap

HTML (SGML. 1986)

<!-- sgml html xml comment.
can be multiple lines.
cannot be nested.
-->

better is

<cmt>this is a good design of html comment</cmt>