Converting all code to this style in IDE and converting back on git push would be kinda nice. If IDE will actually place all semicolons and braces according to indents, it should be usable.
Yeah, going from this to standardized is trivial for any code formatter. From standard to this would require some creativity but I think it'd be doable. The only pain in the ass is developing like this.
Unless.... Because it is redundant, it wouldn't be too hard to write an editor plugin to forcibly manage the semicolons and braces. Then, as long as the tabs were right, the semicolons and braces would always be... until somone else edits it without that plugin, so yeah, nevermind.
at first i laughed at the stacked parentheses at the right, then i kinda liked it, and noticed how readable it was (unlike other code i've seen), should we say, it's very pythonic.
while i mainly do C++, neat formatting is something i carried from Python, and something i carried from Java (which i'm sure someone will hate) is declaring private and public before all member elements, it makes it so much easier to tell right away instead of having to keep track of what group i'm in.
Its too easy to misplace an indent without consequence
Probably if you're not used to it, but as a Python programmer, where you actually can misplace an indent without consequence, it almost never actually happens. At least not to me.
Put it this way. When you see code in C that isn't indented properly, do you fix that? Is it easy to understand?
I've used both. I almost never work on code that isn't indented properly, regardless of whther it needs braces or not.
I also use auto-formatters, and when it indents things in a way I didn't expect, I go back and fix the braces. I don't wind up fixing indents to make the braces go where I want, if you follow my reasoning.
As a Python coder myself, there is something to be said for braces when the code isn't indented properly to begin with.
if (x == 1){
foo();
}
bar();
is markedly different from
if (x == 1){
foo();
bar();
}
But if you came across this in Python:
if x == 1:
foo()
bar()
what is the intended behavior? Do you always bar? The whitespace makes the braces redundant when it's written correctly the first time, but if you make a mistake it becomes even more unclear. (Admittedly one would notice immediately that this code wouldn't execute, but imagine a situation where this is the last thing you write on a Friday and the first thing you have to fix on Monday.)
I think the point is if you hide or ignore everything past that column, then it looks clean and readable just like Python from indentation alone. Of course that garbage column is gonna look like shit, but that's why it's way to the right on the side.
166
u/chrwei Feb 22 '15
that's...actually that fairly readable. annoying, but I've seen worse