Comparison of programming languages (syntax)

1

This comparison of programming languages compares the features of language syntax (format) for over 50 computer programming languages.

Expressions

Programming language expressions can be broadly classified into four syntax structures:

Statements

When a programming languages has statements, they typically have conventions for: A statement separator demarcates the boundary between two separate statements. A statement terminator defines the end of an individual statement. Languages that interpret the end of line to be the end of a statement are called "line-oriented" languages. "Line continuation" is a convention in line-oriented languages where the newline character could potentially be misinterpreted as a statement terminator. In such languages, it allows a single statement to span more than just one line.

Line continuation

Line continuation is generally done as part of lexical analysis: a newline normally results in a token being added to the token stream, unless line continuation is detected.

Libraries

To import a library is a way to read external, possibly compiled, routines, programs or packages. Imports can be classified by level (module, package, class, procedure,...) and by syntax (directive name, attributes,...) The above statements can also be classified by whether they are a syntactic convenience (allowing things to be referred to by a shorter name, but they can still be referred to by some fully qualified name without import), or whether they are actually required to access the code (without which it is impossible to access the code, even with fully qualified names).

Blocks

A block is a notation for a group of two or more statements, expressions or other units of code that are related in such a way as to comprise a whole.

Comments

Comments can be classified by:

Inline comments

Inline comments are generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment. Examples:

Block comments

Block comments are generally those that use a delimiter to indicate the beginning of a comment, and another delimiter to indicate the end of a comment. In this context, whitespace and newline characters are not counted as delimiters. In the examples, the symbol ~ represents the comment; and, the symbols surrounding it are understood by the interpreters/compilers as the delimiters. Examples:

Unique variants

ABAP supports two different kinds of comments. If the first character of a line, including indentation, is an asterisk the whole line is considered as a comment, while a single double quote begins an in-line comment which acts until the end of the line. ABAP comments are not possible between the statements and because Native SQL has other usages for these characters. In the most SQL dialects the double dash can be used instead.

Comment comparison

There is a wide variety of syntax styles for declaring comments in source code. in italics is used here to indicate block comment style. in italics is used here to indicate inline comment style.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article