Hacker News new | past | comments | ask | show | jobs | submit
The amount of fascination that people have with these "grammar nazi" bots -- some of them implementing completely arbitrary "rules" and some of them disagreeing with others on what "good" Python code should look like -- doesn't stop to amaze me.

Here's "bad" code:

     important_numbers = {
        'x': 3,
        'y': 42, # Answer to the Ultimate Question!
        'z': 2
    }
Here's what "good" code should look like:

    important_numbers = {"x": 3, "y": 42, "z": 2}  # Answer to the Ultimate Question!
Which completely misses the writer's intent. But did you notice that there are two spaces before the pound now? Also, the quotes are now double because apparently it's somehow more kosher! So much improvement!

The actual problems in the code I work with are not the spaces at the end of line or imports in non-alphabetic order, it's the 10-line list comprehensions that are so long that they're impossible for me to parse. None of these tools catch that. My place used pylint, flake8, black, ruff -- with hundreds of commits on every change. All that energy could be better spent elsewhere.

The point of the "grammar nazi" bots is to focus on the actual problems: if a bot is deciding about linting, you don't have to waste brain power to discuss it in PRs.

It is what it is, everyone gets the same, shut up and work on what matters.

I'm surprised you consider it a lot of energy spent, I tend not to spend any on this, it just runs automatically on my code and I drop out of pretty much every discussions about linting as it's good enough with automated tools.

I also used to work in places where there was no such tools, and there I had to actually spend time discussing and thinking about linting.

In my previous place, discussions on coding style were forbidden in PRs. It worked just fine.

Edit: one could also use single or double quotes in strings, and it didn't anger the grammar nazi bots as there were none.

Which gets rid of the discussion, but not the problem coding style rules are supposed to fix: Code looks the same, regardless of who wrote it. That's the whole point of code style guidelines like that as there's no functional reason for them.

That's why I like Go, every piece of code looks the same, there's one default enforced linter and this discussion (or discussion if discussion should be allowed or prohibited) doesn't even cross anyones mind.

Waiting patiently for the other person to produce a post hoc rationalization about why everybody’s code looking different is in fact a good thing
My argument is more to the tune of "everybody’s code looking slightly different is not a problem in practice as long as I can read and understand it."

However since you've asked so nicely here you go: everybody’s code looking different is because all humans are different. It's what makes us human. I am very serious about my craftsmanship, and I bring my "humanity" to it: sometimes I include a cultural reference (as in the example above), or an internal joke in the name of a (very long) variable, or vent my frustration in a comment.

My first ten years of writing Python were uneventful; nobody commented about my style and I never commented about others'. With the advent of grammar nazi bots, everyone is supposed to now please them by writing completely bland code, which in my opinion degrades me from a craftsman to a code-monkey. This is dehumanising, in a certain sense.

loading story #49057950
loading story #49058584
Can you not read code if it uses single vs double quotes?
loading story #49057584
loading story #49057421
loading story #49057413
That's exactly what a good cogwheel in the machine would say
>Which gets rid of the discussion, but not the problem coding style rules are supposed to fix: Code looks the same, regardless of who wrote it.

Which might be more overrated OCD than anything worth it. If you like that, you can add a formatter at the end of the chain or even just when reviewing.

The value isn't just in the lack of discussion, but in amplifying the signal to noise ratio of diffs. with ruff or gofmt or whatever, it’s pretty much guaranteed that a change of code is an intentional part of the proposed change. with multiple authors with variable code styles touching the same project, there is a much higher chance of a diff containing lines that preserve semantics but change the code.
There's a ton of variation in golang code, as gofmt is not opinionated enough. As evidenced by the existence of golines[0] or gofumpt[1].

0: https://github.com/golangci/golines/

1: https://github.com/mvdan/gofumpt

