Hacker News new | ask | show | jobs
by NateDad 4499 days ago
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).

2 comments

>> 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.

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 :)
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.
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.
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.