5 ms·
The benefit of significant whitespace is that you can't write code like this: int foo() { a(); b(); c(); if (test()) doSomethin
by sullyj3 7y ago
The benefit of significant whitespace is that you can't write code like this:
int foo() {
a();
b();
c();
if (test())
doSomethingIfTest();
doSomethingUnconditionally();}
- _bxg1 7y agoMost modern editors will actively make it difficult to do this, and some even do format-on-save to fix it across the board.
- viklove 7y agodef foo(): a() b() c() if test(): doSomethingIfTest() doSomethingUnconditionally() You can still write this, which is equally garbage because a, b, and c mean nothing to me. I know you're just showing a code example, but my point is that unprofessional idiots will always write shit code, the language won't protect them from themselves. Your issue can be fixed with a linter, mine can't. Look at this python code: https://github.com/django/django/blob/master/django/core/mail/message.py#L193 https://github.com/django/django/blob/master/django/core/mai... In my opinion, it's rather difficult to tell where one if/else block ends, and the next begins. At a glance, I couldn't even tell you how many if/else statements there are. In my opinion, braces give me a frame of reference for my eyes to lock into, even in my periphery, and give me a far better understanding of the code structure.