The only formatting that drives me up the wall is people using K&R braces in C# or Java. It's not 1970 anymore, and we're not all typing on green-screen terminals. It's like people fetishizing vim or emacs over modern IDEs.
The only formatting that drives me up the wall is people using K&R braces in C# or Java. It's not 1970 anymore, and we're not all typing on green-screen terminals. It's like people fetishizing vim or emacs over modern IDEs.
AFAIK there is no rule in K&R requiring no braces for single-line blocks. In that situation, braces are optional.
The K&R style was hugely influential on Java and many other languages, it has nothing to do with green-screen terminals (I used those, as well as white and amber), it is just a style. I also moved on from vi, and use IntelliJ and Sublime most of the time.
The only difference between K&R braces and Java braces is that they combine lines on if-else. The Java guys did it because it enabled them to fit more code on to overhead slides. Overhead slide projectors predate green-screen terminals BTW...
All these are configurable (and not enforced by default but you can definitely do so with .editorconfig).
It is also fairly popular in C# to use expression-bodied members where they have just a single expression/statement e.g.
class Test {
public int Property => 42;
public void Method() => Console.WriteLine(42);
}