http://www.perlmonks.org?node_id=528852

Vote on this poll

72 -- Doesn't everybody?
[bar] 87/11%
20 -- I use a Zaurus.
[bar] 6/1%
78 -- Isn't this the standard?
[bar] 93/12%
180 -- I have a wide screen!
[bar] 7/1%
120 -- Eighty chars just isn't enough.
[bar] 44/6%
Real programmers don't wrap their code.
[bar] 152/20%
64 -- Because its such a nice number....
[bar] 4/1%
50 -- My wife won't let me upgrade my 15 inch monitor....
[bar] 6/1%
I never wrap two lines at the same column.
[bar] 15/2%
Aren't wraps something you eat for lunch?
[bar] 11/1%
80 -- 'Cause I like to...
[bar] 110/14%
Wherever my boss says I have to.
[bar] 7/1%
79 -- Rank doth have its priviledges
[bar] 20/3%
I am a free spirit and wrap as I like when I like....
[bar] 213/27%
775 total votes
Replies are listed 'Best First'.
Re: On what column do you wrap your code?
by Old_Gray_Bear (Bishop) on Feb 08, 2006 at 17:41 UTC
    There is an option missing:
    • 71 -- For historical continuity

    ----
    I Go Back to Sleep, Now.

    OGB

Re: On what column do you wrap your code?
by swampyankee (Parson) on Feb 08, 2006 at 17:56 UTC

    Ideally, 72, because I'm old enough to remember punched cards and, much worse, old enough to need to use large fonts.

    emc

    " When in doubt, use brute force." — Ken Thompson
      Punched card, you lucky fellow. I had to start on coding sheets, hand in to ops to punch to card.

      Then I found the terminal room and learnt how to send jobs direct, not long after found interactive compiler and that really sped things up. This is Fortran 77 on Honeywell Mainframe, GCOS 4 operating system.

        Coding sheets! A luxury! In my day we had to lay out stones in a river bed. Made coding during the rainy season mighty interesting.
        How about Fortran IV on ICL 1900 under George III with 6-bit bytes so no lower case letters. Also, the editor was single pass so you planned your edits very carefully! I did have a teletype though linked to the mainframe with a 100 baud acoustic coupler. Anyone remember those?
Re: On what column do you wrap your code?
by DrWhy (Chaplain) on Feb 08, 2006 at 17:15 UTC
    I have a wide screen, so I wrap my functional code at column 80 and place any temporary/debugging code starting at column 82 and do not wrap it. This is made nicer by the fact that the editor I use, UltraEdit, can place a vertical line at any column. I have it set to column 80.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

      OT: I love UltraEdit when I'm forced to use Windows. On my native Mac OS, I use BBEdit.
      I use UltraEdit also and I have a vertical column set at column 78. I don't always wrap there, but in general I attempt to not go too far past it.

      I use UE all the time, (lifetime registration++) but i havent the foggiest how to turn on this vertical line business. How do i do it?

      ---
      $world=~s/war/peace/g

        View menu->Set Column Markers (set marker 1 to 80), View menu->Show Column Marker 1

        --DrWhy

        "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Re: On what column do you wrap your code?
