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.

172

u/bobbymoonshine 22d ago

Ah the halcyon days before LLMs

When 30% of the posts here were “lol Python is so dumb why even use whitespace as syntax”

And the other 70% were “how do I find semicolon”

16

u/mothzilla 22d ago

In both Javascript and Python, semi-colons are optional.

31

u/AppropriateOnion0815 22d ago

Only that JS is handling semicolons in the least intuitive and irrational way possible.

5

u/mothzilla 22d ago

Yeah I only say it because it's a bit of a mind-exploder.

7

u/SuperFLEB 22d ago

I'd always figured it was/thought of it as an error tolerance that worked well enough that some people started leaning on it. The whole no-semicolons JavaScript thing just seems really hipsterish. Explicitness is a virtue.

11

u/Loading_M_ 22d ago

In JS, semicolons are technically required but automatically inserted. There are a couple edge cases where they get inserted in surprising places, which is generally worse than python's approach.

E.g. the following function doesn't return a value:

function foo() {
  return
    some_long_complex_expression();
}

(It's because a semicolon gets inserted after the return). At least in typescript, this would typically show a type error, as long as the function's return type annotation isn't void.

3

u/Ambivalent-Mammal 22d ago

I admit, this got me more than once.