Live data from Hacker News

Line length in programming

ck.kennt-wayne.de

1–10 of 74 posts

Re: Line length in programming

#2
And obviously practicality can get in the way. 80 character lines will be a nightmare in a java-project with verbose naming schemes (FactoryFactoryObjectThingymybobProducer thingy = new FactoryFactoryObjectThingymybobProducer(..);).

Re: Line length in programming

#3
Under what mechanism is it decided that this particular post becomes visible on Hacker News? Does it simply mean that one user with high karma liked the post? The 80 character rule is in programming over and over again and I didn't find anything new in the article...

Re: Line length in programming

#4
post #3

Under what mechanism is it decided that this particular post becomes visible on Hacker News? Does it simply mean that one user with high karma liked the post? The 80 character rule is in programming over and over again and I didn't find anything new in the article...

The information on how to configure emacs to highlight lines that are too long was new to me.

I presume it is on the front page because it has got several up votes in its first half hour.

Re: Line length in programming

#5
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

#7
80 chars is a useful rule of thumb, so long as it's tempered by practicality. I've worked on projects where the limit was taken far too literally, which results in code that's harder to read.

This is especially true if you're using something verbose (Java, Objective-C) or whitespace-sensitive (Python).

Re: Line length in programming

#8
In my opinion the 80 character limit is mostly for better presentability. If the code appears in a blog post or a book, it is better to read and typeset if it is less than 80 characters. Though there are several articles[1] which explain other reasons for this legacy limitation.

I would be happy to read code more than 80 characters, if it doesn't have to be artificially cut into multiple lines (the screenshot in the post is a pretty good example). In fact, I find 80 characters too less and often set Emacs to use 100 characters as the limit.

[1]: http://stackoverflow.com/questions/903754/do-you-still-limit...

Re: Line length in programming

#9
I think this post was upvoted because the tip is easily among the top 10 advice that can be given to aspiring programmers. Forcing yourself to write short lines forces you to decompose code which in turn lets you see the patterns you are working with which you then can refactor. Long lines, deeply nested code blocks and code duplication. Those traits tend to cluster together and are a sign of inexperience imnsho.
Post reply on HN