News for hackers. Stuff that matters.
Re:Why We Switched from Python to Go (2021) by gkop on Thursday May 26, 2022 @12:18PM (#31520192)
For those of us not deeply familiar with Python vs Go, can you share a bit about why gofmt is so much better than the Python status quo (IE what’s wrong with autopep8 mentioned in article?)?
Re:Why We Switched from Python to Go (2021) by sliken on Thursday May 26, 2022 @12:39PM (#31520469)
Go has one, the same one used by the compiler, so there's no arguments, no multiple standards, etc. Python has a few options, and when a new language feature comes out the time to implementation may vary.

Think of it this way, if you could all the python code on github and ran it though autopep8, what fraction of the files would be changed?

Generally in the go community, contributions, patches, code, etc that's not formatted with gofmt is considered wrong/broken.

Re:Why We Switched from Python to Go (2021) by mountainriver on Thursday May 26, 2022 @02:57PM (#31522106)
It’s also an example of how Go thinks about all problems. Do things one way that is well made and roughly satisfies most use cases
Re:Why We Switched from Python to Go (2021) by kaba0 on Friday May 27, 2022 @03:42AM (#31527035)
(Other than Generics, which was known to be required decades before its existence.. sorry)
Re:Why We Switched from Python to Go (2021) by smokey_circles on Friday May 27, 2022 @05:28PM (#31535143)
required is a strong, but personal opinion. go's generics are just type switches for the lazy (over simplified)
Re:Why We Switched from Python to Go (2021) by gkop on Thursday May 26, 2022 @12:49PM (#31520579)
Thanks! More curiosity:

How do humans that disagree with the One Format deal with it? Do they self-select away from Go?

> Think of it this way, if you could all the python code on github and ran it though autopep8, what fraction of the files would be changed?

How does the format evolve over time as the community discovers improvements (if it does), and what are the implications for code on github?

Re:Why We Switched from Python to Go (2021) by sliken on Thursday May 26, 2022 @01:11PM (#31520871)
Generally I think most agree that gofmt makes pretty good decisions and it's better to have one format than competing formats that make it ugly when someone joins the team, or you are importing a library. The more you read code the nicer it is to have it all in the same format.

Like much of go, there's the "go" way to do it, and the language simplicity reduces the chance of multiple programmers taking multiple approaches that are all different enough to require wrappers to interoperate. Sure your pet feature from some other language may be missing.

The language (and gofmt) have evolved. In particular since the parser is externally usable (by gofmt, IDEs, and other tools) you can actually use that tool to rename variables, functions, etc without having to worry about getting a REGEXP right. So when there's the occasional incompatible change gofmt can parse code into a tree, make a transformation, and then back info code ... including comments.

It's relatively common (in my experience anyways) to have commit hooks in git run gofmt on go code. Generally go's been very compatible, none of the issues like Python2 vs Python3. I'm sure some avoid go for these reasons, but I lump them in with folks that reject python because of whitespace/indenting.

Re:Why We Switched from Python to Go (2021) by returningfory2 on Thursday May 26, 2022 @01:36PM (#31521176)
The point of view in Go is that the specific format is irrelevant. The design choices made by the format don't matter. What you think is "nice" code and what someone else thinks is "nice" code doesn't matter. The benefit of formatting has nothing to do with making the code conform to anyone's definition of "nice". It's just about having a format that's passable and that is then applied uniformly.
Re:Why We Switched from Python to Go (2021) by PeterisP on Thursday May 26, 2022 @01:21PM (#31520987)
If you disagree with the One Format, you can configure your IDE to show (or transform) the code in a different style while you're working with it, and have the One Format be the format for storage of the source.
Re:Why We Switched from Python to Go (2021) by theshrike79 on Monday May 30, 2022 @04:21AM (#31556695)
"Gofmt's style is no one's favorite, yet gofmt is everyone's favorite." - Rob Pike

This pretty much sums it up. Gofmt isn't perfect, but everyone uses it and deals with it. It's included with the language so there's no point in trying to create a "competitor".

Re:Why We Switched from Python to Go (2021) by snorfalorpagus on Thursday May 26, 2022 @12:28PM (#31520319)
I don't think there is a status quo. There is choice between autopep8, yapf (which itself supports 4 different styles), black, and maybe some more I'm missing. With languages that have a built in formatter this isn't an issue.
Re:Why We Switched from Python to Go (2021) by gkop on Thursday May 26, 2022 @12:39PM (#31520463)
What’s the material consequence of this lack of uniformity? When a new Python developer joins a team, is it painful or costly to accommodate their stylistic preferences? I see a single standard as a nice to have, but as long as the language has adequate tooling with reasonable defaults and quality linting, this just doesn’t seem like a big deal. Curious to learn first hand experience of those that switched from Python to Go…
Re:Why We Switched from Python to Go (2021) by prepend on Thursday May 26, 2022 @04:29PM (#31522992)
I’ve found it’s nice for detecting people who care about unimportant things.

I can’t imagine ever picking a language based on this feature and seems weird to even mention it.

This has never caused me a minute of headache and the only time I care is when conflicting styles are used in the same file.

I always thought it was kind of dumb of Go to care about this but don’t care enough to affect my language choice. I don’t use Go but am open if it’s a fit for a project.

I like that Python has that variability and let’s developer make decisions as they see fit.

I don’t want to talk to people about tabs and spaces unless we’re already friends and having a few beers.

Re:Why We Switched from Python to Go (2021) by gkop on Thursday May 26, 2022 @05:20PM (#31523506)
In candor I dabbled in Go in 2016 and found the community leaders arrogant and rude. I hope the community has evolved since then to expect more from leaders, but would need to see evidence of this before touching Go voluntarily again.
Re:Why We Switched from Python to Go (2021) by theshrike79 on Monday May 30, 2022 @04:31AM (#31556746)
I've used a good dozen languages and I don't know the "community leaders" of any of those.
Re:Why We Switched from Python to Go (2021) by BobbyJo on Thursday May 26, 2022 @12:48PM (#31520563)
The biggest issue I've felt with Python formatting is you run into build/versioning issues that basically never happen with gofmt. Also, some tools don't do everything you need, and you need multiple, like having to combine isort and black.
Re:Why We Switched from Python to Go (2021) by spapas82 on Thursday May 26, 2022 @01:03PM (#31520763)
Nowadays black is a defacto standard in python formatting.
Re:Why We Switched from Python to Go (2021) by throwaway894345 on Thursday May 26, 2022 @01:09PM (#31520836)
Black is awesome for the Python ecosystem, but it's still painfully slow for large files compared to gofmt.
Re:Why We Switched from Python to Go (2021) by Spivak on Thursday May 26, 2022 @01:26PM (#31521048)
How large is large because I don’t think I’ve ever even noticed black’s delay on 10k files.
Re:Why We Switched from Python to Go (2021) by throwaway894345 on Thursday May 26, 2022 @02:47PM (#31522018)
It would pause for a few seconds on 1-3kloc files on a fully loaded 2019 macbook pro.
Re:Why We Switched from Python to Go (2021) by philwelch on Thursday May 26, 2022 @01:52PM (#31521393)
autopep8 isn't deterministic enough. If you were going to autoformat your Python you'd want to use Black, which has the same philosophy as gofmt.