Curly bracket programming language: Difference between revisions

Content deleted Content added
No edit summary
Line 1:
'''Curly brace''' or '''bracket''' [[programming language]]s are those which use [[balance]]d [[bracket]]s ('''{''' and '''}''', also known as "brace brackets" or simply "braces") to make [[block (programming)|block]]s in their [[syntax]] or [[formal grammar]], mainly due to being [[C programming language|C]]-influenced.
 
== History ==
Curly-bracket style goes way back before C. [[BCPL]] was the first language to use a curly bracket style, for outlining multi-statement function bodies. [[Ken Thompson]] gave the feature more glory in [[B programming language|B]]. Because [[C programming language|C]] was initially designed after B, C has retained the bracket style of B. [[C syntax]] should really be B syntax. Most languages that came after C ([[C++]], [[Java programming language|Java]], [[ECMAScript]] and its popular descendant [[JavaScript]], [[C Sharp programming language|C#]], [[D programming language|D]], etc.).
 
== Statements and blocks ==
Line 17 ⟶ 20:
 
but this is not recommended, as it becomes nearly impossible for a person to read after the program grows beyond a few statements.
 
A popular way to work with curly braces is with the [[K&R]] style:
 
int i;
for(i = 0; i < 10; i++) '''{'''
printf("%d", i);
doTask(i);
'''}'''
 
There are many other ways to identify statement blocks, such as ending keywords that may match beginning keywords (in [[Ada programming language|Ada]], [[Pascal programming language|Pascal]], [[REXX]], and [[Visual Basic]]), the [[Off-side rule]] of indentation (in [[Python programming language|Python]]), or other symbols such as parentheses (in [[Lisp programming language|Lisp]]). These ways are not necessarily exclusive: whereas indentation is the default in [[Haskell programming language|Haskell]], curly brackets can be used when desired.