Javin Paul

I am Java programmer, blogger on http://javarevisited.blogspot.com and http://java67.com

Does Column Width of 80 Make Sense in 2019?

One of the oldest coding practice is to keep line width 80, and many of us follow it blindly but have you ever thought why we have this practice in the first place?
I believe it was to make your code more readable in the age of small
monitors so that whole content can fit in the screen, or it might have
originated from the age of punch card, which was used to be 80 columns
wide.
This sounds reasonable when we think about those old days but do you think this rule makes sense in 2019?
We are now living in the age where most of the developers have got large monitors, which can show up to 180 characters, doesn’t this is wastage of precious monitor space? It also makes your code unnecessary long, then it actually is.
I first come to know about line wrapping at 80, while reading Oracle Code Conventions for the Java Programming Language, which was last revised at April 20, 1999, which under indentation says
4.1 Line Length
Avoid lines longer than 80 characters, since they’re not handled well by many terminals and tools.
Note: Examples for use in documentation should have a shorter line length-generally no more than 70 characters.
If I understood correctly (I may be wrong), one goal of this rule is consistency.I used to think that 80 was silly, but being able to go through source code written by a dozen different teams over last 7 years and not
needing to re-size my window is a really nice thing. Consistent column
width helps with the pace of reading code.
Since I mostly worked with large monitors, like LG 32MP58HQ-P 32-Inch IPS Monitor with Screen Split, I also realize that we are wasting lots of precious
space. The consistent column width of 80 is simply too little.
I personally use 120 unless the project I work already finalized a column width, in that case, I go for consistency.
One more reason people give for still using a column with of 80 is that
nowadays they are working with multiple files at once, mostly in VIM or in their IDEs like Eclipse or IntelliJ IDEA.
For example, if you use standard column width you can fit a couple of files
across a reason and can compare them line by line, which I believe is a
real benefit.
You can even do a three-way merge inspection on one screen without
scrolling sideways. By the way, this should not be done at the cost of
excessive wrapping.
I understand that consistent columns make it easier to scan and read through text but it doesn’t matter whether it’s 80 or 120.
On a closing note, I would say that consistency is nice and you must go for it but 80 or even 100 is too short.
Many developers could probably live with 120 or even 150 though. Our modern widescreen high definition LCD monitors can easily handle more.
It is more readable than the excessive wrapping because I personally
find it much harder to read a wrapped line than just seeing the whole
thing in one line. Of course, this is just preference and others will
feel different.
So, what do you guys think, does this rule still hold or you have already moved on?
Other Programming Articles you may like
Thanks for reading this article so far till the end. If you like this article then please consider following me on medium (javinpaul). if you’d like to be notified for every new post and don’t forget to follow javarevisited on Twitter!

Tags

Comments

August 5th, 2019

How wide is your article on Hackernoon? Around 80 characters on my screen. 65 if I turn it into fixed-width characters. Microsoft’s documentation code samples shows only 110 characters(*). Github’s code view is around 130 characters wide before showing a scrollbar. Anyway, the point is that code doesn’t only live in the editor. You will paste it into articles and tutorials. And would be a shame if a bug got into production because a code reviewer hadn’t bothered to vertical scroll a bit. 80 characters is a good guideline, I think. I try my best to never post an inline comment nor start a new code statement when I have passed the 80th column.

(*) If it wasnt for me being annoyed at having to scroll vertically back and forth to read their tutorial code earlier today, I probably wouldn’t have made an account on Hackernoon just to reply to your article. :smirk:

More by Javin Paul

Java
Java
Java
Java
Javascript
Online Courses
Scala
Linux
Online Courses
Software Development
Software Development
Programming
Tech
Programming
Programming
Big Data Courses
Learn Programming
Web Development
Data Science
Programming
Coding
Learn Python
Certification
Programming
Java
Programming
Java
Programming
Coding
Technology
Java
Programming
Kotlin
Programming
Programming
Web Development
Programming
Programming
Java
Data Science
Web Development
Android App Development
Java
Java
String Coding Questions
Programming
Programming
Programming
Java
Software Development
Programming
Web Development
Programming
Software Development
Coding
Online Courses
Sql Courses Online
Sql
Microservices
Programming
Java
Web Developer Roadmap
Software Development
Graphql
React
Programming
Big Data
Programming
Topics of interest