List of programming languages that require newlines

A oneliner is a computer program written in a single line, without using any newline (\n) characters. This is common in interactive shell scripting, which for practical reasons are only written as a single line, and languages such as Perl and APL have a culture of writing substantial pieces of logic as single lines.

Most languages whose syntax is based on standard tokenisation, where all forms of whitespace are treated similarly, allow us to replace any newline character with a space character, and thus let us write programs of any complexity on a single line. Even languages that use newline characters rather integrally, such as Python, may have escape hatch notation such as semicolons that allows us to avoid newlines in most or all cases.

The following lists attempts to catalogue programming languages that do not allow arbitrarily complicated programs to be written on a single line. Sometimes the reason is particularly subtle (or not even clear), which are of course the most interesting cases.

Some language specifications (remember when languages didn’t just have implementations?) allow implementations to impose limits on line lengths, which naturally puts a limit on the size of single line programs. We are ignoring those limits in the following, since it’s not terribly interesting.

Further, the POSIX standard defines a line as always ending in \n, even the last (or only) line in a file (POSIX 2017, section 3.206). This also precludes \n-free programming. We will leave it to the Unix philosophers whether a oneliner may have a single newline in it. Similarly, POSIX also allows lines to have a maximum length.

The list

The co-list

These languages may look like they require newlines, but actually do not, for reasons that are subtle and/or interesting.