Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: default code width formatting at 120?
4 points by ddalex on Jan 10, 2014 | hide | past | favorite | 5 comments
It's been for several years now that we have high resolution monitors, and 4K (for programmers!) is upon us. I think it's time to part with ancient 80-character default width for source code.

On my 1920px width monitor I code comfortably at 100-characters width in two editors side-by-side, although the font is a bit small at 10. On a 3840x2160, I expect to turn the monitor in portrait mode (it's gonna be too wide for web browsing at 3840, 1920px already breaking lots of sites!) and squeeze two code windows side-by-side with at least 120 characters usable width. This is a 50% increase over the standard 80-column width for editors !

Moving to 120 characters code width seems to have a lot of advantages; we can use longer variable names, we have space for longer expressions, e.g. lambda functions or generators; and the commit messages (I look at you, git) and comments will not be awkwardly split in a quarter of the screen.

Question is: how do we start moving everybody to use 120-characters default width for their code ?



Shorter lines are easier to read. Long uneven lines are hard to read. This is why all newspapers use multi-column pages with advanced layout algorithms to make the lines as even as possible.

I also don't think being able to fit a "lot of action" on each line is an advantage at all because code like that is hard to follow, debug and refactor. If you instead split it up over multiple lines it becomes easy to see what the common parts are and refactor them into new functions.

There is also a lot of people with poor eyesight who uses large fonts and would have to horizontal scroll (big pita) 120 char wide lines.


I've never watched for this, or even known there where 'limits'. I just make sure my lines aren't too long.

Is it common for IDEs or editors to set line width limits? Does the character limit include tabs (I assume it does)?


Please, do not stick to a number. Use your common sense.

You can use this simple question:

1. In which way is this chunk of code easier to read, one liner or split?

That is it.


Everybody? Just move your own stuff. Others will follow. Our code has been at a _soft_ limit of 120 for 5 years or so now.


I already moved mine on 120. But common expectations of 80 are there for a reason.

How do we change the reasoning ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: