Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 05:20:20PM +0530, Rustom Mody wrote: > There was a recent discussion on the python list regarding maximum line > length. > It occured to me that beautiful haskell programs tend to be plump (ie have > long lines) compared to other languages whose programs are 'skinnier'. > My thoughts on this are at > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > Are there more striking examples than the lexer from the standard prelude? > [Or any other thoughts/opinions :-) ] For what is worth, in our project (Ganeti) which has a mixed Python/Haskell codebase, we're using the same maximum length (80-but-really-79) in both languages, without any (real) issues. regards, iustin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 5:29 PM, Iustin Pop wrote: > On Mon, Oct 29, 2012 at 05:20:20PM +0530, Rustom Mody wrote: > > There was a recent discussion on the python list regarding maximum line > > length. > > It occured to me that beautiful haskell programs tend to be plump (ie > have > > long lines) compared to other languages whose programs are 'skinnier'. > > My thoughts on this are at > > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > > > Are there more striking examples than the lexer from the standard > prelude? > > [Or any other thoughts/opinions :-) ] > > For what is worth, in our project (Ganeti) which has a mixed > Python/Haskell codebase, we're using the same maximum length > (80-but-really-79) in both languages, without any (real) issues. > > regards, > iustin > Sure! There can hardly be a case that 80 causes any issues. Just that a bit more than 80 can sometimes lead to distinctly more elegant programs. Too much more than 80 can cause issues with readability and/or other tools. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
It is kind of ironic that the wide code examples in the blog post are wrapped at 65 chars by the blog formatting. Regards, Malcolm On 29 Oct 2012, at 11:50, Rustom Mody wrote: > There was a recent discussion on the python list regarding maximum line > length. > It occured to me that beautiful haskell programs tend to be plump (ie have > long lines) compared to other languages whose programs are 'skinnier'. > My thoughts on this are at > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > Are there more striking examples than the lexer from the standard prelude? > [Or any other thoughts/opinions :-) ] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
* Rustom Mody [2012-10-29 17:20:20+0530] > There was a recent discussion on the python list regarding maximum line > length. > It occured to me that beautiful haskell programs tend to be plump (ie have > long lines) compared to other languages whose programs are 'skinnier'. > My thoughts on this are at > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > Are there more striking examples than the lexer from the standard prelude? > [Or any other thoughts/opinions :-) ] Indeed, I've seen quite a few Haskell projects with long lines. Personally, I find it hard to read and very irritating. I always use 80-chars lines in my projects. It seems that people who write long lines mostly come from academic background, where there's less emphasis on maintainability (no offense; also, I haven't conducted a proper statistical research — this is just an impression). Roman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 5:40 PM, Malcolm Wallace wrote: > It is kind of ironic that the wide code examples in the blog post are > wrapped at 65 chars by the blog formatting. > > Regards, > Malcolm Well that goes to underscore a couple of points: 1. The fixed 80 char width that was inviolable decades ago breaks today on both sides: it may be too low or too high! 2. I guess I dont know how to use blogger very well :-) 3. Are you viewing on a narrow device? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I'm not viewing on a narrow device, and I see the wrapped (and the whole post confined to the centre of the screen). I certainly don't use an 80-column limit any more. I use the rule: A function must be completely visible in my editor on my screen. (but this is only a good rule if most people who will be reading the code will also have a similar sized viewport. After all, code is far more often read than written.) And I balance line length with function length. On 29 October 2012 12:18, Rustom Mody wrote: > On Mon, Oct 29, 2012 at 5:40 PM, Malcolm Wallace > wrote: > >> It is kind of ironic that the wide code examples in the blog post are >> wrapped at 65 chars by the blog formatting. >> >> Regards, >> Malcolm > > > > Well that goes to underscore a couple of points: > 1. The fixed 80 char width that was inviolable decades ago breaks today on > both sides: it may be too low or too high! > 2. I guess I dont know how to use blogger very well :-) > 3. Are you viewing on a narrow device? > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
Colin Adams wrote: >I'm not viewing on a narrow device, and I see the wrapped (and the >whole >post confined to the centre of the screen). > >I certainly don't use an 80-column limit any more. I use the rule: > >A function must be completely visible in my editor on my screen. (but >this >is only a good rule if most people who will be reading the code will >also >have a similar sized viewport. After all, code is far more often read >than >written.) I don't think "similar sized viewport" begins to cover it. If the editor wraps long lines, then the lines will always be visible, no matter how long they are. Of course, lines wrapped around to the beginning of the next line in indented code are really, really ugly, so I'd prefer to avoid that. This is one of the cases where it's more important that there be a standard than what the actual value is. Personally, I like roughly 80 columns, but I've been dong this long enough to have used the things that the 80-column console format was copied from. That screens are now bigger isn't really relevant. They are also windowed - no matter how hard Windows, Linux and Mac apps try and pretend they own the entire screen - and multitasking, so it's unreasonable to format code as if the editor were going to be the only visible window. On the other hand, readable cross-platform text formatting always seems to be a lost cause, as this mail and the referenced blog posting demonstrate. -- Sent from my Android tablet with K-9 Mail. Please excuse my swyping. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 5:55 PM, Colin Adams wrote: > I'm not viewing on a narrow device, and I see the wrapped (and the whole > post confined to the centre of the screen). > > I certainly don't use an 80-column limit any more. I use the rule: > > A function must be completely visible in my editor on my screen. (but this > is only a good rule if most people who will be reading the code will also > have a similar sized viewport. After all, code is far more often read than > written.) > > And I balance line length with function length. > Very good point: getting the line to fit in one screen-line is of comparable importance to getting a function into one screen. And especially when one is teaching, (as Roman easily figured out!) having to scroll up and down in the midst of explanations is a certain show-spoiler. On Mon, Oct 29, 2012 at 6:40 PM, Mike Meyer wrote: > On the other hand, readable cross-platform text formatting always seems to > be a lost cause, as this mail and the referenced blog posting demonstrate. > -- > Sent from my Android tablet with K-9 Mail. Please excuse my swyping. > As for the wraparound problems, hopefully they are now solved (for normal computers!) I'd appreciate hearing if they are not. And Thanks Colin for the debugging support! Clearly prettifying code and prettifying a blog are different issues and putting them together makes a harder constraint-solving problem (especially for a blogger noob!) Rusi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On 10/29/2012 07:50 AM, Rustom Mody wrote: > There was a recent discussion on the python list regarding maximum line > length. > It occured to me that beautiful haskell programs tend to be plump (ie > have long lines) compared to other languages whose programs are 'skinnier'. > My thoughts on this are at > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > Are there more striking examples than the lexer from the standard prelude? > [Or any other thoughts/opinions :-) ] In any language, a line longer than 80 characters usually (but not always) suggests that you might want to stop and rethink your design. In many cases a refactoring or two will greatly simplify the code and reduce your line length as a result. I think the lexer is an example of refactoring-needed rather than long-lines-needed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
If I find my line is longer than 80 characters, I just shorten my function and variable names! It's perfectly idio(ma)tic! On Mon, Oct 29, 2012 at 9:52 PM, Michael Orlitzky wrote: > On 10/29/2012 07:50 AM, Rustom Mody wrote: >> There was a recent discussion on the python list regarding maximum line >> length. >> It occured to me that beautiful haskell programs tend to be plump (ie >> have long lines) compared to other languages whose programs are 'skinnier'. >> My thoughts on this are at >> http://blog.languager.org/2012/10/layout-imperative-in-functional.html. >> >> Are there more striking examples than the lexer from the standard prelude? >> [Or any other thoughts/opinions :-) ] > > In any language, a line longer than 80 characters usually (but not > always) suggests that you might want to stop and rethink your design. In > many cases a refactoring or two will greatly simplify the code and > reduce your line length as a result. > > I think the lexer is an example of refactoring-needed rather than > long-lines-needed. > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 6:52 AM, Michael Orlitzky wrote: > On 10/29/2012 07:50 AM, Rustom Mody wrote: > > There was a recent discussion on the python list regarding maximum line > > length. > > It occured to me that beautiful haskell programs tend to be plump (ie > > have long lines) compared to other languages whose programs are > 'skinnier'. > > My thoughts on this are at > > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > > > Are there more striking examples than the lexer from the standard > prelude? > > [Or any other thoughts/opinions :-) ] > > In any language, a line longer than 80 characters usually (but not > always) suggests that you might want to stop and rethink your design. In > many cases a refactoring or two will greatly simplify the code and > reduce your line length as a result. I disagree. That might be true for imperative languages, where width is indicative of deep nesting and its associated problems. But it is not true for a functional language, where it is merely indicative of a wide "normal form". Yes, the normal form can sometimes be refactored, but to what end? You might easily end up refactoring out of the level of abstraction you actually want. Or the wide form might have useful properties, like the ability to sort the lines of source code alphanumerically (which would be lost if you switched to a stanza-based format) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I stick to 80 columns fairly rigidly. This is not only so that it fits into narrow windows, but also so that any two subexpressions in the same expression tend to be close together on my screen, which makes it easier for me to reason about it. If only it was easy for me to read and write code on a Hilbert curve... :) I don't think long lines indicate a design problem; it's solely a formatting thing. On Mon, Oct 29, 2012 at 7:50 AM, Rustom Mody wrote: > There was a recent discussion on the python list regarding maximum line > length. > It occured to me that beautiful haskell programs tend to be plump (ie have > long lines) compared to other languages whose programs are 'skinnier'. > My thoughts on this are at > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > > Are there more striking examples than the lexer from the standard prelude? > [Or any other thoughts/opinions :-) ] > > Thanks, > Rusi > > > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On 10/29/2012 10:28 AM, Alexander Solla wrote: > > In any language, a line longer than 80 characters usually (but not > always) suggests that you might want to stop and rethink your design. In > many cases a refactoring or two will greatly simplify the code and > reduce your line length as a result. > > > I disagree. That might be true for imperative languages, where width is > indicative of deep nesting and its associated problems. But it is not > true for a functional language, where it is merely indicative of a wide > "normal form". Yes, the normal form can sometimes be refactored, but to > what end? You might easily end up refactoring out of the level of > abstraction you actually want. Or the wide form might have useful > properties, like the ability to sort the lines of source code > alphanumerically (which would be lost if you switched to a stanza-based > format) Well, I did leave the door open for special cases with "usually (but not always)." I know I've had to go over 80 chars before with huge constants or long test names. If you're willing to sacrifice maintain/readability for some other property (e.g. source code sortability), then I don't think my point applies. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I also stick to a pretty rigid 78 characters. Doing so actually helps me fit more code onto my screen at a time because I usually have two or three columns of open files side by side. I find that I need this more often than I need to see a single function on a page (thanks to Haskell's traditionally small functions). But this works for single functions as well because I can open the same file in multiple columns at different locations in the file. "The ideal line length for text layout is based on the physiology of the human eye… At normal reading distance the arc of the visual field is only a few inches – about the width of a well-designed column of text, or about 12 words per line. Research shows that reading slows and retention rates fall as line length begins to exceed the ideal width, because the reader then needs to use the muscles of the eye and neck to track from the end of one line to the beginning of the next line. If the eye must traverse great distances on the page, the reader is easily lost and must hunt for the beginning of the next line. Quantitative studies show that moderate line lengths significantly increase the legibility of text." Web Style Guide – Basic Design Principles for Creating Website Patrick J. Lynch and Sarah Horton 2nd edition, page 97. On Mon, Oct 29, 2012 at 10:37 AM, Jake McArthur wrote: > I stick to 80 columns fairly rigidly. This is not only so that it fits > into narrow windows, but also so that any two subexpressions in the > same expression tend to be close together on my screen, which makes it > easier for me to reason about it. If only it was easy for me to read > and write code on a Hilbert curve... :) > > I don't think long lines indicate a design problem; it's solely a > formatting thing. > > On Mon, Oct 29, 2012 at 7:50 AM, Rustom Mody wrote: >> There was a recent discussion on the python list regarding maximum line >> length. >> It occured to me that beautiful haskell programs tend to be plump (ie have >> long lines) compared to other languages whose programs are 'skinnier'. >> My thoughts on this are at >> http://blog.languager.org/2012/10/layout-imperative-in-functional.html. >> >> Are there more striking examples than the lexer from the standard prelude? >> [Or any other thoughts/opinions :-) ] >> >> Thanks, >> Rusi >> >> >> >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I would prefer to completely ignore line lengths when writing Haskell. In general, giving good names to things in where-clauses automatically keeps my code "short enough". My opinion is that different people like different code layouts, and when formatting code in certain ways, we will always have to make compromises. I would like if there was a layout normal form for storing Haskell code - all code presented to humans should be shown just as that human likes it best. In the future, I would like to work on a personalizable real-time formatter that editors can hook into, using haskell-src-exts. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 03:50:57PM +, Niklas Hambüchen wrote: > I would prefer to completely ignore line lengths when writing Haskell. > > In general, giving good names to things in where-clauses automatically > keeps my code "short enough". > > My opinion is that different people like different code layouts, and > when formatting code in certain ways, we will always have to make > compromises. > > I would like if there was a layout normal form for storing Haskell code > - all code presented to humans should be shown just as that human likes > it best. > > In the future, I would like to work on a personalizable real-time > formatter that editors can hook into, using haskell-src-exts. +1 to that; I know that it would indeed increase my productivity… iustin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 7:58 PM, Alexander Solla wrote: > > > On Mon, Oct 29, 2012 at 6:52 AM, Michael Orlitzky wrote: > >> On 10/29/2012 07:50 AM, Rustom Mody wrote: >> > There was a recent discussion on the python list regarding maximum line >> > length. >> > It occured to me that beautiful haskell programs tend to be plump (ie >> > have long lines) compared to other languages whose programs are >> 'skinnier'. >> > My thoughts on this are at >> > http://blog.languager.org/2012/10/layout-imperative-in-functional.html. >> > >> > Are there more striking examples than the lexer from the standard >> prelude? >> > [Or any other thoughts/opinions :-) ] >> >> In any language, a line longer than 80 characters usually (but not >> always) suggests that you might want to stop and rethink your design. In >> many cases a refactoring or two will greatly simplify the code and >> reduce your line length as a result. > > > I disagree. That might be true for imperative languages, where width is > indicative of deep nesting and its associated problems. But it is not true > for a functional language, where it is merely indicative of a wide "normal > form". Yes, the normal form can sometimes be refactored, but to what end? > You might easily end up refactoring out of the level of abstraction you > actually want. Or the wide form might have useful properties, like the > ability to sort the lines of source code alphanumerically (which would be > lost if you switched to a stanza-based format) > > > Interesting points. In fact my wish for using (when appropriate) a wide form is related to some hunch about this 'wide normal form' Can you throw some light on how one may understand that phraset? Also BTW Ive cleaned up the post again. Since my ineptitude with blogger was looking like an ineptitude with haskell (which may well be there and more :-) ) Ive moved the wide code to gist. I believe the code examples speak differently in this new format Rusi -- http://blog.languager.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
O_o Those are damn strange reasons to restrict oneself to 80 chars, iMho. I tend to look at ONE file at a time, on one fullscreen widescreen. 100 chars per line is more or less normal; I have my vertical line limit marker set to 100, but only for layout-zen. My lines have sometimes 200 chars length, which causes the less important (long) code not to clutter my overview on the >50 neighbouring lines (~10 functions overview on the left half of the screen). Otherwise, I'd use a browser/Haddock on one part of the screen just to see an overview of the code I'm writing. I'm now wondering, whether this could have sth to do with my ADD, which I had the first 3 decades of my life (and without whiteboard). I think, I should try to code in a small narrow window of 1/4 of my screen, just to test whether that would (still) be a handicap. Roman: "academic background"... Funny; my impression about this matter was from the other point of view: Short lines are good for diff/patch files. Are there more people here with ADD (or ADD-history) and long-lines-disorder? Or is that just me? - marc Original-Nachricht > Datum: Mon, 29 Oct 2012 11:32:29 -0400 > Von: MightyByte > An: Jake McArthur > CC: Haskell Cafe > Betreff: Re: [Haskell-cafe] Optimal line length for haskell > I also stick to a pretty rigid 78 characters. Doing so actually helps > me fit more code onto my screen at a time because I usually have two > or three columns of open files side by side. I find that I need this > more often than I need to see a single function on a page (thanks to > Haskell's traditionally small functions). But this works for single > functions as well because I can open the same file in multiple columns > at different locations in the file. > > "The ideal line length for text layout is based on the physiology of > the human eye… At normal reading distance the arc of the visual field > is only a few inches – about the width of a well-designed column of > text, or about 12 words per line. Research shows that reading slows > and retention rates fall as line length begins to exceed the ideal > width, because the reader then needs to use the muscles of the eye and > neck to track from the end of one line to the beginning of the next > line. If the eye must traverse great distances on the page, the reader > is easily lost and must hunt for the beginning of the next line. > Quantitative studies show that moderate line lengths significantly > increase the legibility of text." > Web Style Guide – Basic Design Principles for Creating Website > Patrick J. Lynch and Sarah Horton > 2nd edition, page 97. > > On Mon, Oct 29, 2012 at 10:37 AM, Jake McArthur > wrote: > > I stick to 80 columns fairly rigidly. This is not only so that it fits > > into narrow windows, but also so that any two subexpressions in the > > same expression tend to be close together on my screen, which makes it > > easier for me to reason about it. If only it was easy for me to read > > and write code on a Hilbert curve... :) > > > > I don't think long lines indicate a design problem; it's solely a > > formatting thing. > > > > On Mon, Oct 29, 2012 at 7:50 AM, Rustom Mody > wrote: > >> There was a recent discussion on the python list regarding maximum line > >> length. > >> It occured to me that beautiful haskell programs tend to be plump (ie > have > >> long lines) compared to other languages whose programs are 'skinnier'. > >> My thoughts on this are at > >> http://blog.languager.org/2012/10/layout-imperative-in-functional.html. > >> > >> Are there more striking examples than the lexer from the standard > prelude? > >> [Or any other thoughts/opinions :-) ] > >> > >> Thanks, > >> Rusi > >> > >> > >> > >> > >> ___ > >> Haskell-Cafe mailing list > >> Haskell-Cafe@haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > >> > > > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments (in deutsch: http://www.gerstbach.at/2004/ascii/) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I frequently find myself wanting to look at one file while coding in another file so I can see type signatures, data type definitions, etc. If I only have one file fullscreen, then I would have to switch back and forth to refresh my mind with API information. If your max lines are sometimes 200 chars, then you're going to have tons of wasted screen space from all the other lines that aren't 200 characters wide. On Mon, Oct 29, 2012 at 4:44 PM, Marc Ziegert wrote: > O_o > Those are damn strange reasons to restrict oneself to 80 chars, iMho. > > I tend to look at ONE file at a time, on one fullscreen widescreen. > 100 chars per line is more or less normal; I have my vertical line limit > marker set to 100, but only for layout-zen. My lines have sometimes 200 chars > length, which causes the less important (long) code not to clutter my > overview on the >50 neighbouring lines (~10 functions overview on the left > half of the screen). Otherwise, I'd use a browser/Haddock on one part of the > screen just to see an overview of the code I'm writing. > > I'm now wondering, whether this could have sth to do with my ADD, which I had > the first 3 decades of my life (and without whiteboard). I think, I should > try to code in a small narrow window of 1/4 of my screen, just to test > whether that would (still) be a handicap. > > Roman: "academic background"... Funny; my impression about this matter was > from the other point of view: Short lines are good for diff/patch files. > > > Are there more people here with ADD (or ADD-history) and long-lines-disorder? > Or is that just me? > > > - marc > > > > > > Original-Nachricht ---- >> Datum: Mon, 29 Oct 2012 11:32:29 -0400 >> Von: MightyByte >> An: Jake McArthur >> CC: Haskell Cafe >> Betreff: Re: [Haskell-cafe] Optimal line length for haskell > >> I also stick to a pretty rigid 78 characters. Doing so actually helps >> me fit more code onto my screen at a time because I usually have two >> or three columns of open files side by side. I find that I need this >> more often than I need to see a single function on a page (thanks to >> Haskell's traditionally small functions). But this works for single >> functions as well because I can open the same file in multiple columns >> at different locations in the file. >> >> "The ideal line length for text layout is based on the physiology of >> the human eye… At normal reading distance the arc of the visual field >> is only a few inches – about the width of a well-designed column of >> text, or about 12 words per line. Research shows that reading slows >> and retention rates fall as line length begins to exceed the ideal >> width, because the reader then needs to use the muscles of the eye and >> neck to track from the end of one line to the beginning of the next >> line. If the eye must traverse great distances on the page, the reader >> is easily lost and must hunt for the beginning of the next line. >> Quantitative studies show that moderate line lengths significantly >> increase the legibility of text." >> Web Style Guide – Basic Design Principles for Creating Website >> Patrick J. Lynch and Sarah Horton >> 2nd edition, page 97. >> >> On Mon, Oct 29, 2012 at 10:37 AM, Jake McArthur >> wrote: >> > I stick to 80 columns fairly rigidly. This is not only so that it fits >> > into narrow windows, but also so that any two subexpressions in the >> > same expression tend to be close together on my screen, which makes it >> > easier for me to reason about it. If only it was easy for me to read >> > and write code on a Hilbert curve... :) >> > >> > I don't think long lines indicate a design problem; it's solely a >> > formatting thing. >> > >> > On Mon, Oct 29, 2012 at 7:50 AM, Rustom Mody >> wrote: >> >> There was a recent discussion on the python list regarding maximum line >> >> length. >> >> It occured to me that beautiful haskell programs tend to be plump (ie >> have >> >> long lines) compared to other languages whose programs are 'skinnier'. >> >> My thoughts on this are at >> >> http://blog.languager.org/2012/10/layout-imperative-in-functional.html. >> >> >> >> Are there more striking examples than the lexer from the standard >> prelude? >> >> [Or any other thoughts/opinions :-) ] >> >> >> >> Thanks, >> >> Rusi >> >> >> >> >> >> >> >> >> >&g
Re: [Haskell-cafe] Optimal line length for haskell
On 30/10/2012, at 3:28 AM, Alexander Solla wrote: > On Mon, Oct 29, 2012 at 6:52 AM, Michael Orlitzky > wrote: > In any language, a line longer than 80 characters usually (but not > always) suggests that you might want to stop and rethink your design. In > many cases a refactoring or two will greatly simplify the code and > reduce your line length as a result. > > I disagree. That might be true for imperative languages, where width is > indicative of deep nesting and its associated problems. But it is not true > for a functional language, where it is merely indicative of a wide "normal > form". Yes, the normal form can sometimes be refactored, but to what end? Better code? I have no idea of what "a wide normal form" might be, and less idea of why that would imply that a narrower and better form does not also exist. We can argue till everyone is sick and tired and still not reach any kind of consensus. Let's have some *examples*. (For the record, the longest line lengths I've ever seen have been in C++ and Java. I know someone who, and I am not kidding, thinks a 390- column line in code intended to be read by other people is OK.) My own perspective is that if I can't fit it onto one slide in large type for my students to see it is too big. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On Mon, Oct 29, 2012 at 4:09 PM, Richard O'Keefe wrote: > > On 30/10/2012, at 3:28 AM, Alexander Solla wrote: > > On Mon, Oct 29, 2012 at 6:52 AM, Michael Orlitzky > wrote: > > In any language, a line longer than 80 characters usually (but not > > always) suggests that you might want to stop and rethink your design. In > > many cases a refactoring or two will greatly simplify the code and > > reduce your line length as a result. > > > > I disagree. That might be true for imperative languages, where width is > indicative of deep nesting and its associated problems. But it is not true > for a functional language, where it is merely indicative of a wide "normal > form". Yes, the normal form can sometimes be refactored, but to what end? > > Better code? I have no idea of what "a wide normal form" might be, and > less > idea of why that would imply that a narrower and better form does not also > exist. I made no implication that narrower forms are not useful, or even better, given that the structure is not incompatible with the syntax used to implement it. (For example, I would much rather [1,2,3,4,5] over > [1 > ,2 > ,3 > ,4 > ,5 > ] but would likely prefer > [ "alpha" > , "beta" .. > , "omega" > ] over the alternative. For example, I generally prefer using the combinators directly when dealing with functors, applicatives, and monads. This can be written "wide", but it can also be written in the style of: > f' = f <$> (a >>= g) ><*> (b >>= h) ><*> (c >>= i >>= k) That is perfectly sensible. But if I had to repeat this syntactic construct, I would probably do it wide: > f' = f <$> (a >>= g) <*> (b >>= h) <*> (c >>= i >>= k) > g' = g <$> (d >>= g) <*> (e >>= h) <*> (f >>= i >>= k) The new row exposes a sort of "tabular" structure. This code is easy to edit, all at once, highlights differences, and exposes similarities that might be hidden if written in stanza format and have enough "rows" in that format. Of course, a "normal form" merely a combinator, or rather, its definiens. So one might ask, why not factor this out into a combinator? That might well be appropriate, or it might not. Either way, your program end up with a table for values which may vary (since, presumably, the definitions of f' and g' witness that you want to define f' and g'.), as in: > f' = comb f a b c > g' = comb g d e f This cannot be made any narrower (up to naming). We can call a normal form n-wide if its combinator requires n arguments. How many combinators do we really want? A combinator is what it will take to factor the "wideness" out of a tabular form, and all you get is a maybe narrower tabular form. My own perspective is that if I can't fit it onto one slide in large > type for my students to see it is too big. > This is fair enough, but there are some types of extremely uninteresting code that don't go on slides and are naturally expressed as extremely wide tables. Typically, it is data for use by the program -- the stuff the program traverses to output its answer. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
On 30/10/2012, at 5:56 PM, Alexander Solla wrote: > For example, I generally prefer using the combinators directly when dealing > with functors, applicatives, and monads. This can be written "wide", but it > can also be written in the style of: > > > f' = f <$> (a >>= g) > ><*> (b >>= h) > ><*> (c >>= i >>= k) > > That is perfectly sensible. But if I had to repeat this syntactic construct, > I would probably do it wide: > > > f' = f <$> (a >>= g) <*> (b >>= h) <*> (c >>= i >>= k) > > g' = g <$> (d >>= g) <*> (e >>= h) <*> (f >>= i >>= k) 021346789021346789021346789021346789021346789021346789 > > The new row exposes a sort of "tabular" structure. The trouble is that this is not real code. As it stands, nobody is complaining about this example. It fits well into 65 columns, being 60 columns wide. I really would like to see real examples. I found the lines of the SegmentTree code that was mentioned recently to be too long for comfort. Line wrapping in TextEdit (or for that matter Emacs) takes no heed whatever of Haskell syntax. I also found that the lines could very easily have been broken in quite natural places.fine f' and g'.), as in: > > > f' = comb f a b c > > g' = comb g d e f > > This cannot be made any narrower (up to naming). Yes, it can. f' = comb f a b c g' = comb g d e f There's an indentation meta-rule that I am very fond of: Where a line is *broken* depends on the spelling of names; where a line is *indented* depends only on logical structure. > We can call a normal form n-wide if its combinator requires n arguments. And they can each go on a separate line if need be. > > This is fair enough, but there are some types of extremely uninteresting code > that don't go on slides and are naturally expressed as extremely wide tables. > Typically, it is data for use by the program -- the stuff the program > traverses to output its answer. I have nothing to say about machine-generated code (and if it's _that_ uninteresting, and _that_ naturally expressed by extremely wide tables, then let's hope no human had to suffer to create it). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I wonder if people who like one giant window maybe don't use the REPL? I keep 3 windows open: one with the editor, one with ghci, and one with a shell. The shell I use for compiles, darcs records, diffs, grepping, moving files around, etc. I don't understand how people are able work with fewer... it's awkward to constantly ^Z out of the editor, not to mention that you can't look at a diff, test output, compiler output, etc. and code at the same time. With the REPL I'm constantly jumping back and forth to fix type errors, test functions, etc. Since I have 3 terminals that basically means a strict 80 columns on all but the widest monitors, but it's never a problem. Just define more small functions. Breaking them up keeps the nesting down, gives names to to sections, gives me something to test from the REPL, and ensures there are regularly spaced toplevel type signatures, so a type error doesn't propagate too far through inference. I've tried with >3 terminals but I can never figure out what to do with the extra ones. Now that I think of it, it would be interesting to slave two vims together so the secondary one is always the % buffer. Then I don't worry about who is opened where but can still swap between current and last used quickly. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
Evan Laforge wrote: >I wonder if people who like one giant window maybe don't use the REPL? > I keep 3 windows open: one with the editor, one with ghci, and one >with a shell. [...] >I've tried with >3 terminals but I can never figure out what to do >with the extra ones. Besides your two shells, I tend to have a documentation browser should I be using a library I'm not familiar with, and (once the project gets large enough) a second editor window for files with code that might interact with the code I'm working on. Of course, in an IDE (I use emacs), all of these things tend to be available as panes in one window. -- Sent from my Android tablet with K-9 Mail. Please excuse my swyping. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
2012/10/29 MightyByte : > "The ideal line length for text layout is based on the physiology of > the human eye… At normal reading distance the arc of the visual field > is only a few inches – about the width of a well-designed column of > text, or about 12 words per line. Research shows that reading slows > and retention rates fall as line length begins to exceed the ideal > width, because the reader then needs to use the muscles of the eye and > neck to track from the end of one line to the beginning of the next > line. If the eye must traverse great distances on the page, the reader > is easily lost and must hunt for the beginning of the next line. > Quantitative studies show that moderate line lengths significantly > increase the legibility of text." > Web Style Guide – Basic Design Principles for Creating Website > Patrick J. Lynch and Sarah Horton > 2nd edition, page 97. Robert Bringhurst's "The Elements of Typographic Style" offers a similar dictum: Anything from 45 to 75 characters is widely regarded as a satisfactory length of line for a single-column page set in a serifed text face in a text size. The 66-character line (counting both letters and spaces) is widely regarded as ideal. For multiple column work, a better average is 40 to 50 characters. -- http://webtypography.net/Rhythm_and_Proportion/Horizontal_Motion/2.1.2/ I have come to accept 80 characters as a limit that is both in keeping with programming convention and amenable to the good taste of typographers. Many respectable software projects honor this limit and to emulate them, in matters small as well as large, is to simplify our work in many small ways. Art is long and life is short. -- Jason Dusek pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe