I strongly prefer braces. But I also increasingly languages with a standard style and formatter. Go and Rust both do this well.
I strongly prefer braces. But I also increasingly languages with a standard style and formatter. Go and Rust both do this well.
// just copied some code into this while block, oops I copied an extra space out front...
while (...) {
if (...) {
...}
}
// after Ctrl+S tied to autoformat
while (...) {
if (...) {
...
}
}I love Python's indentation based blocks (in Python) but this is the biggest issue I've had with it. That and maybe occasionally when word wrapping.
I think Python's general terseness mitigates most of the reasons I might miss blocks in C or Java.
Making copy/paste bugs too hard discourages copy/pasting code rather than reading and rewriting, so, mixed bag there, IMO.
That was my experience in Python.
-> These statements need to be in this other loop.
-> Cut...paste
-> Reindent
-> Turn my brain to extreme paranoia, and double-check that I properly indented the first and last lines of the code I moved.
In braces-languages, it was just cut..paste..autoformat. If you missed a brace, you hear about it from the compiler.
Python is a great language in a lot of ways, but I caught myself making indentation mistakes twice a week. Significant indentation is, in my opinion, an error in language design.
Personally I've been way more annoyed when I've typed something up in the REPL and can't paste that over directly because of the >>> and ... but that's really a small tooling issue; a smarter editor would remove the REPL marks when pasting. Same for other REPL languages, most of them have PSn...
if other < mine:
update_comments(other, mine)
write_billing(other)
and then I paste it, but get the indentation wrong on the last line, and it falls outside of the if block. Maybe my brainbox needs an upgrade.And yeah, pasting code into a repl would be easier too if I could rely on braces to convey scope.
for line in lines_to_paste:
paste(current_indent .. line)