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 · 8 comments
Closed

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

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

Comments

@azw413
Copy link

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
@mvdan
Copy link
Member

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 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 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 as completed Jun 5, 2020
@ianlancetaylor
Copy link
Contributor

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 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 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.

@manujchandra
Copy link

Allman should be supported. As per my understanding, K&R was created to save printing costs of physical programming books. I know programming books are still around and we need to save trees, but vertical space is not a problem on computer screens.

For old school programmers like myself, K&R looks asymmetrical and subtly disorienting. This is not to say I cannot read or work with K&R but I prefer to use Allman.

How does the following code look to you?

func main(){
	fmt.Println("Hello, 世界")}

The above code works, but I am sure you will find it odd.

What about this?

func main()				{
	fmt.Println("Hello, 世界")	}

This works too. But I am sure you will disapprove of it.

When I look at K&R, I feel the same oddness and discomfort when you see the above two bracing styles.

I hope the developers will be considerate towards that. Its your language, I dont mean to tell you what to do with it. Its just a humble request. If you like K&R you can use that, but it should not be enforced as an error.

@mdlayher
Copy link
Member

Sorry, this isn't going to happen and the discussion is not worth pursuing further on an issue that was closed a year ago.

@golang golang locked as resolved and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants