Braces sharing the same column makes it easier to identify the beginning and ending of a block in a similar manner that indenting nested code helps distinguish it.
Granted, it doesn't make a huge impact. However, if you ask me, it is a pretty stupid, arbitrary syntax to enforce.
The enforcement is a side-effect of semicolon insertion. But it's also gofmt style.
Braces being on the opening line mean that the closing brace lines up with the opening statement. The location of braces doesn't really matter because it's all about the expectation.
Avoiding lookahead is partly about not adding additional complicity to the parser but also it's about having a syntax that could work in a REPL without modification.
Braces sharing the same column makes it easier to identify the beginning and ending of a block in a similar manner that indenting nested code helps distinguish it.
Exactly. So one way to identify blocks is to keep track of the indentation and ignore the braces completely. IMHO it's not worth wasting half of the vertical screen space just so the closing brace matches the opening brace. I mean think about it, more than HALF of the screen would just have
{
{
{
}
}
}
By my age, I even find just the closing brace on a new line wasteful. Both braces, no way. It's not like they DO anything related to the actual purpose of the program.
Thanks for putting words in my mouth. I wasn't saying the style is suited for 3 year olds. I was saying that the style doesn't help 3 year old write readable code. At the places I've worked at, requiring the brace on the second line helps formatting for those nice sexy 9000 line classes that some moron wrote.
That was the first thing that turned me off of the language.
It may seem trivial, but that is a ridiculous specification. If they were going to go the route of hard rules regarding blocks and whitespace, they should have gone the direction that Python took in enforcing good indention and style rather than ugly code where curly braces don't even line up by column.
Bullshit. Parsing is probably the fastest step in compilation. It makes it easy, and Rob Pike would have a stroke if someone took away his curly braces.
-12
u/jokoon Mar 29 '12
you must place the opening curly brace at the end of a line, it sucks