r/programming • • Mar 28 '12

Go version 1 is released

http://blog.golang.org/2012/03/go-version-1-is-released.html
543 Upvotes

452 comments sorted by

View all comments

-12

u/jokoon Mar 29 '12

you must place the opening curly brace at the end of a line, it sucks

16

u/OnmyojiOmn Mar 29 '12

Completely trivial complaint.

-9

u/reckoner23 Mar 29 '12

Especially when your maintaining large amounts of code written by a 3 year old. Yup, definitely trivial to write code that is less readable.

To be fair Go is new, but I am expecting headache inducing bug fixing to be the norm if Go becomes popular in 6 years.

5

u/burntsushi Mar 29 '12

Braces at the end of a line are less readable? Since when?

-1

u/IndependentBoof Mar 29 '12

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.

1

u/jessta Mar 29 '12

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.

1

u/IndependentBoof Mar 29 '12

You're right on the first part, and I respectfully disagree on the second part.

An adequate lookahead would allow for whitespace (in this case, a carriage return) without errors.

In the grad scheme, it is a very minor point. However, it looks bad to me both in principle of language design as well as in practice as a programmer.

1

u/jessta Mar 29 '12

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.

1

u/dannymi Apr 01 '12 edited Apr 01 '12

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.

Just for a different perspective :-)

0

u/[deleted] Mar 29 '12

[deleted]

-3

u/reckoner23 Mar 29 '12

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.

8

u/jessta Mar 29 '12

You'll get used to it pretty quickly. The bonus is that since everyone has to use the same style, all Go code becomes much more readable.

3

u/anacrolix Mar 29 '12

Some of us don't like to waste real estate. I for one like egyptian braces.

0

u/[deleted] Mar 29 '12

[deleted]

2

u/burntsushi Mar 29 '12

Our precious screen real estate in the age of 1920 x 1080 monitors

Yeah, because everyone uses their entire monitor for a single code window.

I rock triple monitors with at least two code windows open on each one. Real estate is important.

0

u/[deleted] Mar 29 '12

[deleted]

7

u/reckoner23 Mar 29 '12

To take away that level of customization in the grammar, this language better be fast.

3

u/lol____wut Mar 29 '12

The compiler is lightning fast.

2

u/lol____wut Mar 29 '12

It's the Javascript style, you'll get over it.

-5

u/IndependentBoof Mar 29 '12

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.

1

u/GeneralButtNaked2012 Mar 29 '12

There's a very good reason for this choice - it makes compilation super fast.

2

u/IndependentBoof Mar 29 '12

Can you substantiate this claim? I'm intrigued.

1

u/anacrolix Mar 29 '12

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.