It is cool
What are some common misconceptions about programming that you'd like to debunk?
Submitted 9 months ago by mac@programming.dev to programming@programming.dev
Comments
frankenswine@lemmy.world 9 months ago
frankenswine@lemmy.world 9 months ago
It is fun
JackGreenEarth@lemm.ee 9 months ago
That’s subjective. I find coding fun.
eltimablo@kbin.social 9 months ago
Both of your comments hurt in that way only the truth is capable of hurting.
frankenswine@lemmy.world 9 months ago
i dodn’t want to flood the thread - there’s more where that came from
frezik@midwest.social 9 months ago
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?
class werkzeug.test.EnvironBuilder(path='/', base_url=None, query_string=None, method='GET', input_stream=None, content_type=None, content_length=None, errors_stream=None, multithread=False, multiprocess=False, run_once=False, headers=None, data=None, environ_base=None, environ_overrides=None, mimetype=None, json=None, auth=None)
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.
BehindTheBarrier@programming.dev 9 months ago
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.
frezik@midwest.social 9 months ago
There are plenty of other languages that have named parameters but no holding object. You format it like this:
some_func( foo: 1, bar: 2, baz: 3, )
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.
theherk@lemmy.world 9 months ago
There are no absolutes, and most of these “myths” are at least true to some extent. Much like any paradigm (worse is better, whitebox testing, lbyl vs eafp, etc), none are universally best. And all are helpful to know about.
mvirts@lemmy.world 9 months ago
It’s not magic