Is that really a problem that needs solving though? The easiest way to not spend time bikeshedding is to just not bikeshed. Don't make guidelines. Don't run tools to check them. Don't comment on them in PRs. None of it matters.
loading story #49060301
> That's why I like Go, every piece of code looks the same, there's one default enforced linter and this discussion (or discussion if discussion should be allowed or prohibited) doesn't even cross anyones mind

I remember people saying this exact same thing about Python ~20 years ago.

Using a consistent string delimiter has value: if you search for ['foo'] you will find all instances of the string foo. With inconsistent delimiters, you better have a single canonical 'foo' in your project or you're going to run into problems.
See if you know where this leads before clicking on it: https://xkcd.com/208/
loading story #49057860
When a string contains strange characters, how do you enforce the single consistent delimiter?

You probably haven't written diverse enough code.

I would hate to work on that codebase. We learn to parse code more quickly over years of looking at code written with the same conventions and style. There’s a reason why Google are so serious about following their style guides.
Even better: if someone feels like the syntax must be different, they can pick it up at a centralized repository with more people that specialize in syntax.

Afterwards it will affect production code everywhere on the planet. :)

loading story #49058497
>The point of the "grammar nazi" bots is to focus on the actual problems: if a bot is deciding about linting, you don't have to waste brain power to discuss it in PRs.

And yet, as per the example, the bot force worse linting decisions, and even pushes towards more bugs (e.g. future readers missing the comment intention since it now applies to all 3).

loading story #49059372
loading story #49060141
And yet, a new argument surfaces about whether or not the linking should take place. Some people just like to argue :)
I've never had discussions about code formatting in PRs, this seems like a made up problem or something that predates my career.
> something that predates my career

That's because everybody uses linters nowadays, which was the original point.

loading story #49059890
It's not by accident that tabs vs spaces is one of the stereotypical great debates in programming.
loading story #49057217
These used to happen all the time. In one (otherwise great) programming course in university you would even get points subtracted if you did not follow the lecturer's preferred style.

(I think that in their case it was partially because uniformity made correcting faster.)

loading story #49057218
Silicon Valley (the TV show) memed about it with its tabs vs spaces bit. It used to be a thing for sure. It has been a good 10 or 15 years since I had such a discussion. Automated linting and formatting tools largely killed it in my experience.
loading story #49057226
> this seems like a made up problem or something that predates my career

I can believe the latter, and I can assure you this was a Big Deal back in the day. There's a reason Go ships with gofmt, and gofmt was somewhat revolutionary for being a built-in "you gotta do it like this" back in the day.

loading story #49059903
Dunno, now the workflow is like agent makes code changes, ruff complains, agent fixes complaints at the cost of code bloat, agent makes a PR, another agent reviews the PR, agent makes changes, PR is approved and merged. Nobody reads PRs anymore with the agentic development velocity.
loading story #49058721
loading story #49058507
loading story #49061214
Those tools actually save team energy. Without them any programmer has different opinion on formating, code quality, what is readable etc. You can discuss it endlesly or you can just use ruff.
loading story #49056850
loading story #49059215
loading story #49056851
It’s because you forgot a comma after the last item. If you had kept that the items wouldn’t have been compacted (at least in black, I’ve stopped linking my code because it breaks intends of formatting more often than it helps)
loading story #49057414
loading story #49058451
loading story #49058800
loading story #49059446
The actual rules are less important, only the consistency of applying them is.

I find that people who argue against automatic linting and formatting tend to be the same that would argue incessantly about style. So much wasted energy, I want none of that.

Also, in your example above, if you put the comment on the line _above_ instead of inline the formatter will most likely do the right thing.

loading story #49057422
loading story #49057481
loading story #49061411
loading story #49058518
loading story #49059037
loading story #49061456
loading story #49058425
loading story #49058709
loading story #49057853
It's funny to see this comment about Python, which was designed to be a style North Korea. Maybe in a decade we'll see a Go linter and have a good laugh at that.
loading story #49058835