4 ms·
... curly brackets on new lines do work perfectly fine in case you're writing code on your own. As soon as you start working in a team and each team member star
by donjoe 9y ago
... curly brackets on new lines do work perfectly fine in case you're writing code on your own. As soon as you start working in a team and each team member starts to use their own formatting, it becomes super messy and unreadable.
Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself and never ever have to start arguing about curly brackets, whether to use tabs vs. spaces, ... (I'll stop here).
- musage 9y agoBut why should Go enforce it on behalf of everybody? A parser option to not automatically insert semicolons would be all I need, but no. To me, even with super short lines, braces at the end of the line are messy, and consistently messy is still messy. > Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself Which then leaves the language to explain why that style is best. Did Google ever do that?
- donjoe 9y agoGo's authors didn't explicitly explain their choice of style, yet they explain why they enforce it: https://golang.org/doc/faq#Is_there_a_Go_programming_style_guide https://golang.org/doc/faq#Is_there_a_Go_programming_style_g... https://golang.org/doc/effective_go.html#formatting https://golang.org/doc/effective_go.html#formatting Style guides are a matter of taste. None is better or worse. Yet, I really don't like discussing about my taste within a team of different tastes. It's like asking someone why he/she'd prefer black coffee over cappuccino. I'd prefer someone (or the language) making a clear decision upon code style and enforcing it rather than ending up with a messy, un-styled code base.
- thegeekpirate 9y agoOfficial response: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=8m43s https://www.youtube.com/watch?v=PAAkCSZUG1c&t=8m43s
- musage 9y agoYeah, that's what I thought.
- AnimalMuppet 9y ago> To me, even with super short lines, braces at the end of the line are messy, and consistently messy is still messy. To me, they're just harder to spot. I think having them on their own line "frames" the inner block nicely. That said, brace location is not the hill I'm willing to die on. It's a minor thing, not worth getting religious over. For my own code, I'll do it how I want. For a team, though, consistency really does matter. I'll make my case, and then I'll shut up and do what the group decides. (And actually, I think consistency within a file matters more than consistency between files, so I'm fine with "The file author/main maintainer sets the style for the file. If you modify the file, keep the existing style.")
- vidarh 9y agoBut when the language/tooling enforces it, you've made language choice a proxy for style choice. A large part of what makes me stick to Ruby over Python for example, is that I can't stand languages with significant indentation. It may seem minor, but it isn't to me, to the extent where I avoid Python whenever I can. When your language enforces formatting like that, people will choose or choose away the language over the formatting. It's that important. Especially with so many languages to choose for that you can often pick one that is sufficiently similar.
- tqkxzugoaupvwqr 9y agoGo enforces a style because all code, written across different teams and organisations, should look the same so anybody can pick up anybody else’s code and read it with ease. There are no differing styles in different libraries. It’s very harmonic. What I can’t stand in other languages is the Laisser-faire attitude regarding styles. Some people put whitespace here, some there, some put the curly brace here, some there. How about some consistency across all codedbases?
- vidarh 9y agoI'm not willing to put up with harmony at the cost of the code I have to spend most of my time reading being formatted in ways I don't find optimally readable. Making people who care about formatting to the extent I do refuse to use the language is the cost of tools that enforce those kind of rules. That's of course their choice, just as it is mine to stay clear of tools (and languages) I don't consider worth my time.
- UncleEntity 9y ago> A large part of what makes me stick to Ruby over Python for example, is that I can't stand languages with significant indentation. More like 'consistent indentation' methinks. I still have nightmares about trying to merge some GSOC student's code from their branch to trunk where the indentation was all over the place, it was so bad that lint couldn't even figure out what the hell they were up to -- well, I think lint was crapping out on macros more than anything but still... So...someone got to put on their resume they did a GSOC for Blender but the work they did was basically wasted since it wasn't possible to clean it up enough to merge.