Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: 78/80 chars perl line still a meaningful rule

by talexb (Canon)
on Oct 18, 2012 at 19:23 UTC ( #999800=note: print w/replies, xml ) Need Help??

in reply to 78/80 chars perl line still a meaningful rule

It's a simple question, with, for me, a complicated answer. It boils down to

  • Make the code easy to read and comprehend;
  • Make the code easy to maintain; and
  • Make the code easy to print out.

Reading and Comprehension are important points: if there are multiple lines much longer than 80 characters, the eye can't take it all in, and the head has to move as well. The eye's visual acuity is actually quite limited, but the brain does an excellent job of pretending that it's better than it is. As the line of code gets longer, it gets harder to find where the beginning of the next line is.

Maintaining code, once you comprehend it, is vital. And it could be that you're not on your favourite workstation with multiple gigantic screens -- you might be limited to a 25x80 screen. Having long lines cut off or wrapped can be quite irritating. (I've just been working on some scripts within Jenkins, editing in dialog boxes, and it's difficult to see where a line is a continuation.)

Getting a hard copy of your code can be quite useful -- but that's for naught if the print function either cuts the long lines or wraps them where you don't want it to. It's much better to do your own wrapping (I use gq{ in vim, for example) and have it display and print out correctly. Yes, the file will be longer -- too bad. :)

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^2: 78/80 chars perl line still a meaningful rule
by greengaroo (Hermit) on Oct 19, 2012 at 17:56 UTC

    I agree with that!

    And may I add that consistency in your indentation is more important than the length of your lines.

    There are no stupid questions, but there are a lot of inquisitive idiots.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999800]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2018-06-20 18:04 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.