Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided i...
For further actions, you may consider blocking this person and/or reporting abuse
TIL: That people have missed the real point of limiting line length to 80 characters.
The real point is that more than 80 characters makes lines appear very long and are much harder to read. Code that sticks to less than 80 characters is much easier to skip though.
PS: If you feel like you are wasting your monitor space then rotate it:
Heck yes, anyone who hasn’t tried out a vertical monitor should do so
I wish I could get used to a vertical monitor, mine has a strange shadow. I think it's a reflection or something. It drives me batty.
How would you do dual monitors on a mac mini?
I agree that most screens today can handle 120 or even more with ease, but I still use 80 characters since it makes it really easy to open two tabs (or more) in the same screen, something I find myself doing quite often.
Personally I completely disable forced wrapping and allow myself some long lines.
Scrolling horizontally on a Mac is a piece of cake and as natural as scrolling vertically.
I also feel it makes it much easier to scan the code.
Obviously this is a very personal preference and it should be a team decision as to what rules to abide by that suit everyone.
Are you sure it makes it easier to scan your code? We're not built to parse nested structures like AST's horizontally, especially when we can't look at it all at the same time. I think it helps to break lines at operators of lower precedence when it comes to readability.
Hi Nayeem!
I don’t mean i don’t break nested structures. I mean I don’t want to be pinned to a set length. Some lines make sense at 85 or 90 or whatever if it’s clear.
For example, I think blank lines are much more important at creating “separations” than imposing a strict line length.
And thorough indentation too.
Thanks for your reply.
Having two code windows side by side is awesome. Same thing goes for editor + browser, whether it's documentation or our js application we are working on.
Above that, IDE can be opened on a display with pivot set for portrait mode. Longer lines won't fit :)
There is one more reason for enforcement of colum width. It's to reduce the nesting levels. HTML with twelve or more nesting levels is well known to all those people who use html4 with tables. It's just difficult to find yourself in it, and yet I still see people doing 3 or 4 levels of nested loops, even more of nested anonymous functions.
In traditional books the line length varies, but hovers around 60-75 characters per line. I like the way 80 characters makes it feel like i'm reading a book. That's my main reason for doing the column width of 80 thing.
I like 120 per line. Most lines fall around or under 80 characters, but in the event that some need to be a little longer it does not feel limiting.
I also do not open multiple code windows at once because it seems counterproductive to have a split focus. I work with one file at a time with keyboard shortcuts to navigate through them.
I don't have much opinion on this since I'm a newbie.
However, because of GitHub, I'm forced to make it suit to 80, and It was a good practice to avoid unreadable code in my case.
I feel like I'm too good at obeying.
In my team we have ditched the hard line length rule and activated soft wrapping in editors. Mainly for two reasons:
And if, for some reason, we should enforce a hard line length then we would add the rule to our linter and the code would be automatically formatted to the width.
One reason to have a smaller column count is for code review/compare. I find it much more pleasant when you can just read without horizontal scrolling.
Some say it's to force us from having too many indentation layers and encourage refactoring when appropriate.
True that! If you constantly find yourself writing lines longer than 80 characters then you should probably rethink what you're doing. I bet your code is a mess!
Well, not necessarily.
Long lines that are a result of long symbol names and a boilerplate-ridden language (note the author's Java background) can easily exceed that limit without actually becoming too complex.
I assume that's why, for example, Google enforces a bigger column limit for Java than the likes of JavaScript in its style guides.
I guess there is some truth to that, C code (especially object oriented C code) can end up with symbols that will easily take half of your 80 character limit (e.g. g_dbus_object_manager_client_new_for_bus_finish).
In such cases the GNU coding standards come in handy.
I have an extra wide curved monitor. I still code with 80 characters. I find very long lines hard to read as well.
The only time I use the full screen with my IDE is when I'm comparing diffs.
80 for me is a bit too low, i usually stick between 100-120