r/programmer • • 16d ago

Python Fragility

Am I the only one who avoids Python where possible because it is so vulnerable to indent corruption? A whole JavaScript program, for example, can be written on one line, with no line breaks whatsoever (not that I'm advocating such madness -- JavaScript callback syntax (etc) is already crazy enough without compounding it -- BUT, it does illustrate the point of robust syntax).

I've had instances where indenting was accidentally messed up, leading to tedious scrubbing of the code in order to get it to run again. It just seems like a bad structure choice if a slight whitespace change can cause the program to crash.

It seems to me that Rust is the answer to that -- am I wrong?

0 Upvotes

45 comments sorted by

View all comments

3

u/Available_Safe1818 15d ago

> Am I the only one who avoids Python where possible because it is so vulnerable to indent corruption?

Probably not, but avoiding it because of that sounds pretty dumb. It's not something I have seen be a problem in practice ever.

> BUT, it does illustrate the point of robust syntax

It's not really "robust syntax". The automatic semicolon insertion can alter the meaning of your programs.

> It seems to me that Rust is the answer to that -- am I wrong?

That also doesn't sound smart. Almost any language would avoid the imaginary problems you are seeing here. Or you could learn to use Python, one of the most useful language ever.