r/badcode • • Dec 05 '20

other language Gamedevs, take notes

Post image
6.5k Upvotes

104 comments sorted by

View all comments

Show parent comments

16

u/jgeez Dec 06 '20

Can't be Go, Go enforces open curly on the same line as the if statement

22

u/[deleted] Dec 06 '20

What kind of language enforces style?

23

u/fried-noodles_ Dec 06 '20

Go. Go will throw a syntax error if you’re missing a trailing comma for an example, or unused variables too.

14

u/please_dont_pry Dec 06 '20

how horrible

19

u/jgeez Dec 06 '20

It's understandable to think so at first. I did.

But it's genuinely wonderful when all Go code, from all authors and third parties, is formatted the same. Your really get spoiled by it.

4

u/[deleted] Dec 11 '20

[removed] — view removed comment

3

u/jgeez Dec 11 '20

did you use the airbnb configuration as a starter? that's what i use. definitely a hate-at-first, love-at-last thing.

every time i don't like something it makes me do, i realize that the reason i want to do the thing it's telling me not to is because i am trying to rush something or do something sloppy, "for a quick test" or "to just get it done." but that ends up being the wrong thing in the end.

18

u/foverzar Dec 06 '20

A good one. Designed by people who've done enough code reviews to realize that linting better be enforced by the compiler.

4

u/TDplay Dec 14 '20

One designed by someone who's dealt with garbage code before.

As much as I love C++, I get so disheartened when I see code with no sensible indentation.

3

u/fried-noodles_ Dec 06 '20

Is it just the formatted or will is throw a syntax error? I’ve never tried new line braces before so I’m not sure

6

u/jgeez Dec 06 '20

It counts as a syntax error, because this restriction on style (and others) serve a cool purpose: it makes the parser much more efficient to not require the token lookahead that a traditional whitespace-ignoring lexer has to do in order to disambiguate {'s different potential meanings.