[swift-evolution] Brace syntax

Chris Lattner clattner at apple.com
Sat Dec 19 21:59:16 CST 2015


> On Dec 19, 2015, at 5:58 PM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
> 
> There is not in fact an emphasis on conciseness. This has been repeated many times by the swift team. Conciseness is not a goal of Swift, but expressiveness absolutely is. Braces are a well-understood and simple way to express the notion of a scope/closure. And FWIW removing braces means you have to come up with a completely different syntax for closures, because indentation does not suffice there.
> 
> Also, "don't be like C" is not even remotely a goal of Swift. The Swift syntax is C-like in many respects. "Be like C" isn't a goal either of course, but when deciding between two alternatives that have no compelling arguments either way, picking the one that would be more familiar to Obj-C programmers is usually a good idea.

Kevin got it exactly right, but I’d expand that last bit a bit to:

 “… picking the one that is most familiar to programmers in the extended C family is a good idea.


The extended C family of language (which includes C, C++, ObjC, but also C#, Java, Javascript, and more) is an extremely popular and widely used set of languages that have a lot of surface-level similarity.  I don’t claim to know the design rationale of all of these languages, but I surmise that this is not an accident: programmers move around and work in different languages, and this allows a non-expert in the language to understand what is going on.  While there are things about C that are really unfortunate IMO (e.g. the declarator/declaration specifier part of the grammar) there is a lot of goodness in the basic operator set, focus on dot syntax, and more.

I do agree that there are some benefits to ditching braces and relying on indentation instead, but there are also downsides.  Deviating from the C family in this respect would have to provide *overwhelmingly* large advantages for us to take such a plunge, and they simply don’t exist.

-Chris


More information about the swift-evolution mailing list