DEV Community


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

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.

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.

ryansmith profile image
Ryan Smith

Popular linters and formatters for JavaScript default to 80 characters:

Thread Thread
alastairdunca13 profile image

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

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#.

erikpischel profile image
Erik Pischel

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

emptyother profile image

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.

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

omrisama profile image
Omri Gabay

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

ghost profile image

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

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.

leob profile image

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.

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.

maixuanhan profile image
Han Mai

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

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.

tarialfaro profile image
Tari R. Alfaro

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

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.

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.