News for hackers. Stuff that matters.
Re:Line length in programming by Nursie on Monday February 24, 2014 @05:35AM (#7290069)
80 is too few. The old reason for it (what if you get stuck doing an emergency bugfix using vi on an 80 char display?!?) no longer holds.

It's not massively too few, and most lines never get close to the limit anyway, but the odd line of 100-120 thrown in really isn't a problem on a modern display.

Re:Line length in programming by chrisbridgett on Monday February 24, 2014 @06:13AM (#7290175)
I thought the historical reason was that punch-cards had 80 characters per line.

...just Googled it: http://programmers.stackexchange.com/questions/148677/why-is...

Re:Line length in programming by RyanZAG on Monday February 24, 2014 @06:33AM (#7290232)
That's interesting. Even more so in that the 80 characters per line for punch-cards is because that's the size a dollar bill was back then, because punch cards were created for use in the 1890 census. http://www.columbia.edu/cu/computinghistory/census-tabulator...

It's like the railway gauge size being standardized by the ancient romans. The best part of all of this though is the other comments on this page - many of them seem to imply that 80 width was chosen because of how well it fits onto your computer screen and that 100 must be too wide. If the dollar bill in 1890 had been a bit wider, they'd likely be arguing now how 80 is too small!

It proves the point that it's important to actually understand why certain things are chosen and not just assume they're always the best. Going with the standard method is not always the most beneficial path.

Re:Line length in programming by NateDad on Monday February 24, 2014 @07:11AM (#7290355)
That is a straw man. No one actually thinks 80 character displays are the reason to use 80 characters.

I think 80-100 is fine. More than 100 and you probably need to refactor the line some, because you probably have too much logic on a single line (or you need to choose names that aren't hugely long).

Re:Line length in programming by Nursie on Monday February 24, 2014 @12:30PM (#7292044)
>> No one actually thinks 80 character displays are the reason to use 80 characters.

Err, yeah they do, I have been given exactly that reason on a few occasions, generally by older engineers who had experience with old-school machines that had precisely those screen dimensions. I don't disagree with your main point, but it's really not a straw man.

Re:Line length in programming by NateDad on Tuesday February 25, 2014 @06:55AM (#7297037)
Well, for most people it's a straw man. I've worked with some greybeards, and they are smart enough to know that they can resize the terminal on their modern laptop :)
Re:Line length in programming by collyw on Monday February 24, 2014 @10:16AM (#7291189)
The beauty of expressive languages like Python is that you can fit a lot of logic into one line with list comprehensions and the likes. When it isn't obvious what it is doing straight away, add a comment.
Re:Line length in programming by NateDad on Tuesday February 25, 2014 @06:53AM (#7297033)
This is almost always a bad idea. I've extracted many a python line into 2-4 lines to make it a hell of a lot more clear. Packing logic into a line is not a good thing. It may be fun and a challenge, but it makes for fragile code that is easy to get wrong and/or misunderstand.
Re:Line length in programming by collyw on Friday February 28, 2014 @01:08PM (#7320391)
I often use list comprehensions where I would have previously used a for loop. It means you have less variables and are less likely to have side effects. I wouldn't say it is always a bad idea.
Re:Line length in programming by jeremyjh on Monday February 24, 2014 @06:56AM (#7290301)
You don't use a split screen in your editor?
Re:Line length in programming by stinos on Monday February 24, 2014 @07:05AM (#7290337)
'modern display' is mentioned so I'd guess that's 1900 pixels or more. That will likely fit a couple of split screens even at 100 characters?
Re:Line length in programming by mooism2 on Monday February 24, 2014 @08:26AM (#7290588)
A 1920pixel-wide monitor is 274 characters wide (if your characters are 7 pixels wide, like mine). That's two files side-by-side with 100 character lines, or three files side-by-side with 80 character lines.
Re:Line length in programming by Nursie on Monday February 24, 2014 @12:28PM (#7292029)
Split how?

I usually work with a file list/project navigator/something to the left and a build window at the bottom of the screen. I usually have two screens so that docs/browsers/whatever can live on the second screen. Seems to work for me.

In my current project I'm using eclipse which has a right-hand panel for build targets. Even with both left and right hand panels there's still enough space in the source window for 130 character lines.

Don't get me wrong, I think most lines should be short and that you should endeavour to keep them a reasonable, readable length. I just disagree with 80 as a hard limit.