this post was submitted on 23 May 2024
261 points (91.4% liked)

Programmer Humor

19623 readers
92 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

...from people who seem to refuse to install paredit or coloring plugins for either? ps lisp syntax ftw, it's a feature!

you are viewing a single comment's thread
view the rest of the comments
[–] sajran@lemmy.ml 17 points 6 months ago (4 children)

So I'm going to say what I always say when people complain about semantic whitespace: Your code should be properly indented anyway. If it's not, it's a bad code.

I'm not saying semantic whitespace is superior to brackets or parentheses. It's clearly not. But it's not terrible either.

As someone who codes in Python pretty much everyday for years, I NEVER see indentation errors. I didn't see them back when I started either. Code without indentation is impossible to read for me anyway so it makes zero difference whether the whitespace has semantic meaning or not. It will be there either way.

[–] technom@programming.dev 11 points 6 months ago* (last edited 6 months ago)

Python decided to use a single convention (semantic whitespace) instead of two separate ones for machine decodeable scoping and manual/visual scoping. That's part of Python's design principle. The program should behave exactly like what people expect it to (without strenuous reasoning exercises).

But some people treat it as the original sin. Not surprised though. I've seen developers and engineers nurture weird irrational hatred towards all sorts of conventions. It's like a phobia.

Similar views about yaml. It may not be the most elegant - it had to be the superset of JSON, after all. But Yaml is a semi-configuration language while JSON is a pure serialization language. Try writing a kubernetes manifest or a compose file in pure JSON without whitespace alignment or comments (which pure JSON doesn't support anyway). Let's see how pleasant you find it.

[–] Crisps@lemmy.world 6 points 6 months ago* (last edited 6 months ago) (1 children)

This leads to weird bugs when you change indentation and miss a line or reorder lines. The logic changes. Not too bad when you’re on your own, as Python seems to be intended for. Add multiple developers and git merges and it is a recipe for disaster. With end tags at least you just end up with poorly formatted working code.

[–] sajran@lemmy.ml 1 points 6 months ago

It's probably more prone to mistakes like that, true. But in practice I really never witnessed this actually being a problem. Especially with tests and review.

[–] eluvatar@programming.dev 5 points 6 months ago (1 children)

The number of times I move code around and can just press a hotkey to fix indentation though. Not possible with Python.

[–] sajran@lemmy.ml 1 points 6 months ago

Yeah, that's definitely a good point. But it's a minor thing. Adjusting indentation takes 2 keystrokes in vim, I barely notice it.

[–] coloredgrayscale@programming.dev 2 points 6 months ago (1 children)

Most IDEs support automatic code formatting, and doing so on save. Or have it as a github hook.

[–] sajran@lemmy.ml 4 points 6 months ago

Of course, but when indentation has a syntactic meaning the formatter often won't be able to fix it.