4 ms·
What is so wrong about properly indenting your code that you feel it's necessary to add {} to make it better?
by aspyct 3y ago
What is so wrong about properly indenting your code that you feel it's necessary to add {} to make it better?
- happymellon 3y agoYou could always ask Apple. Braces are explicit, whitespace implicit. https://embeddedgurus.com/barr-code/2014/03/apples-gotofail-ssl-security-bug-was-easily-preventable/ https://embeddedgurus.com/barr-code/2014/03/apples-gotofail-...
- arunix 3y agoAnd of course, "Explicit is better than implicit" https://en.wikipedia.org/wiki/Zen_of_Python#Principles https://en.wikipedia.org/wiki/Zen_of_Python#Principles
- JohnKemeny 3y agoIn Python, whitespace is explicit, so actually, the bug you just posted hadn't happened if they used Python. Indeed, in your link, the braces are implicit too.
- gkbrk 3y agoBeing able to copy-paste code with every editor and not ending up with broken code is a real time saver.
- lozenge 3y agoOnly if the use of a stupid editor is saving you time.
- spirit557 3y agoSo if this became popular you'd have some camps using it and some not. Wouldn't that be ironicly more annoying than the problem it's solving?
- bsza 3y agoNo, since the conversion is trivial in both directions and a plugin could do it automatically.
- andybak 3y agoWhy have I never had a problem copy/pasting Python? What are y'all doing??
- cjfd 3y agoThere is nothing wrong with properly indenting code. The lack of {} makes python very ugly when things no longer fit on one line. Because Python has an opinion about whitespace there are certain ways one can break a line an other ways one cannot. The result looks very ugly. Maybe the old way of using a backslash was not the worst, but linters nowadays don't like that anymore. Also having : also does not make things look better. Python must be one of the most ugly looking languages out there.
- giancarlostoro 3y ago> when things no longer fit on one line That sounds like a PEP-8 violation ;) All your lines should be under 79 characters. Might look ugly to some but to others it looks fine.
- housecarpenter 3y agoYou might be already aware of this, but besides using the backslash, the other way you can allow an expression to span multiple lines in Python is to enclose it in brackets. I find this to be pretty unobtrusive. Often your line break will already be within a pair of brackets anyway.
- xigoi 3y agoBlack can usually reformat code pretty well.
- Netcob 3y agoI don't get it either. I mostly use C#, but I somehow manage to properly indent it anyway. Whenever I use python, I don't have any issues with indentation. To me this discussion always sounds a bit like people complaining they can't find any brown underwear.
- datavirtue 3y agoThe "properly" part.
- bernds74 3y agoProperly indenting code is fine. Now try modifying that code, like removing an if statement inside somewhat nested code and trying to ensure that everything still has the same meaning as before. With Python, you can never be sure you did it right.
- rlpb 3y agoI don't see why not. Simple visual inspection confirms if it does what you expect, unlike languages that use braces.
- qgin 3y agoBecause everyone (and all their editors) on every project have to handle indentation identically or as soon as someone makes an edit, things won't run.
- throwawa14223 3y agoFor my ability to read and assess source code significant white space kills me.