Doe anyone know why JuliaFormatter uses a 92 character max line length?

It seems like such a random number, but I was just curious if there was any particular reason for using this many characters?

https://domluna.github.io/JuliaFormatter.jl/stable/#JuliaFormatter.jl-1

I believe it’s more or less random.

The Blue style guide https://github.com/invenia/BlueStyle suggests a line width of 92 and many people just used that because it was of the first ones and is also quite reasonable.

I don’t think there is a specific reason for 92, the motivation is just that it’s a bit wider than the standard limit of 80, which is often perceived as too narrow (the limit of 80 however has historical reasons and goes back to hardware TTY limitations, which I think is rooted in some punchcard format).

6 Likes

Personally, I’m glad that it’s 92 characters. 93 would have been far too many.

10 Likes

80 columns was the size of an IBM punched card. I used them a lot at one time.

IIRC Univac had an alternate punched card format with 96 columns.

4 Likes

92 is a nice number. I often use 100, but it’s actually a bit wide. 80 is way too narrow, and pointless with modern displays.

1 Like

I guess the number 92 comes from Julia formatting guidelines: https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#general-formatting-guidelines-for-julia-code-contributions.

6 Likes

The question has been asked before:

https://github.com/JuliaLang/julia/pull/9848

So it’s getting on to be a FAQ, like “where does the name Julia come from?”

1 Like

I did a poll on this 2 years ago:

and 92 was the most common choice.

I don’t think this value comes from any deep principles, it is just kind of a sweet spot for most people in the sense that longer lines usually signal a problem with the code.

In particular:

  1. indentation with 16–20+ spaces: consider moving code to local or global functions
  2. very long argument lists: group them to (immutable) structs or similar
  3. closures taking up a lot of the line length: use do, or a local named function
  4. if all else fails: just break that line somewhere
7 Likes