7 ms·
Optimal code line width has very little to do with monitor or window width. It's more of an anatomical restriction: the resolution of the human eye and the fiel
by avodonosov 6y ago
Optimal code line width has very little to do with monitor or window width. It's more of an anatomical restriction: the resolution of the human eye and the field of view.
For example, if we had 10 meter-wide monitors we won't be able to see them entirely from a close distance. Increasing the distance will require to increase the font, so the number of characters per line we can use doesn't change much.
Not so long ago I showed a piece of code on a mobile phone to a colleague, saying he should use shorter lines. He replied I need a larger display. When I opened the same code on my desktop display the lines were not fitting the editor window almost the same as on the mobile screen. (The angular sizes of a mobile phone screen and individual characters on it are approximately the same as of the bigger screen and characters on it because we keep phone closer to eyes).
I currently work with a codebase where long lines are used and it is so inconvenient. When I switch to some 80-cols code it is such a relief.
- TeMPOraL 6y agoDetails matter. The way I'm set up at my desktop, my editor can fit ~320 columns. Which means I can fit four 80-column-wide files side by side. Three, if you account for line numbers on the margin. (I usually do two, because my code tends to go up to ~120 characters.)
- demosito666 6y agoThe more reasons to use narrower lines, right? I mean, I work in two files side by side 50% of the time, and with 120 chars the text would require wrapping, which is really unreadable in e.g. python.
- jabirali 6y agoPersonally, I prefer handling long lines via horizontal scrolling (with keyboard shortcuts) rather than wrapping.
- threatofrain 6y agoYou don't read code the way you read a book or long-form document, as authors generally don't optimize for vertical reading.
- bsder 6y agoI would be more sympathetic to 80 column limits if Linux didn't have indent set to 8 columns.
- ASalazarMX 6y agoThis was a solved problem with tab indenting. It's a bit unfortunate that space indenting won, but I understand why.
- catern 6y agoWhat do you mean? Linux uses tabs.
- ASalazarMX 6y agoWinning doesn't mean completely extinguishing the competition.
- jml7c5 6y agoNot really a solved problem. Even if you set your editor to display 1 tab as 2 columns, another person may set their editor to display 1 tab as >2 columns. So even using tabs, a project has to set rules for tab width.
- 0-_-0 6y agoWhy would that be a problem? That's the point, that you can set tab width any way you want.
- ric2b 6y agoThe argument is that the line length limit has to be related to some default indentation length, which in Linux's case is 8 spaces.
- PunksATawnyFill 6y agoThis is always the argument against tabs, but it makes no sense. So what? If you don’t like your tab width, CHANGE IT. That’s a huge win over spaces, where indentation is hard-coded.
- bcrosby95 6y ago> It's more of an anatomical restriction: the resolution of the human eye and the field of view. The restriction on code length to 80 has absolutely nothing to do with the resolution of the human eye or your field of view. > For example, if we had 10 meter-wide monitors we won't be able to see them entirely from a close distance. Increasing the distance will require to increase the font, so the number of characters per line we can use doesn't change much. Again, this isn't relevant to the question of say, 80 cols vs 100 cols vs 120 cols. No one seems to be saying cols should be unbounded in length. > Not so long ago I showed a piece of code on a mobile phone screen to a colleague, saying he should use shorter lines. He replied I need a larger display. When I opened the same code on my desktop display the lines were not fitting the editor window almost the same as on the mobile screen. (We keep phone closer to eyes so can use smaller characters). I'm not sure how this is an argument for 80 cols other than the already addressed "I limit my development environment to 80 cols".
- burntsushi 6y agoI have a certain monitor width, distance from that monitor and font size. Those constraints dictate how many open file columns I can fit across my screen. I'm happy if I can get two columns, so that I can edit files side-by-side. 80 columns is the approximate sweet spot. The suggestion that people should just get "better hardware" is so completely asinine, because it neglects to realize that the quality of hardware might not be the problem. For example, instead of having a single very large monitor, I use three somewhat smaller monitors because that enables other productive workflows.
- bcrosby95 6y agoHe never said to buy better hardware. He said the code should no longer be formatted based upon what he believes to be a niche situation. People in this situation can, in fact, still edit code. You will get line wrapping. It's not optimal, but neither is editing 80 lines when you have 100 available.
- burntsushi 6y ago