Re: A desperate lunge for on-topic-ness

Discussion in 'Python' started by Jean-Michel Pichavant, Oct 19, 2012.

  1. ----- Original Message -----
    [snipe 80 char line discussion]
    > And, quite frankly, people who care more about the readability of
    > their
    > code than about squeezing in as much processing into a single line of
    > text as possible.
    >


    As usual Steven, you take someone's argument, you add a little bit of exaggeration and make it sound silly.
    Using 80+ char lines doesn't mean I put all my efforts exceeding the 80 char limit. As a matter of fact, I never
    get the char limit get into the way of readability. What needs to be short will be short, and what needs to be long will be long.


    [snip]
    > Flame away :)


    good job :eek:)

    JM
     
    Jean-Michel Pichavant, Oct 19, 2012
    #1
    1. Advertising

  2. On Fri, 19 Oct 2012 11:21:06 +0200, Jean-Michel Pichavant wrote:

    > Using 80+ char lines doesn't mean
    > I put all my efforts exceeding the 80 char limit.


    I didn't say it did. I was describing some of the reasons people might
    choose to stick to the 79 character limit, beyond the reason you gave,
    which quite frankly is the least important reason. 80 character
    terminals? Who still uses them? Well, a few people, but they're in a
    minority. But caring about the readability of code? Everyone needs to
    read code at some point, and 79 characters is a good balance between
    stuffing too much into a single line and spreading it out too thinly over
    multiple lines.


    > As a matter of fact, I
    > never get the char limit get into the way of readability. What needs to
    > be short will be short, and what needs to be long will be long.


    Code never *needs* to be long, because it can always be shortened.

    Some code might be more conveniently written as a single long line. But I
    would argue that nearly never is code more easily *read* as a single long
    line, and since code is read much more than it is written, it is more
    important to optimise for reading, not writing.



    --
    Steven
     
    Steven D'Aprano, Oct 19, 2012
    #2
    1. Advertising

  3. On 19 Oct 2012 22:14:27 GMT, Steven D'Aprano
    <> declaimed the following in
    gmane.comp.python.general:


    > I didn't say it did. I was describing some of the reasons people might
    > choose to stick to the 79 character limit, beyond the reason you gave,
    > which quite frankly is the least important reason. 80 character
    > terminals? Who still uses them? Well, a few people, but they're in a
    > minority. But caring about the readability of code? Everyone needs to
    > read code at some point, and 79 characters is a good balance between
    > stuffing too much into a single line and spreading it out too thinly over
    > multiple lines.
    >


    Strangely, we've gone from 80-character fixed width displays to
    who-knows-what (if I drop my font size I can probably get nearly 200
    characters across in full-screen mode)...

    But at the same time we've gone from 132-character line-printers
    using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11
    paper, defaulting to portrait orientation -- with a 10 character/inch
    font, and 1/4" left/right margins, we're back to 80 character limitation
    <G>
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Oct 20, 2012
    #3
  4. Jean-Michel Pichavant

    Tim Chase Guest

    On 10/19/12 17:14, Steven D'Aprano wrote:
    > Code never *needs* to be long, because it can always be shortened.


    I advocate one bit per line:

    1
    0
    1
    0
    0
    1
    0
    1
    1
    0
    0
    1
    0
    1
    1
    1
    0
    0
    0
    0
    1
    1
    1
    0
    1
    1
    0
    0
    1
    1
    0
    1
    1
    0
    0
    1
    1
    1
    1
    0
    0
    1
    1
    1
    1
    1
    1
    1

    «grins, ducks, and flees»

    Shortenedly-yers,

    -tkc
     
    Tim Chase, Oct 20, 2012
    #4
  5. Jean-Michel Pichavant

    rusi Guest

    On Oct 20, 8:27 am, Tim Chase <> wrote:
    > On 10/19/12 17:14, Steven D'Aprano wrote:
    >
    > > Code never *needs* to be long, because it can always be shortened.

    >
    > I advocate one bit per line:
    >
    > 1
    > 0
    > 1
    > 0
    > 0
    > 1
    > 0
    > 1
    > 1
    > 0
    > 0
    > 1
    > 0
    > 1
    > 1
    > 1
    > 0
    > 0
    > 0
    > 0
    > 1
    > 1
    > 1
    > 0
    > 1
    > 1
    > 0
    > 0
    > 1
    > 1
    > 0
    > 1
    > 1
    > 0
    > 0
    > 1
    > 1
    > 1
    > 1
    > 0
    > 0
    > 1
    > 1
    > 1
    > 1
    > 1
    > 1
    > 1
    >
    > «grins, ducks, and flees»
    >
    > Shortenedly-yers,
    >
    > -tkc


    T
    H
    A
    N
    K
    S

    T
    I
    M
    (for the sanity)
     
    rusi, Oct 20, 2012
    #5
  6. On 2012-10-20, Dennis Lee Bieber <> wrote:

    > Strangely, we've gone from 80-character fixed width displays to
    > who-knows-what (if I drop my font size I can probably get nearly 200
    > characters across in full-screen mode)...
    >
    > But at the same time we've gone from 132-character line-printers
    > using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11
    > paper, defaulting to portrait orientation -- with a 10 character/inch
    > font, and 1/4" left/right margins, we're back to 80 character limitation
    ><G>


    True, but nobody prints source code out on paper do they?

    Seriously -- I can't remember the last time I printed souce code...

    --
    Grant
     
    Grant Edwards, Oct 20, 2012
    #6
  7. On Sat, 20 Oct 2012 14:18:47 +0000 (UTC), Grant Edwards
    <> declaimed the following in
    gmane.comp.python.general:

    >
    > True, but nobody prints source code out on paper do they?
    >
    > Seriously -- I can't remember the last time I printed souce code...


    Well, having been unemployed for a year, I can't speak much of
    recent practice...

    But I did tend to run up listings when I had to take over
    maintenance of some programs and needed to become familiar with the
    overall code base...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Oct 20, 2012
    #7
  8. On Sat, Oct 20, 2012 at 3:10 PM, Dennis Lee Bieber
    <> wrote:
    > On Sat, 20 Oct 2012 14:18:47 +0000 (UTC), Grant Edwards
    > <> declaimed the following in
    > gmane.comp.python.general:
    >
    >>
    >> True, but nobody prints source code out on paper do they?
    >>
    >> Seriously -- I can't remember the last time I printed souce code...

    >
    > Well, having been unemployed for a year, I can't speak much of
    > recent practice...
    >
    > But I did tend to run up listings when I had to take over
    > maintenance of some programs and needed to become familiar with the
    > overall code base...

    Same here. I've been unemployed (retired!) 6 years, but I'd
    occasionally print code written by someone else, never anything of my
    own.
     
    David Robinow, Oct 20, 2012
    #8
  9. Jean-Michel Pichavant

    Walter Hurry Guest

    On Sat, 20 Oct 2012 14:18:47 +0000, Grant Edwards wrote:

    > True, but nobody prints source code out on paper do they?
    >
    > Seriously -- I can't remember the last time I printed souce code...


    I remember my first IT job - COBOL programming in the early 80's. The
    rule was that every time we delivered a new or updated program into
    testing, we had to print a listing onto fanfold paper and hang it, in a
    cardboard binder, onto a set of rails which ran down the center of the
    office.

    I recall even then thinking the practice ludicrous.
     
    Walter Hurry, Oct 20, 2012
    #9
  10. Jean-Michel Pichavant

    Roy Smith Guest

    In article <5081d0c3$0$30003$c3e8da3$>,
    Steven D'Aprano <> wrote:

    > Some code might be more conveniently written as a single long line. But I
    > would argue that nearly never is code more easily *read* as a single long
    > line, and since code is read much more than it is written, it is more
    > important to optimise for reading, not writing.


    Like many people here, I don't worry much about the 80 column limit. I
    make my lines of code as long as they have to be, and no longer. If
    there's some obvious and easy way to fold the statement onto multiple
    lines, I'll do it. If not, I won't.

    This tends to result in lines that are less than 80 characters, but if
    not, I don't worry about it (assuming I'm even aware of it).

    I just did a little experiment. I took about 20 KLOC of python that was
    largely written by me and make a histogram of the line lengths
    (http://www.panix.com/~roy/length.pdf). Just by eye, I'd say "most are
    less than 80, almost all are less than 100". I'd guess the average of
    all non-empty lines is about 45 or so. The longest line is 273
    characters:

    sys.stderr.write("Error: Can't find the file 'settings.py'
    in the directory containing %r.\nYou'll have to run django-profile.py,
    passing it your settings module.\n(If the file settings.py does indeed
    exist, it's causing an ImportError somehow.)\n" % __file__)

    Would that have been better rewritten broken up into several shorter
    lines? Absolutely. Such is life.

    PS: I didn't write that line :)
     
    Roy Smith, Oct 20, 2012
    #10
  11. On Sat, 20 Oct 2012 14:18:47 +0000, Grant Edwards wrote:

    > On 2012-10-20, Dennis Lee Bieber <> wrote:
    >
    >> Strangely, we've gone from 80-character fixed width displays to
    >> who-knows-what (if I drop my font size I can probably get nearly 200
    >> characters across in full-screen mode)...
    >>
    >> But at the same time we've gone from 132-character line-printers
    >> using fan-fold 11x17 pages, to office inkjet/laser printers using
    >> 8.5x11 paper, defaulting to portrait orientation -- with a 10
    >> character/inch font, and 1/4" left/right margins, we're back to 80
    >> character limitation
    >><G>

    >
    > True, but nobody prints source code out on paper do they?


    I do.

    There's nothing better than spreading out a dozen sheets of source code
    over a table to get a good, high-level overview of what does what in
    preparation to refactoring it.


    > Seriously -- I can't remember the last time I printed souce code...


    I've never printed souce code either *wink*



    --
    Steven
     
    Steven D'Aprano, Oct 21, 2012
    #11
  12. On Sun, Oct 21, 2012 at 7:07 PM, Steven D'Aprano
    <> wrote:
    > On Sat, 20 Oct 2012 14:18:47 +0000, Grant Edwards wrote:
    >> True, but nobody prints source code out on paper do they?

    >
    > I do.
    >
    > There's nothing better than spreading out a dozen sheets of source code
    > over a table to get a good, high-level overview of what does what in
    > preparation to refactoring it.
    >
    >> Seriously -- I can't remember the last time I printed souce code...

    >
    > I've never printed souce code either *wink*


    So what you actually mean is that there's nothing _like_ spreading out
    &c &c. I should think that throwing cold water over the code would be
    better.

    ChrisA
     
    Chris Angelico, Oct 21, 2012
    #12
  13. On Sun, 21 Oct 2012 20:20:41 +1100, Chris Angelico wrote:

    > On Sun, Oct 21, 2012 at 7:07 PM, Steven D'Aprano
    > <> wrote:
    >> On Sat, 20 Oct 2012 14:18:47 +0000, Grant Edwards wrote:
    >>> True, but nobody prints source code out on paper do they?

    >>
    >> I do.
    >>
    >> There's nothing better than spreading out a dozen sheets of source code
    >> over a table to get a good, high-level overview of what does what in
    >> preparation to refactoring it.
    >>
    >>> Seriously -- I can't remember the last time I printed souce code...

    >>
    >> I've never printed souce code either *wink*

    >
    > So what you actually mean is that there's nothing _like_ spreading out
    > &c &c. I should think that throwing cold water over the code would be
    > better.


    Er, no. Note spelling of "source code" vs "souce code". Hence the grin.

    I seriously do print out source code. When I'm having trouble seeing how
    the parts of a module fit together, reading print-outs is a good way
    around the problem. Class browsers don't show you duplicate code, and
    besides, only works with classes. Reading code on screen is limited in
    how much you can see at a time. Both of these things play a part in
    refactoring, and so does printing out the source and having a human being
    (i.e. me) look at it.


    --
    Steven
     
    Steven D'Aprano, Oct 21, 2012
    #13
  14. Jean-Michel Pichavant

    Tim Chase Guest

    Re: printing (was: A desperate lunge for on-topic-ness)

    On 10/21/12 05:00, Steven D'Aprano wrote:
    > I seriously do print out source code. When I'm having trouble
    > seeing how the parts of a module fit together, reading print-outs
    > is a good way around the problem.


    I don't print my personal code--both in light of the fact that I
    know it much more intimately and I longer own a printer. But when
    trying to wrap my head around other people's code at work, printing
    helps to get both the big picture and the details at the same time,
    as well as allows me to annotate it with multi-colored
    pens/highlighters.

    Maybe I'll reconsider when I have a 300+ dpi desktop surface that is
    as large as my desk+walls (where those printouts end up).

    -tkc
     
    Tim Chase, Oct 21, 2012
    #14
  15. Jean-Michel Pichavant

    Gene Heskett Guest

    On Sunday 21 October 2012 07:02:26 Steven D'Aprano did opine:

    > On Sat, 20 Oct 2012 14:18:47 +0000, Grant Edwards wrote:
    > > On 2012-10-20, Dennis Lee Bieber <> wrote:
    > >> Strangely, we've gone from 80-character fixed width displays to
    > >>
    > >> who-knows-what (if I drop my font size I can probably get nearly 200
    > >> characters across in full-screen mode)...
    > >>
    > >> But at the same time we've gone from 132-character line-printers
    > >>
    > >> using fan-fold 11x17 pages, to office inkjet/laser printers using
    > >> 8.5x11 paper, defaulting to portrait orientation -- with a 10
    > >> character/inch font, and 1/4" left/right margins, we're back to 80
    > >> character limitation
    > >>
    > >><G>
    > >>

    > > True, but nobody prints source code out on paper do they?

    >
    > I do.
    >
    > There's nothing better than spreading out a dozen sheets of source code
    > over a table to get a good, high-level overview of what does what in
    > preparation to refactoring it.
    >
    > > Seriously -- I can't remember the last time I printed souce code...

    >
    > I've never printed souce code either *wink*


    So do I, but I often am looking at assembler listings with the assembler
    set for 132 chars a line to preserve the src codes comments, so lp gets a
    use 17 cpi option on the cli that makes the listing. I probably recycle 2
    reams of paper a year doing exactly that. Those who won't take advantage
    of that are doomed to publish buggy code.

    Cheers, Gene
    --
    "There are four boxes to be used in defense of liberty:
    soap, ballot, jury, and ammo. Please use in that order."
    -Ed Howdershelt (Author)
    My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
    Not all men who drink are poets. Some of us drink because we aren't poets.
     
    Gene Heskett, Oct 21, 2012
    #15
  16. On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano
    <> wrote:
    > Er, no. Note spelling of "source code" vs "souce code". Hence the grin.


    Ahh. I totally didn't see that, I'm way too used to reading past
    typos. Sure. Printing out *source* code, that's altogether different.

    Me, though, I don't print anything. Paper and I are not exactly on
    speaking terms; the last time we met, he cut me, and that's one of the
    rudest things you can do to someone.

    ChrisA
     
    Chris Angelico, Oct 21, 2012
    #16
  17. Jean-Michel Pichavant

    DJC Guest

    On 20/10/12 15:18, Grant Edwards wrote:
    > On 2012-10-20, Dennis Lee Bieber <> wrote:
    >
    >> Strangely, we've gone from 80-character fixed width displays to
    >> who-knows-what (if I drop my font size I can probably get nearly 200
    >> characters across in full-screen mode)...
    >>
    >> But at the same time we've gone from 132-character line-printers
    >> using fan-fold 11x17 pages, to office inkjet/laser printers using 8.5x11
    >> paper, defaulting to portrait orientation -- with a 10 character/inch
    >> font, and 1/4" left/right margins, we're back to 80 character limitation
    >> <G>

    >
    > True, but nobody prints source code out on paper do they?


    I print source code. Usually when the development has got to a stage
    that the program works but needs a lot of tidying up. It's a lot more
    comfortable than scrolling up and down screen to look through pages from
    the comfort of an armchair. Also I can take the listing to a Café and
    write notes all over it. Sometimes removing the temptation to
    immediately hit the keyboard is a good thing.
     
    DJC, Oct 21, 2012
    #17
  18. On Sun, 21 Oct 2012 20:20:41 +1100, Chris Angelico <>
    declaimed the following in gmane.comp.python.general:


    > So what you actually mean is that there's nothing _like_ spreading out
    > &c &c. I should think that throwing cold water over the code would be
    > better.
    >

    Only if it's mongrelizing with PERL
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Oct 21, 2012
    #18
  19. On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote:

    > On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano
    > <> wrote:
    >> Er, no. Note spelling of "source code" vs "souce code". Hence the grin.

    >
    > Ahh. I totally didn't see that, I'm way too used to reading past typos.


    As a programmer, doesn't that screw up your debugging ability?


    > Sure. Printing out *source* code, that's altogether different.
    >
    > Me, though, I don't print anything. Paper and I are not exactly on
    > speaking terms; the last time we met, he cut me, and that's one of the
    > rudest things you can do to someone.


    Man, you must have deserved it. Paper, he don't just cut anybody.


    --
    Steven
     
    Steven D'Aprano, Oct 21, 2012
    #19
  20. On 2012-10-21, Steven D'Aprano <> wrote:
    > On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote:
    >
    >> On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano
    >> <> wrote:
    >>> Er, no. Note spelling of "source code" vs "souce code". Hence the grin.

    >>
    >> Ahh. I totally didn't see that, I'm way too used to reading past typos.

    >
    > As a programmer, doesn't that screw up your debugging ability?


    Indeed it does.

    I spent a half hour the other day trying to figure out what was wrong
    with a line of PHP code, when it was nothing but a mis-spelled
    variable name. [I've only been working with PHP a short time, but
    have quickly grown to dislike it.]

    --
    Grant
     
    Grant Edwards, Oct 21, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zero Piraeus

    A desperate lunge for on-topic-ness

    Zero Piraeus, Oct 18, 2012, in forum: Python
    Replies:
    24
    Views:
    358
    Krzysztof Voss
    Oct 19, 2012
  2. Chris Angelico

    Re: A desperate lunge for on-topic-ness

    Chris Angelico, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    148
    Chris Angelico
    Oct 18, 2012
  3. Demian Brecht

    Re: A desperate lunge for on-topic-ness

    Demian Brecht, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    193
    Demian Brecht
    Oct 18, 2012
  4. Mark Lawrence

    Re: A desperate lunge for on-topic-ness

    Mark Lawrence, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    146
    Mark Lawrence
    Oct 18, 2012
  5. Jean-Michel Pichavant

    Re: A desperate lunge for on-topic-ness

    Jean-Michel Pichavant, Oct 18, 2012, in forum: Python
    Replies:
    2
    Views:
    169
    Demian Brecht
    Oct 19, 2012
Loading...

Share This Page