It gets tiring listening to devs rage about the 80-char limit, then go on to produce code that's basically unreadable because it scrolls way off the screen.
I'm also not convinced that 80 chars "happens to line up quite well with the human eyes ability to track horizontal lines of text". It's claimed often, but in the absence of any actual studies, the best you can really say on this is that it is your subjective experience. Mine is different - I find 100-120 columns per line to be eminently more readable.
Until the aforementioned study determines what the average peak readability length of _code_ (which I think is likely to be different from regular text, because the semantic units are different between the two), we'll just have to agree to disagree.
Citation needed.
Hacker News keeps clean discourse by downvoting comments that are not relevant or do not stimulate debate.
How do you know the width of a standard human isn't determined by 2000 years of people choosing partners that would fit beside them on a cart comfortably.
Considering the numbers of programmers in the world, and how long they've been working with text, and how much annoyance text breaks / line wrapping / format flowing causes it's kind of surprising that there isn't better ways of wrapping lines without line breaks.
What's current best practice? Or is it just down to the project style guide?
There are more such rules which differ between standards (like Linux kernel style vs. PHP PSR-2 style), e.g. how to pad trailing lines of function call. Linux style says to align trailing lines at offset next to the opening brace. (This doesn't look good in case of long function name, though, but most of time readability of this way is very good.) K&R is referenced as an original of such style, just as everywhere in Linux coding style. Also Linux coding style is not just what is told in Documentation/CodingStyle - there are some unwritten tools which you'll encounter when you run scripts/checkpatch.pl or get reviews on your patch submission.
We've all got widescreen monitors now, right? So it makes sense that people are going well past 80 characters.
For the same reason, newspapers use multiple columns, even though the paper itself would allow for 200-character lines.
qry.setParameter("a", a);
qry.setParameter("b", b);
qry.setParameter("foo", foo);
qry.setParameter("bar", bar);
After the first "qry.setParameter" you're no longer reading anything but the parameters and your eyes are moving vertically.Or if you have something like this:
Query qry = getEntityManager().createNamedQuery("User.findUserBySomething", Long.class);
You're only reading the "User.findUserBySomething". The rest of it is mainly fluff.It's also worth noting that newspapers traditionally used columns because they allow individual articles to be typeset and then divided into pieces later during composition. Not because they offer some kind of readability advantage.
I think on a mental level, the problem is that when the lines are this short, the grammar is extremely broken up, so you need to "cache" 4-5 lines of context to understand anything. When it's 80 per line, lines are parsed in a more independent fashion.
I think 70-100 is perfect, depending on other factors.
Screenshot of what I mean: http://www.trbimg.com/img-5667d3f6/turbine/la-la-na-menace02...
Sure we do, but some/many of those widescreen monitors are only eleven or thirteen inches diagonally, and can't reasonably fit two buffers of text 120-chars wide without shrinking the font to eye-straining sizes (yes, even on retina screens).
Plus, this only gets worse as you get older and your eyesight starts to diminish.
Yup, I'm at that point.
[1]: https://tkware.info/2016/05/08/a-case-for-increasing-pep8-li...
There are contexts when Python doesn't force you to, such as the example the article shows as "ways [that] actually make our code less obvious and less readable":
err("HTTP 403 Forbidden -"
" Does your bitbucket user have rights to the repo?\n")
But if you indent it properly, I don't think it's less readable than the extra-long-line-with-scrolling: err("HTTP 403 Forbidden -"
" Does your bitbucket user have rights to the repo?\n")
The other example, build_url = "{url}/pipelines/{pipeline}/jobs/{jobname}/builds/{buildname}".format(
url=os.environ['ATC_EXTERNAL_URL'],
pipeline=os.environ['BUILD_PIPELINE_NAME'],
jobname=os.environ['BUILD_JOB_NAME'],
buildname=os.environ['BUILD_NAME'],
)
could perhaps be written as urltmpl = "{url}/pipelines/{pipeline}/jobs/{jobname}/builds/{buildname}"
build_url = urltmpl.format(
...
or like this: build_url = "/".join((os.environ['ATC_EXTERNAL_URL'],
"pipelines", os.environ['BUILD_PIPELINE_NAME'],
"jobs", os.environ['BUILD_JOB_NAME'],
"builds", os.environ['BUILD_NAME']))(Coincidentally, this is why the separator there is a dash, rather than the more grammatically correct comma)
And I thank you for the other examples of ways to handle the URL, but again we've moved into making changes for very minor benefit just to please the analyzer, rather than the human reading the code.
I used to work at a dysfunctional startup which could not agree on any sort of coding style conventions, and one of the other devs would just zoom his Visual Studio window fullscreen and type, type, type until he bounced off the far edge, no sense of column width at all. His code was excruciatingly terrible for a lot of reasons, but at least it was easy to spot since it looked just as messy as its structure.
I actually was just contemplating ditching the 80-char limit the other day, at least for personal projects.
For car width, I think that that's also a pretty reasonable width, since it's the perfect width to fit two people side-by-side comfortably, with a bit of room in the middle.
Now we only need to think of things that have developed for historical purposes, yet are not reasonable defaults.