109
this post was submitted on 06 Feb 2024
109 points (94.3% liked)
Programming
17526 readers
238 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
That Python is the most readable language. Merely forcing an indentation style is only part of the issue. Python programmers have a tendency to write a bunch of named parameters all on one line, and it's a mess.
Even the automated documentation can't make it right. What the hell is this shit?
This is not enlightening. It might as well go on the shelf next to the worst regex you've ever seen. The automated doc generator needs to break these up to put one arg on each line, or just omit it altogether and let the detailed docs handle it.
It's not just the doc generator, either. I see this kind of style all the time in Python code. It's unreadable and it also makes it harder to figure out diffs when a parameter in the middle is changed (though it's helped by color coding for pull requests on GitHub and the like).
It's almost like the language attracted a bunch of people who thought indentation was the only thing you needed to make readable code. No further thought put into it.
I don't disagree that this is hard to read, but I feel it's worth mentioning python has a pretty acceptable style guide. The problem is, it's far less common in python to bundle parameters into some holding object. So here you have massive function that has to accept a lot all at once. In use it's probably not as bad looking however.
And at least, it actually explains all the damn parameters. It's a lot nicer than seeing functions parameters you don't understand, and all you have is the name. This is not limited to python either
There are plenty of other languages that have named parameters but no holding object. You format it like this:
And this works fine. Of course, not everyone does that, but I almost never see it done in Python.
This style comes into conflict with rules that functions shouldn't be longer than 20 lines for whatever. The solution to that is to be relaxed about the line count rule. I'd rather see 40 trivial lines than 20 with everything crammed up.
Completely agree with that, we have the same issue in C# where I work. Just waiting for the day I get to push and update to our shared code style (editorconfig) to force that.