The
curly brace family of
computer programming languages are a number of
programming languages that share superficial
syntactic similarities, including:
- curly braces '{' and '}' to delimit code blocks.
- == for equality test, and = for assignment.
- semicolon as statement delimiter, i.e. a semicolon after each statement.
- Case sensitivity.
- lexical scope in most cases. Perl breaks this, partly.
- Most of them (Perl excluded) insist on empty braces for function calls that take no parameters.
- Often other C-style control structures such as for loops and increments. e.g.
int x;
for(x = 0; x < 10; x++) { DoSomeOperation(); }
These features surfaced in the
C programming language in
1971, though its predecessors
BCPL and
B show many of them.
This syntax has some merits: it is terse yet readable. But this alone cannot explain its position. The rest is down to history.
C became popular, then C++ became popular as it was "a better C". Java and Perl would not have used this syntax if it wasn't for C and C++, and the rest followed that trend. This positive feedback effect has made the curly brace style the most common syntax.
The best known curly brace languages are C, C++, Objective-C, Java, C#, PHP, JavaScript, Perl. These languages differ widely in how they actually work, but the superficially similar syntax is chosen in new languages for reasons of simple familiarity.
Most of these languages are procedural and/or object-oriented. Some are strongly typed (e.g. Java), some are weakly typed (e.g. PHP).
The code
if (x == 2)
{
y = 3;
DoSomeOperation();
}
... could be from any of these languages except Perl or PHP. These would require the minor change of a $ sign before the variable names x and y.
Another style is the pascal family of languages, which delimit blocks with begin and end, among other minor differences. Although there are IMHO better criteria on which to divide up programming language families than on the spelling of certain textual tokens, it seems to be a good indicator of underlying heritage in this case.
Another popular language outside of the curly brace family is python, which uses white space to delimit blocks.
Inspired by the equivalent writeup on wikipedia.