DEV Community

loading...

Discussion on: What programming best practice do you disagree with?

Collapse
ryansmith profile image
Ryan Smith • Edited

80 characters per line is a common one. I feel that this is an old practice from technical limitations that lived on. I do not go overboard with extremely long lines of code, but with widescreen monitors, 80 characters seems a bit limiting.

Collapse
marble_shark profile image
Marble Shark

Erm, nobody insists on that anymore so no, not common at all - it's long been revised to 120.

Collapse
ryansmith profile image
Ryan Smith

Popular linters and formatters for JavaScript default to 80 characters:

eslint.org/docs/rules/max-len
prettier.io/docs/en/options.html#p...

Thread Thread
alastairdunca13 profile image
FineYoungDebaser

Like everything else about JavaScript, This limit is regressive at best.

Collapse
marissab profile image
Marissa B

If I remember correctly that stemmed from the COBOL era where a punch card only had a certain number of characters across plus a blank column (the fourth I think?) for the sorting wheel to put cards in order.

I don't think I've ever adhered to a certain number of characters in C#.

Collapse
erikpischel profile image
Erik Pischel

Plus, in the 80s graphic cards the standard text mode was 80 columns X 24 lines.

Collapse
emptyother profile image
emptyother

I think 80 is just for encouraging good practices. Some people tend to ignore soft recommendations like "don't go overboard", but will follow hard limits.

Collapse
epse profile image
Stef Pletinck

I appreciate code that has an 80 char limit, means I can put two code panes next to each other without having to put the font eyebleedingly small

Collapse
omrisama profile image
Omri Gabay

My coworkers use huddled terminals in an i3 workspace and with Vim, they appreciate having 80 characters per line.

Collapse
ghost profile image
Ghost

same here, 80 chars are visible in 3 columns at 1080p; and also 1 vim column + browser without triggering the "small screen websites format". By the way, i3 + nVim is perfect

Collapse
cjbrooks12 profile image
Casey Brooks

I prefer 120 characters, and stay pretty strict on that limit. 80 chars definitely is not enough, but I do like having a hard limit on line length.

Collapse
leob profile image
leob

80 characters per line is horribly outdated, it would make most of my code look ugly especially in a more verbose language like PHP.

120 characters per line is fine, that's much more okay.

Collapse
paul_melero profile image
Paul Melero

It has another use case: showing code on a presentation (you need to increase the base font size) keeps your code formatted and in the screen.

Collapse
maixuanhan profile image
Han Mai

Yeah, multiple screens are common nowadays. Super long line is not encouraged. For easy reading I prefer 120~130.

Collapse
gsto profile image
Glenn Stovall

It's not just a technical issue. longer lines are harder for the human mind to parse out. In text, 50-60 characters are ideal. I think more than 80 in code is pushing it. Having said that, I agree that it's not something to be too dogmatic over. We have our linter set to 125 cpl.

Collapse
tarialfaro profile image
Tari R. Alfaro

I'm pretty fond of 80 characters being the limit.

Collapse
ryansmith profile image
Ryan Smith

I have heard of the 50-60 being ideal, but I thought that was more for reading sentences than text in general. I could be wrong though, I haven't looked at the studies on it.

Collapse
apihlaja profile image
Antti Pihlaja • Edited

Over 80 characters per line means project is written in some ancient language. For example Java.. or other older strongly typed language where it's occasionally impossible to make code nice & readable 😅

That, or there is some bigger issues in code structure.