by Kim_Bruning · 2y ago · 0 comments
I just wrote my code as normal (indented, thank you very much) and could ignore semicolons and curly braces, and the code just ran.
I was done in half the time!
This seems like a regression by people who are bad at indenting their code. ;-)
(see also: https://pypi.org/project/goto-statement/ )
Checking the code on your screen against your internal mental model does take varying amounts of time. It depends on language syntax and how your mind works.
Different programmers internally think in different ways, it turns out.
In my case I found that I tend to look at the indentation primarily, and then I check parentheses and semicolons against the indentation.
(So in my case python lets me skip an entire step.)
But nowadays it's autocompleted anyway.
b) When reformatting code like
for a in x:
f(a)
if something:
g()
you're liable to make a typo and commit a grave logic error. for (let a of x) {
f(a);
if (something) {
g();
}
}
If you're a programmer who looks primarily at indentation for their syntax cues, it's the parens that can lead you into traps.So there's arguments either way.
Now that I'm used to it, I do feel that indentation errors (or at least an indentation/paren mismatch) should probably be a syntax error either way.
Possibly people who argue for belts and suspenders might be on to something?
To me, that was a definitive proof that while people may prefer braces over white space the majority of those same people read code, they are using indentation to guide their mental parse tree - not the braces. One obvious reason for doing that is they may not even be able to see the braces in the editor window.
It also seems obvious that the compliers should parse the same way humans do. It makes life so much simpler when we both see the same thing, so the code the compiler is emitting matches the semantic tree we are building in our heads. Which means if your goal is correct, readable code python got it right, and just about every other language gets it wrong. The article notwithstanding, there is not a lot of wriggle on that point.
Whitespace sensitivity is the top of Python’s pretty exhaustive list of flaws.
I put the cursor over a curly bracket, press CTRL-M, the cursor navigates to the other curly bracket.
My eyes also parse code much faster when it is both indented and with proper brackets.
Python just makes more difficult some common tasks like commenting out a try/catch block without having to reindent all the code inside.
Not a win IMO. In fact, Python presumes it is easier to use, while in reality, it is not.