5 ms·
I always was strictly against whitespace in Python because it can lead to all kinds of weird errors. But Nim (and also Haskell) has static types so most wrong i
by progman 11y ago
I always was strictly against whitespace in Python because it can lead to all kinds of weird errors. But Nim (and also Haskell) has static types so most wrong indentations are caught by the compiler. That's really nice to have.
- nickbauman 11y agoI've been a Python dev since 2008 and I can count on one finger where this has actually been an issue. I'd love have you enumerate the "all kinds of weird errors" for me. Not saying you're wrong, mind you, just want to understand.
- muaddirac 11y agoI have to agree - the only whitespace-related errors I've ever come across are "IndentationErrors" - which are pretty easy to resolve.
- mercurial 11y agoI remember a bug caused by that, due to a merge, where an instruction went out of an if block.
- andybak 11y agoI wonder if it was an automatic merge or whether someone just didn't eyeball the code properly?
- iopq 11y agoThat's scary... this is why I'm unhappy with merge tools that don't understand the underlying language
- nickbauman 11y agoOk this sounds legit. Thank you. But if you think about this carefully it means that two people wrote the exact same expression in different scopes, which seems really, really odd, no? I'm trying to contrive this in my mind and I'm having difficulty (my fault, obvs). If this happens again it deserves its own blog post describing the situation carefully!
- mixmastamyk 11y agoSince 2000, there were a few times in that first afternoon while doing the tutorial... March 2000? I think, but then I configured my editor to use spaces and subtly show tabs. That was the last time, yeah. People that complain about whitespace haven't used Python much, it's a dead giveaway. And yet, the benefits are enormous, I've probably skipped typing a hundred thousand redundant braces since then, and ended up with more readable code.
- esrauch 11y agoTabs are considered the same as 8 spaces, so if you ever have a single moment of lax enforcement of "only tabs" or "only spaces" you can get bizarre results.
- Demiurge 11y agoJumping on this wagon. Have been using and teaching Python for more than 10 years and have never seen any weirdness. Python actually warns when there are mixed tabs in blocks.
- Nadya 11y agoI've always felt the argument against whitespace due to "indenting 2 spaces instead of 4 spaces" or something silly is like trying to argue "Braces are bad because you might forget to close a brace!" IDE's handle both scenarios. My IDE largely remembers how far in I should be indented and if I use a brace it closes it for me. If I program in a plain text-editor like Notepad - I still don't mess up my indenting any more than I forget to close a brace or parenthesis. It's a silly argument formed from speculation and "but its possible!" rather than reality.
- andrewstuart 11y ago>> it can lead to all kinds of weird errors Quite the opposite. Whitespace for me is a godsend - all code is formatted the same way and I rarely if ever have to deal with whitespace related errors. In fact I don't even know what whitespace related errors are - you'd have to explain what you mean. On the other hand, when programming in JavaScript I seem to spend all my time trying to work out issues related to brackets and code structure - very very annoying and silly - can't computers work brackets out, do we need to tell them what the code structure is?