1. 47
    1. 7

      I wonder, what is the historical reason for this style not being default? I’ve witnessed two transitions from “continuation indent” (A) to “single indent, ) goes to the new line” (B).

      Kotlin code was originally written with A, because code in IntelliJ was written with A, but then they switched to B for the official style. rustc originally used A because ???, and then, with the introduction of rustfmt, it was switched to B.

      B also seems much easier to maintain without tooling, as you don’t have to manually align parameters. Why is it that people seem to prefer A by default?

      1. 3

        (A) is sometimes an initial choice because a language does not initially support trailing commas. Without trailing commas, you lose the benefit of reducing line-diffs by putting the closing paren on the next line. However, once the language picks up more traction, the complexity involved in adding support for trailing commas might be outweighed by their convenience (for formatting, code generation, etc.). If support for trailing commas does get added, the line-diff argument becomes a pretty strong argument for (B).

        I think this might even have been the case for Kotlin, which I don’t think had trailing commas in its initial release, although I can’t tell if that was because Java didn’t support trailing commas, or because the preferred style was (A).

      2. 2

        I wasn’t there when this history was being made but I’ve heard the following from the veterans of those early days:

        • it looks “wrong” for some Pythonistas to return to the original indentation level before the entire block starting with, say, an if statement is complete;
        • early editor support like Emacs didn’t properly indent Python code based on the colon but instead on the first non-whitespace token in the line. So it would indent a line that started with if but it wouldn’t care about whether there’s a colon at the end. This makes the sadface indent style clumsy to use in such editors;
        • it’s subjectively “ugly” because the bare combination of a closing paren with a colon looks alien.
    2. 6

      I love this explanation. Succinct and without trying to rationalize any subjective preferences for “beauty”.

    3. 3

      This is my preferred style in ruby as well.