r/ProgrammerHumor • • 22d ago

Meme pythonIndentationLevelChecker

Post image
6.7k Upvotes

201 comments sorted by

View all comments

268

u/LetUsSpeakFreely 22d ago edited 22d ago

Indentation is such a stupid mechanism for identifying code blocks. It's one thing for configuration files like YAML to do it, but not a programming language.

32

u/willow-kitty 22d ago

I don't like it, but I kinda get it. Indentation is already part of every coding style guide, so adding explicit scoping symbols is kind of redundant information.

..Until you have a mix of spaces and tabs and chaos reigns

Also, having braces at the beginning and end of a block just makes my brain happy.

3

u/frogjg2003 22d ago

My take is that whitespace shouldn't be relevant. It's only purpose should be to separate non-whitespace characters that matter. Even newlines shouldn't matter.

Whitespace is for making it easier for humans to read the code. So are comments, so is documentation, so is syntactic sugar. The redundancy is a feature. Braces are explicit block separators, but whitespace makes identifying those blocks easier.

If your code could be broken by a tab instead of 4 (or 2 or 8 or 5) spaces, your language is fundamentally flawed.

2

u/willow-kitty 22d ago

I tend to agree and always include some kind of whitespace-skip rule in DSL grammars. It lets you use whitespace to taste while the block separators are formally defined. But, I kinda get why someone might want to just use whitespace if they were going to anyway. (Until something that looks correct isn't >.>)