by grinder (Bishop) on Feb 08, 2006 at 18:12 UTC

    Interesting question. I pulled up some code and run it through (don't shoot me)

      awk '{print length($0)}' * | sort | uniq -c | sort -nk2

    ... which produced the following output:

    504 1 112 2 12 3

    (504 blank lines, 112 lines with a single char (probable a closing brace) and so on). I turned that into a scatter plot and I see that I have a fair spread of line lengths all the way out to about 75. From there the number of lines with longer lengths drops off a cliff, but that there is a clearly visible tail of line lengths all the way out to 120 or so.

    Which does tend to correspond to the way I code. I like breaking things up, such as named parameters on separate lines, but as I'm either in an xterm or a Putty session, I just make the window as big as it needs to be, and if a certain line of code just looks nicer at 120 characters then I'll let it be.

    • another intruder with the mooring in the heart of the Perl

Re: On what column do you wrap your code?
by merlyn (Sage) on Feb 08, 2006 at 19:11 UTC
Re: On what column do you wrap your code?
by mirod (Canon) on Feb 08, 2006 at 17:14 UTC

    Usually around 120, but I just checked, and the biggest gvim window I can get can take 315 chars with the font I use. So I feel I am showing a lot of restraint!

Re: On what column do you wrap your code?
by ambrus (Abbot) on Feb 08, 2006 at 19:26 UTC

    I've chosen 120 but really it's 100 because I've set up the console to 100x37.

Re: On what column do you wrap your code?
by Anonymous Monk on Feb 08, 2006 at 22:50 UTC
    Over 80 is too far. I wrap whenever it looks like it's too near the edge...
Re: On what column do you wrap your code?
by beachbum (Beadle) on Feb 08, 2006 at 18:15 UTC
    I get lost in wrapped code... never use it. I occasionally end up having nested loop lines at 8-10 tab indentions.
Re: On what column do you wrap your code?
by Perl Mouse (Chaplain) on Feb 09, 2006 at 22:47 UTC
    Wrap code? Why would I? Do I look like a Python programmer to you? I don't need newlines, all they do is eat disk space and make hard disk sellers happy. Death to the newline!
    Perl --((8:>*
Re: On what column do you wrap your code?
by herby1620 (Monk) on Feb 10, 2006 at 01:20 UTC
    Of course, one always wraps on (or before) column 72. If you were really doing it right, the continuation character (other than zero, or blank) would be in column 6 (but I digress). You need to be careful, usually the drum card in the keypunch is set to skip automagically at column 72 anyway, so you need to think about it before that happens.

      Ah, another soul remembering the days before ed, let alone emacs or vim...

      Then, of course, giving the long deck to the operator so he (never "she") could put it into the card reader. Or, depending on how quickly you needed the program's output, dropping the cards on the floor.

      There was a reason for those sequence numbers in 73 through 80...

      emc

      " When in doubt, use brute force." — Ken Thompson
Re: On what column do you wrap your code?
by jonadab (Parson) on Feb 09, 2006 at 04:23 UTC
    It depends on the code. HTML for instance tends to get wrapped around column 80, except where that would break up an entity in an undesirable way. I tend to wrap elisp around column 120 or so. Perl code gets wrapped based on semantics, not column numbers. email is not, strictly speaking, code, but I tend to wrap it around column 70, because although *my* mailreader can correctly rewrap quoted text, some people with whom I correspond use lesser mailreaders. All of this changes in a web forum, where I use the width of the textarea as a guideline.
Re: On what column do you wrap your code?
by wolfger (Deacon) on Feb 09, 2006 at 14:50 UTC
Missed option
by mtve (Deacon) on Feb 10, 2006 at 08:16 UTC
    Golf -- wrap at space char or don't wrap at all.
Re: On what column do you wrap your code?
by Albannach (Monsignor) on Feb 09, 2006 at 03:08 UTC
    I've used 132 columns for years, probably because that's what the VT220 provided.

    --
    I'd like to be able to assign to an luser

Re: On what column do you wrap your code?
by tweetiepooh (Hermit) on Feb 09, 2006 at 10:01 UTC
    Using vi with line numbers on means that long lines become a real pain, so I keep them around 75 or so.

    (I use gvim on my development machine but not allowed on production boxes so need to be vi able).

Re: On what column do you wrap your code?
by turo (Friar) on Feb 09, 2006 at 16:29 UTC

    i've used a long time ago vt100 terminals ... this old
    heritage, helps me to have a lot of xterms of 80x25 in my
    screen :-) ... and to be very happy when i use the vterm

    perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'
Re: On what column do you wrap your code?
by samizdat (Vicar) on Feb 10, 2006 at 16:54 UTC
    Real programmers don't wrap their code...

         ... EMACS does, and unwraps as much as it can.

    Don Wilde
    "There's more than one level to any answer."
Re: On what column do you wrap your code?
by tbone1 (Monsignor) on Feb 09, 2006 at 12:46 UTC
    What, no option for 2048? vi rawks, DO0D!!1!

    *ahem* Excuse me.

    --
    tbone1, YAPS (Yet Another Perl Schlub)
    And remember, if he succeeds, so what.
    - Chick McGee

Re: On what column do you wrap your code?
by pileofrogs (Priest) on Feb 09, 2006 at 19:06 UTC

    What about..

    78 .. because TheDamian told me to...

Re: On what column do you wrap your code?
by poqui (Deacon) on Feb 09, 2006 at 22:31 UTC
    180, 132 (greenbar), 80, no wrap... I use them all!
Re: On what column do you wrap your code?
by radiantmatrix (Parson) on Feb 10, 2006 at 21:01 UTC

    I tend toward 80. Why? Hm, well...

    • 72 is much too short when using a 4-char indent level: two levels in and I end up wrapping simple open ... or die "Can't write $filename: $!" calls.
    • 78 would be ok, but WHY?
    • Anything over 80 seems impolitic; I can always expect that someone can view and edit an 80-column line, but much longer and I fear making a production for someone else to deal with my code.

    So, I voted 80, but I'm not strict about it. If I'm maintaining code I try to derive and follow the existing wrapping rules (and other style elements). Some lines just feel like they need to be longer than 80 chars, and I'm willing to let those "break" the wrapping rules.

    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet

      78 would be ok, but WHY?

      The usual argument says stuff about terminals not being able to handle characters in the last column correctly (then why the hell HAVE that column?), and 80-2 allowing the text to still be 80 wide after adding "> ", the quotation mark used in email.

      However, I wouldn't even use such a terminal, and the quoting argument doesn't hold given replies to replies, when another "> " is added. And I indent all code (a habit I got from POD, and I like it) in mail anyway.

      So I think 78 makes no sense at all, and this is one of the guidelines in Perl Best Practices that I choose to ignore. It's 80 for me.

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

        My guess is 78 came about because 'diff' requires two columns for the '< ' and '> '. That seems sensible.
Re: On what column do you wrap your code?
by lorn (Monk) on Feb 09, 2006 at 12:34 UTC
    i following tips on "Best Practices" dog book :P

    Lorn

    -lornlab.no-ip.com-

    -www.slackwarezine.com.br-

Re: On what column do you wrap your code?
by gregor42 (Parson) on Feb 10, 2006 at 15:49 UTC
    Eclipse has a general preference that lets you show the Print Margin as a vertical line. This defaults to 80, but is configurable. Since it's a setting for all Editors it is reflected in EPIC.

    So, barring any VT-xxx sessions, (which are fewer & farther in between as time goes on) I only think about it in terms of printing.



    Wait! This isn't a Parachute, this is a Backpack!
Re: On what column do you wrap your code?
by Knom (Beadle) on Feb 11, 2006 at 05:40 UTC
    ... but seriously, personally I like the challenge of WRITING code in less than 80 cols.

      That's pretty much how I handle it. I don't wrap: I just try to keep lines of code readably short.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

      but seriously, personally I like the challenge of WRITING code in less than 80 cols.

      Hm, apparently you don't have to work with the naming standards imposed by our Oracle group. When one regularly sees stuff like GENERIC_PRODUCT_PKG.GET_GENERIC_PRODUCT_GENERIC_ITEM_CROSS_REFERENCE_INDICATOR_FLAG with about ten parameters on the procedure, it's enough to make a sane person move to Detroit.

      --
      tbone1, YAPS (Yet Another Perl Schlub)
      And remember, if he succeeds, so what.
      - Chick McGee

        Egads!!! Here's my suggestion:

        my $FLAG= GENERIC_PRODUCT_PKG.GET_GENERIC_PRODUCT_GENERIC_ITEM_CROSS_REFERENCE_INDICATOR_FLAG;
        my $MESSAGE="GENERIC PRODUCT XREF INDICATOR FLAG EQUALS: ";
        $MESSAGE.=$FLAG."\n";
        print $MESSAGE;

        Of course, it does help if you don't start out with varbind mappings which are > 80 chars...

        Isn't cut and paste a wonderful thing?!
Re: On what column do you wrap your code?
by Knom (Beadle) on Feb 11, 2006 at 05:37 UTC
    80 digit hex numbers... WOW! What bit processors are you folks working on?? 32 bit hex Address plus CMD code and argument plus spaces only take up ~30 cols. Punch cards and command sheets?? I toggled switches and hit a button. (just kidding)
Re: On what column do you wrap your code?
by blue_cowdawg (Monsignor) on Feb 13, 2006 at 14:54 UTC

    I don't wrap... or rap....

Re: On what column do you wrap your code?
by TedPride (Priest) on Feb 16, 2006 at 13:22 UTC
    I'm the only one who has to work with the code I write, so I wrap at whatever seems comfortable. Generally 100 characters or less.
Re: On what column do you wrap your code?
by QM (Parson) on Feb 18, 2006 at 00:40 UTC
    You left out "at the window edge" (automatically, by the editor), which I suppose is the same as "not at all".

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      80 with 2 char indent
Re: On what column do you wrap your code?
by Anonymous Monk on Feb 17, 2006 at 12:51 UTC
    1

     

    i lie

Re: On what column do you wrap your code?
by PerlingTheUK (Hermit) on Feb 15, 2006 at 18:56 UTC
    85 is my magic column number. Based on 17" TFT running with two vertically separated buffer frames and Lucida Console font size 8.

    Cheers,
    PerlingTheUK
Re: On what column do you wrap your code?
by Paulster2 (Priest) on Feb 16, 2006 at 21:32 UTC

    Warping the Space/Time Continuum is quite a delicate task, one that could leave you hating life or even ending up in another universe.....OH, You were asking about "wrap" not "warp"....eh....my bad. I was wondering what the numbers were about.

    Paulster2


    .oO( If only I could think of something perlish to write.... )

View List Of Past Polls