Max source line length

Is there a recommended max line length for source code in Julia? I know it is up to personal preference to a large extent, but I am wondering if there is a reasonable default.

The page on documentation recommends 92, but that’s for docstrings.

JuliaPraxis/Spacing does not give a specific number, just recommends

Prefer to split a long line after =, , ||, &&. or (.

This page by John Myles White recommends 80.

CONTRIBUTING.md recommends 92.

Running the following snippet

## count line lengths
dir = "$JULIA_HOME/$(Base.DATAROOTDIR)/julia/base"
dict = Dict{Int,Int}()
for (root, _, files) = walkdir(dir)
    for file in files
        filename = joinpath(root, file)
        _, ext = splitext(filename)
        if ext == ".jl"
            for line in readlines(filename)
                len = length(line)
                dict[len] = get(dict, len, 0) + 1
            end
        end
    end
end
sort(collect(filter((l, _) -> 80 ≤ l ≤ 120, dict)), by = first)

suggests that 92 is not that strictly adhered to: after 92, the frequency drops to about 2/3, something like

 88=>473 
 89=>541 
 90=>494 
 91=>450 
 92=>416 
 93=>274 
 94=>241 
 95=>240 
 96=>231 
 97=>185 
 98=>186 
 99=>148 
 100=>188

Since CONTRIBUTION says 92 I would go with that. However, until there is a well made julia source code formatter, things like line length will always be a best effort endeavor.

Some further stats on line length distributions (just for fun, (lower,upper)=>percentage)):

# Base
 (0, 19)=>40.6  
 (20, 39)=>24.9 
 (40, 59)=>15.0 
 (60, 79)=>11.4 
 (80, 99)=>5.9  
 (100, 119)=>1.4
# packages on my system
 (0, 19)=>38.2  
 (20, 39)=>28.7 
 (40, 59)=>16.1 
 (60, 79)=>10.1 
 (80, 99)=>4.6  
 (100, 119)=>1.2
# base > 80
 (80, 89)=>46.2  
 (90, 99)=>25.8  
 (100, 109)=>11.4
 (110, 119)=>6.4 
 (120, 129)=>3.6 
 (130, 139)=>2.4 
 (140, 149)=>1.5 
# packages > 80
 (80, 89)=>47.4  
 (90, 99)=>18.1  
 (100, 109)=>10.9
 (110, 119)=>6.6 
 (120, 129)=>4.3 
 (130, 139)=>2.5 
 (140, 149)=>2.2 
 (150, 159)=>1.5 
 (160, 169)=>1.3 

Only frequencies above 1% are shown, so the above don’t sum to 100%. As expected, packages have more outliers.

I think that trying to break up lines above 80 chars, at most 92, is a reasonable style guide. Readability will be heavily affected by 160 character monster expressions.

btw: a side question: is there something in (any)/a style gide how to split/format expressions that are one line, but needs to be within the 92 limit? (btw2: as old-school terminal user (80x72) i’d actually see 80 as the defining limit).

See JuliaPraxis/Spacing/Splitting lines, which I linked above.

yes, i wasn’t clear enough: Is there something else than at this link? It’s stating the obvious but leaves away how deep to indent.