Hacker News new | ask | show | jobs
by pswenson 2555 days ago
80 char line length in 2019?
4 comments

I know, on the surface it seems silly, but there are a couple of reasons I've found 80 chars makes things easier in real world workflows in 2019:

* Split panes in editors. With 80 chars, you can usually have two panes on screen along with a file tree, on most laptop screens. This is pretty nice to have.

* Code reviews in a web interface like Github/Gitlab - 80 chars means usually there's no need to pan, even when your browser window isn't full screen

Enforcing 80 chars on everyone for those reasons doesn't feel justifying.

It will definitely make people use weird variable names instead of meaningful ones.

  is_included = true
could turn into,

  inc = true #included or increment?
That's a far worse side effect than other points raised in this thread.
Even worse, abbreviations are terrible as there is one way to write a word correctly, and lots of ways to abbreviate it, so now you have to keep track of that too.

Was it inc? incl? incld? includ? in? incldd?

Now you have to break flow to go check. There's many ways it could be written and a chance for bugs to be introduced if you accidentally pick the wrong style. And when you read it, does the inc mean incorporated? included? includes? including? incapable? incestual?

That's a fair point, though I'll say in my experience, it's not been the case. If it were, I wouldn't do it as I agree with you that it outweighs the benefits I mentioned.
There are many good reasons for that IMO:

* Too long lines are hard to read. For text 11 words per line are recommended, otherwise your eyes will loose track. 11 Words is roughly 60 characters, but code is indented so you need a bit more.

* Some people look at your code in an 80-column terminal, if you use more, this would be rude.

* Some people use a GUI diff tool that displays the code side by side, so that's already 160 characters.

- Breaking lines at only 80 chars would make it read horrible by splitting lines in the middle of syntactic contexts.

- Unless that's your team's preference, you're not helping anyone.

- Same as above.

Python's PEP8 recommends 79 characters.
slightly worse :)
This one is genuinely awful. It makes me take style guides less seriously on the whole.