5 ms·
Many of the submissions seem to have code with lines a mile long. Maybe it's less of an issue nowadays with high-res, widescreen monitors, but I find code that
by jkkramer 18y ago
Many of the submissions seem to have code with lines a mile long. Maybe it's less of an issue nowadays with high-res, widescreen monitors, but I find code that stays within around 80-100 columns to be most readable. Plus it's easier to peruse when you end up seeing the code in other, non-editor environments (terminal, source control, browser).
Does anyone actually prefer longer (100+) lines over LOC? Maybe it's a Windows thing. I know I started to become stricter about line length when I moved to OS X (and started using the command-line more often).
- LogicHoleFlaw 18y agoNewspapers have known for ages that shorter lines are easier for the eyes to follow. I try to stay under 80 lines, with 100 being my max. It helps me to read and comprehend better. Protip: `less -S` unwraps lines so you can read a file in its original format. The arrow keys let you pan left and right.
- mhartl 18y agoIndeed. Creativity can thrive within boundaries: look at what Shakespeare did with the sonnet, or Beethoven with the sonata. Limiting yourself to 80 characters enforces discipline and serves as a valuable constraint on code: always readable, never verbose.
- etal 18y agoMaybe it's an IDE thing. I like a skinny column of code next to something else -- either another skinny column of code (maximized gvim, one vertical split) or Firefox with some documentation/reference in it. Firefox and most IDEs seem to want the whole screen, especially on a 1280-px-wide or smaller display. I can strip the stylesheets off of gratuitously spread-out web pages with Greasemonkey, but most IDEs seem to require enough screen real estate for, um, stuff, that a window with 80 columns of text still takes up more than half the screen.
- dfranke 18y agoI usually write Lisp in 120 columns. I don't actually put very much on each line, but my code tends to be very deeply nested so it finds its way to the right margin rather quickly. Twenty consecutive close-parens is not unusual for me.
- ken 18y agoI have the opposite experience. Lisp puts the operator on the far left, and has no penalty for a newline, so I find it much easier to keep lines shorter. In Algol-based languages, I end up with "something_something [op] something_something" and then if I need to do something else, my next line starts 20 chars from the left edge, to line up with the op. So I have to choose between really long lines, or really short identifiers, or breaking one expression into several using temporary variables -- all of these make me feel dirty.