Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: Go 2: allow Allman brace style in the parser #39421

Closed
azw413 opened this issue Jun 5, 2020 · 6 comments
Closed

proposal: Go 2: allow Allman brace style in the parser #39421

azw413 opened this issue Jun 5, 2020 · 6 comments
Labels
Milestone

Comments

@azw413
Copy link

@azw413 azw413 commented Jun 5, 2020

I know this is holy war for some and that the entire Go community are self-selected K&R bracers but, unfortunately, Go is failing to get traction because many experienced developers are not prepared to be forced into, what they consider to be, the ugly K&R style. I've read various opinions into why Go, uniquely, forces one style from the parser couldn't cope with it to the author simply mandated it because it was his favourite style. Whichever it is, I've seen several times that I cannot get Go adopted for new projects because experienced developers are not prepared to write and look at ugly unreadable code all day long. It's time for a choice.

@gopherbot gopherbot added this to the Proposal milestone Jun 5, 2020
@gopherbot gopherbot added the Proposal label Jun 5, 2020
@mvdan
Copy link
Member

@mvdan mvdan commented Jun 5, 2020

I would contest that Go is failing to get traction. It became mainstream years ago :)

@mdlayher
Copy link
Member

@mdlayher mdlayher commented Jun 5, 2020

Do you have any concrete evidence of these claims? In my 7 years of writing Go, I have never heard of anyone choosing another language because they didn't like Go's brace placement.

@ALTree
Copy link
Member

@ALTree ALTree commented Jun 5, 2020

This has been brought up in the past and is unlikely to change.

From the why can't I put the opening brace on the next line? FAQ:

Some have argued that the lexer should do lookahead to permit the brace to live on the next line. We disagree. Since Go code is meant to be formatted automatically by gofmt, some style must be chosen. That style may differ from what you've used in C or Java, but Go is a different language and gofmt's style is as good as any other. More important—much more important—the advantages of a single, programmatically mandated format for all Go programs greatly outweigh any perceived disadvantages of the particular style. Note too that Go's style means that an interactive implementation of Go can use the standard syntax one line at a time without special rules.

I also don't believe at all your claim that enforcing a particular bracing style is what is preventing Go from being chosen as a programming language.

Closing here.

@ALTree ALTree closed this Jun 5, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 5, 2020

I'll note that besides the gofmt argument, which is compelling in itself, the language uses semicolon insertion to avoid requiring semicolons as a statement terminator or separator. Go uses lexical insertion of semicolons to avoid the difficulties that people have with JavaScript semicolon insertion. That choice in itself mandates K&R brace style. https://golang.org/ref/spec#Semicolons. This is not inherently insurmountable, but it's another part of the argument.

@azw413
Copy link
Author

@azw413 azw413 commented Jun 5, 2020

The evidence I have is entirely from my own experience, one project chose Rust instead. They evaluated Go and were positive towards to it but weren't prepared to accept the enforced brace style. In another case C++ was retained partly because of the brace issue and partly because of the risk of switching to an unknown language. So, in my experience, it is having deterrence effect which is why I raised this proposal. Incidentally I'm a Go advocate, and use it for personal projects, but I also prefer the neater Allman style and I can't really justify why it isn't supported.

@patanne
Copy link

@patanne patanne commented Jun 11, 2020

@ALTree

I have been programming for almost 40 years and have written in 36 languages to date. My company develops software presently in 5 languages, if given the choice, based on a short list of variables. If required we will work with the language of whatever the inherited project originated in.

However, one language we will never use is Go, specifically because of the enforced bracing style. I personally find it completely unreadable. We also have turned down projects where we would have to use the language. We also do not contribute to any open source project that demands it. We use Allman, even in typescript.

We are one company and I am one voice. Add it to the claim you do not believe exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.