5 ms·
Giving meaning to whitespace causes so many headaches and yet people still embrace Python, for some reason. I don’t understand it.
by booleandilemma 7y ago
Giving meaning to whitespace causes so many headaches and yet people still embrace Python, for some reason. I don’t understand it.
- whatshisface 7y agoYour editor makes a world of difference here. Since you shouldn't be writing brace-language code without indents anyways, the biggest issue remaining is mixing tabs and spaces. Gedit makes this a big pain with it's default config (it doesn't even auto-indent) but Atom and IDLE handle it well.
- kevin_thibedeau 7y agoPython 3 rejects mixed whitespace so the problem will be caught quickly.
- userbinator 7y agoCode you write yourself is not usually the source of problems with significant whitespace; it's situations like posting code on websites and discussing it where code in a whitespace-significant language becomes next-to-useless when leading whitespace is stripped, whereas code in any other language will still survive and then easily be autoformatted without changing its meaning.
- pshc 7y agoCan’t remember the last time this has actually happened to me. In what websites are people posting code without code block formatting support? Like, instant messengers?
- contradictioned 7y agoFunfact, even Facebook, Whatsapp, and Telegram support preformatted text in triple backticks.
- icebraining 7y agoIf I were to use such a shitty website, I'd rather make a pastebin and link to it, instead of forcing every reader to reformat it themselves.
- vgetr 7y agoI’ve heard this argument in a lot of contexts, and it has always struck me as saying, “if hitting yourself with this bat hurts, try wrapping this towel around it and maybe it will hurt less.”
- bobbylarrybobby 7y agoIf I pinky promise to indent my code anyway, then why does it matter whether I also have braces or not? In fact, braces allow me to press one button in my editor and get the indentation absolutely perfect, without affecting semantics. Braces also allow for easily copying and pasting blocks of code because the braces delimit the semantics of the copied text. Because your code is already indented, with white space indentation you have to check that a) you pasted the first line at the right indentation level b) every subsequent line is also at the right level relative to the first line. No small feat.
- otabdeveloper4 7y ago> If I pinky promise to indent my code anyway, then why does it matter whether I also have braces or not? Without braces copy-pasting becomes a context-sensitive headache. That's poor usability.
- codetrotter 7y agoAdmittedly I’ve been writing code in Python for many years now but, even from the start I never had a problem with the significance of whitespace. Quite the opposite. I like to format my code nicely anyways (or rather, mostly my editor does it for me because I’ve asked it to do so). I indent with two spaces usually, regardless of language. And have my editors configured to insert two spaces when I press tab. JavaScript, Rust, Python, C. Same difference, in terms of how I use whitespace.
- ben509 7y agoThe main headaches are due to people either wanting to copy and paste code from various sites, or wanting to write really deeply nested code. If you're writing well structured, original code in Python, it's generally cleaner and easier than other languages because the syntax avoids ambiguities that other languages have.
- DangitBobby 7y agoThe difference in my experience is that once you know what's wrong with your whitespaces in Python, you're out of the woods. The interpreter is your friend from that point onward. YAML parsers, on the other hand, give you these really strange errors that are pretty difficult to understand, and it doesn't end with whitespaces.
- h1d 7y agoThere are quite a few comments saying they don't like python even from 10+ year users. Language becomes popular largely through library ecosystem and resources around it, not just how the language looks. I think Google embracing it had a good role in acquiring mind shares. https://news.ycombinator.com/item?id=20672051 https://news.ycombinator.com/item?id=20672051