www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: Code style and project status

Re: Code style and project status

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 20 Mar 2019 23:17:26 +0100 (CET)

On Wed, 20 Mar 2019, Will Cosgrove wrote:

> Any chance we can extend the line length over 80 characters? Is there a
> reason to use this antiquated value?

Some call it antiquated. I call it sensible.

Seriously though, I'm open to discussing the rules as I believe consistency is
more valuable than insisting on an exact style. Code style is a lot about
taste and religion.

So what do you say is a suitable max length?

Let me state why I think code should be within 80 columns:

  - To allow many code editor windows next to each other on my screens (I often
    have several)
  - To fit in a "standard" terminal with when using regular command line tools
  - The above include sensible line widths when doing "git blame" and gdb'ing
    from command line
  - To let diff tools like the github diff viewer to sensibly show before
    and after in two columns in a not too crazily wide browser window.
  - For the same reason books and newspapers don't do overly wide lines: code
    gets less readable when very wide.

> It makes using descriptive function & variable names problematic

I actually think it works the other way around. It forces us to stop using
ridiculously long and hard-to-read names and instead encourage us to use
shorter names that are more readable and easier to remember. I do think we
still have far too many very long names in libssh2.

> and also forces a lot of wrapping in if statements which makes them harder
> to parse.

The easy fix for this is: shorter names, fewer indent levels.

But I'm also used to code like this and I think multi-line statements are
easier to read than very wide statements. Again: preference and taste.

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2019-03-20

the libssh2 team