Live data from Hacker News

Is the 80 character line limit still relevant? (2008)

richarddingwall.name

101–110 of 180 posts

Re: Is the 80 character line limit still relevant? (2008)

#101

80 characters is way, way too short. I think 120 is a decent spot for today's displays, although I don't mind even longer than that either.

No it's not, it's perfect. You want to be able to do side-by-side diffs on your laptop using a normal sized (not tiny) font. You want to be able to paste snippets into design documents and emails and blogs without accidental wrapping or truncating or scrolling. 80 is nicely legible. It works really well.

On my laptop, with a normal font (12-14pt) I can have a side bu side diff of 100 char wide text just fine.

Re: Is the 80 character line limit still relevant? (2008)

#102

Earlier quoted context omitted.

IMO 120 is the extreme limit but a good limit. Anything higher than 120 is to long and, personally, I'd ask for that to be fixed in a code review.

I just bought an ultrawide, and I just checked to see how wide my lines are in my code editor. 350 characters. When I'm coding for myself, I use all of that at times. I love that there are some things I no longer have to break onto multiple lines any longer. Also, if you have a ton of nested loops etc, then you don't end up with that problem where you can only see the first few characters of the deepest lines.

I suspect nested loops going that deep are very likely to be a design problem.

Re: Is the 80 character line limit still relevant? (2008)

#105
I don’t care how ultra your wide is, reading anything horizontally is painful and unwieldy. It’s biological, your eyes can’t track horizontally without row guidance, and even then it’s not hard to get lost.

I have one rule: code flows vertically. I like reading books. Code should read as easily as a book. I have found that if you constrain your code to being shaped like a book, almost everything else follows naturally.

You can’t be indented 7 levels into hell if your code has a reasonable line limit. You can’t jam arbitrary numbers of statements onto a single line. You have to decompose your control flow at reasonable function breaks. Lines are a better primitive for editing and debugging. Etc. etc. etc.

Re: Is the 80 character line limit still relevant? (2008)

#106
post #13

65-80 for readability however once you introduce indentation this naturally increases. I always felt that shorter lines were a good way to encourage less nested code. Alas after all these years the consensus is against me.

agree. i think google python formatter kept lines at 65, i was surprised but it made you keep things concise & ended up much more skimmable.

Re: Is the 80 character line limit still relevant? (2008)

#107
One thing I find sad is that of the 4 IDEs that I work with, most of which have an option to break done long line into several multiple line equivalents, none allow to do a word wrap smarter than that of notepad. They already implemented the refactoring tool, using it in rendering would probably not be a far fetch. That would allow us to get past handling line breaks manually and the invariant discussions and review comments on how best to line up function parameters and comments in 2024.

Re: Is the 80 character line limit still relevant? (2008)

#108

Sticking with 80 characters has been great for my team. Not only does it encourage shorter lines, but comparing diffs on GitHub ensures that both old and new comparisons fit evenly on the page without any cutoffs or wrapping

What kind of monitors does your team use?

I view diffs side-by-side all the time with much wider lines than 80 chars, but I have 27" monitors, which are not unusual these days.

Re: Is the 80 character line limit still relevant? (2008)

#110
post #66

Earlier quoted context omitted.

IMO 120 is the extreme limit but a good limit. Anything higher than 120 is to long and, personally, I'd ask for that to be fixed in a code review.

120 is way too small. IMO 180 is a good limit. We're not on 800x600 screens anymore

Over 120 and most likely something is wrong with the code. That many levels of indentation usually means that code's cyclomatic complexity is off the charts and is in desperate need of refactoring. It could indicate bad naming practices (to long) which also should trigger refactoring. This is all to say it is more about what long lines say about the code than anything to do with the display.

Some languages are just naturally worse at this (eg. Java), so there is always some flexibility. But for most languages that don't have multiple levels of indentation by default and the custom of overly long names, 120 is more than enough to be a good guidepost.

Post reply on HN