Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming Technology

Is the 80 Columns Limit Dead? 317

Dancing Primate asks: "Reading through the code of co-workers and various open source projects, I'm finding that people are no longer formatting their code to 80 columns. With most people using X and the wide range of non-vi editors, is the 80 column limitation disappearing? Am I the only one who gets grumpy when I do a diff or print code, and it's hard to read?"
This discussion has been archived. No new comments can be posted.

Is the 80 Columns Limit Dead?

Comments Filter:
  • U of Toronto (Score:4, Interesting)

    by beyonddeath ( 592751 ) on Friday August 06, 2004 @06:58PM (#9904380)
    I know in a lot of my coding classes at U of T they required no more than 80 characters on a line, lest you get some hefty mark deductions. I dont stick to it for my stuff tho i usually limit it to when my screen starts scrolling to the right....
    • Re:U of Toronto (Score:3, Informative)

      by saden1 ( 581102 )
      The current project I’m working on has set 120 columns as standard acceptable column width. This is of course the maximum characters you can print on an A4 paper in landscape layout.

      We have 21" monitors and should and high resolution these days so I see no reason to stick with 80 columns.
      • Re:U of Toronto (Score:4, Interesting)

        by Dan Ost ( 415913 ) on Friday August 06, 2004 @09:39PM (#9905732)
        I generally limit my own code to 72 columns so that when I print 2 columns
        in landscape mode with line numbers, there is no wrapping and enough white
        space to the right of the code to make notes and such.

        One of my beefs with Java is that it seems impossible to write comfortable code
        in less than 120 columns.
        • Re:U of Toronto (Score:3, Insightful)

          by julesh ( 229690 )
          One of my beefs with Java is that it seems impossible to write comfortable code
          in less than 120 columns.


          I see no reason why you should have a problem with that. I write Java in my job, and rarely exceed my editor window's default width, which is 94 columns. Are you using 8 column indents, by any chance?
  • huh? (Score:3, Insightful)

    by reynaert ( 264437 ) on Friday August 06, 2004 @06:59PM (#9904386)
    Why would vi have any problem with long lines?
    • Re:huh? (Score:4, Informative)

      by Rheingold ( 2741 ) <wcooley@@@nakedape...cc> on Friday August 06, 2004 @07:07PM (#9904476) Homepage
      You obviously haven't used the stock vi in Solaris recently...
      Terminal too wide
  • yes it does (Score:3, Insightful)

    by jeffy124 ( 453342 ) on Friday August 06, 2004 @07:01PM (#9904413) Homepage Journal
    when printing a monospace 12 point font on a piece of paper.
    • Why are you printing code in 12 point font?! You can buy reading glasses in any pharmacy/ convenience store for a few bucks, btw.
      • Re:yes it does (Score:3, Insightful)

        by Mr. Slippery ( 47854 )
        Why are you printing code in 12 point font?! You can buy reading glasses in any pharmacy/ convenience store for a few bucks, btw.

        If you print and display at a decent size, you won't end up needing reading glasses...

        Don't strain your eyes - you only get one pair.

  • The Way of the World (Score:5, Informative)

    by Jason Scott ( 18815 ) on Friday August 06, 2004 @07:03PM (#9904433) Homepage
    As the administrator of TEXTFILES.COM, I can attest that it is certainly the case that modern writers who submit me works for the uploads [textfiles.com] section generally pay little or no attention to formatting along any given column length. Keep in mind that I always ask for these submissions in ASCII form, so this isn't the result of converting over from Word or StarOffice.

    I think the reason I get files like this one [textfiles.com] is that people just let notepad and similar programs do the wrap for them. The fact that web browsers don't always wrap means you get some pretty funky looks.

    This is not 100 percent true, of course: I've gotten submissions [textfiles.com] just this year that keep to the 80 column limit and include formatting taking advantage of it.

    But on the whole, I think it's just that people no longer think of the world as sized in 80 columns, and we might as well understand that's the case. My heart will always be for the way it used to be [textfiles.com], of course.
    • As far as text documents go I find text to be easier to read when people don't assume a certain display width. I commonly have several applications open and very little screen space left for my notepad text window.

      I think people replying to emails with a cutoff of 40-80 characters can be really difficult to read since I usually use a large window to read their emails and that sometimes leaves a whole 2/3rds of the window blank.

      Source code should have reasonable but flexible limits. A width of 80 sounds lo
  • I don't get it (Score:5, Interesting)

    by Dixie_Flatline ( 5077 ) * <<moc.liamg> <ta> <hog.naj.tnecniv>> on Friday August 06, 2004 @07:05PM (#9904458) Homepage
    Because of the way that people name their methods and variables now (int IHaveToDoABunchOfNiftyStuffHere( INT nThisIsAReallyImportantInt ) ) 80 columns isn't particularily feasible. That said, I don't understand why people don't just standardize on a column width and stick with it. When I first started working here, I tried to work within 80 columns, but my coworkers hated it when I reformatted their code, and I hated it when they touched mine. Now I format to 132 columns, and nobody really notices when I reformat their code to fit.

    All the important stuff happens at the END of the line. It's where the actual methods get called and the work gets done. Seeing the beginning the line is usually entirely meaningless, and I hate scrolling to have to see the end of the line at 160 characters. I've already got my hands on the keyboard, and the mouse isn't a tool that I can use to input code, so it's just a waste of my time to put my hand on it. Most editors even indent and format the code pretty nicely if you manually break the line in a language like C or C++ which don't care about whitespace.

    It doesn't really matter what the column width is as long as
    1) Everyone sticks to it
    2) You don't have to scroll to see the end of the line.
    • Re:I don't get it (Score:3, Interesting)

      I guess that's part of the reason some of the newer languages out there (Perl, Python, Ruby) allow post-conditionals.

      die("The meat of the statement is at the front of the line") if Language.supports("post-conditionals");

      • Re:I don't get it (Score:3, Insightful)

        by E_elven ( 600520 )
        Your example may not be the best. It's usually really important to know what the hell the condition is. That's why it's generally a good idea to:

        if something
        x
        else
        y
        end

        That being said, postconditionals make the code flow much better and are excellent for short single choices (i.e. just an if, not an if-else).
      • Re:I don't get it (Score:3, Informative)

        by Scarblac ( 122480 )

        Perl does that, Python doesn't. I don't know about Ruby.

        And Perl does it because those guys like giving you many options, it doesn't mean that actually using that is a good idea. Perl contains lots of possibilities that in 99% of the cases are a bad idea to use.

    • Re:I don't get it (Score:2, Insightful)

      by hotpotato ( 569630 )
      It doesn't really matter what the column width is as long as
      1) Everyone sticks to it
      2) You don't have to scroll to see the end of the line.

      I disagree. Reading short lines is less tiresome than reading long lines. This is the reason why most newspapers use rather narrow columns in print.

      When lines are logically longer than 80 chars, I use line breaks to make them fit.. not too difficult, and I find that several short lines of method calls are much easier to read than a single long line.

      • Re:I don't get it (Score:3, Insightful)

        by __david__ ( 45671 ) *
        This is true for english prose, but is *not* the case with code. Having all the code on one line is usually more readable even if the line is very long. This is easy to prove, just try it.

        Having lines that are long is especially useful when you have some sort of repeating pattern that makes a nice column down the screen (either very similar code or a data structure). Wrapping lines in this case royally screws the readability.

        -David
  • 80 columns died when they came out with 132 column printers. Where have you been?

    No seriously on Linux use svgatextmode if you can or a framebuffer driver and try to expand the columns on your screen. Or just use X / windows elsewhere.

    80 columns is thought of as old.

    • Really? Then how to you recommend people still using vt100 terminals cope?

      What about people using PDA or cellphone-based ssh
      clients?

      slrn? Mutt?

      My Apple //e and I spit at you.

      I generally find those who advocate ditching the 80-column standard are the same ones who have no problem with HTML-ized email.

      Bah. Feh.
    • Re:um news flash (Score:3, Insightful)

      by 0x0d0a ( 568518 )
      The advantage of using 80 columns is that you can have multiple source lines on screen.

      At 1152x864, you can slap four xterms with the default fixed 9 font onscreen, and refer easily to headers and other code.

      I view X as particularly useful because I can *have* four terminals onscreen at once, though I can make any bigger if I feel like it or my eyes are tired.
      • This is very true. At 1024x768 resolution, two xterms 56x80 fit neatly side by
        side on my laptop. I run at a higher resolution on my workstation and will
        lengthen my xterms, but I like to stick to 80 or 88 columns wide. I've tried
        coding in 132 columns, but find that long lines are unwieldy to read and write.
  • Error (Score:4, Funny)

    by Anonymous Coward on Friday August 06, 2004 @07:12PM (#9904525)
    With most people using X

    The proper technology name is ActiveX.
  • 80 columns lives (Score:3, Informative)

    by bandy ( 99800 ) <andrew.beals+slashdot@gmail.com> on Friday August 06, 2004 @07:14PM (#9904546) Homepage Journal
    80 columns is still the default width of an xterm and Gnome Terminal window. Grumpy cow-orkers insist on sticking to 80 columns. It's a fact of life. Get used to it.
    • Thats exactly what I was going to point out. All my xterms are 80 columns, likewise with my NEdit window. My console runs a framebuffer at 1280x1024 and will do twice that.
  • Printing wide code can be annoying - although if the printout showed when lines wrapped with the down-then-left arrow common in some editors... that would make life easier.

    But it's not as annoying as printing the output from SQL statements in M$ Query Analizer... especially when there is a text(16) field in the output that needs analising!
  • by Spudley ( 171066 ) on Friday August 06, 2004 @07:19PM (#9904594) Homepage Journal
    You've only just noticed, eh? Methinks you've had your head stuck in the sands of the character-based terminal a bit too long.

    The only reason I can think of to keep using 80 character lines now is if you're writing in COBOL (which forces the issue). For anything else, you can either write your lines as long as you need them (if you're programming), or you turn on word-wrap (if you're doing anything else).

    When I say 'as long as you need them', that isn't an invitation to write programs with 700-character lines; I mean, there's still a requirement for a degree of common sense, even for programmers ;), but sticking to 80 characters is truly limiting, especially these days when everyone has screens and editors that are capable of so much more.
    • When I say 'as long as you need them', that isn't an invitation to write programs with 700-character lines; ...

      Oh, I dunno. Some years back, a particularly obnoxious programmer on the team produced a ridiculously-long routine to do a certain task. I opined that I could do it in a lot less code. His response was something sarcastic along the lines of "Oh, yeah; I suppose you could do it in one line of C." I paused a few beats, and said that, yes, I could. He sneered at this, so I offered a wager, whi
    • Use Jedit.

      The line-wrap feature is killer.

      Put line numbers in the giutter

      it prints to printer with line-wrap.

      use code-to-html plugin for pretty web output

      code your code without worrying about all that.

  • by monopole ( 44023 ) on Friday August 06, 2004 @07:20PM (#9904602)
    ...Hollerith cards
  • Well, I guess I came to the party late. I didn't even realize that code used to be formatted to 80 columns!

    I guess that's why most of my old code is impossible to maintain. In search of something better, I switched to Python because of ESR recommendation [linuxjournal.com] and I really, really like it. The forced syntax makes my code a lot more readable. Although I've been struggling to switch my LAMP coding from Linux/Apache/MySQL/PHP to Linux/Apache/MySQL/Python, I'm hoping it will be easier to maintain.

    I think I'll b
  • Never! (Score:5, Funny)

    by Dr. Photo ( 640363 ) on Friday August 06, 2004 @07:21PM (#9904612) Journal
    If we don't format our code to 80 columns, then how will we maintain back-compatibility with IBM punch cards?!
  • by stefanlasiewski ( 63134 ) * <slashdotNO@SPAMstefanco.com> on Friday August 06, 2004 @07:23PM (#9904638) Homepage Journal
    You can violate the 80 column rule any time you want. Just do me one favor-- get rid of the tabs.

    But remember, a 'tab' MUST be equal to 4 spaces or less. Destroy the tab character! Save the whitespace!

    Nothing awakens the Hulk more then looking at code that someone indented with 8 tabs. Yarrrrg!
    • by Tumbleweed ( 3706 ) * on Friday August 06, 2004 @07:33PM (#9904751)
      Okay, Hulk, that's just dumb. You _want_ indentation to be done via tabs - that way everyone can set the tab to _display_ as as many characters as they want. How many 'spaces' (equivalent) a tab displays should be up to your text editor of choice. The original author can display their tab characters as equivalent to 8 or whatever, and you can view it as 4 or whatever. That's the genius of using tabs for indentation.
      • Ok, you're right. I think I actually just want consistant tabs... it's been a long week.

        I was just trying to find a bug in some code written by a number of different authors: One guy used tabs, one used sets of 4 spaces, one guy used sets of 2 spaces... and of course, 8 indents means 8 nested statements. it's easy to get lost in there.

        • Yuck!

          Yeah, that would involve a series of search & replaces just to get it to the point of readability. There might be some programs out that that fix formatting problems like that for you; certainly worth looking for.
      • No.

        This would be true in a system without hard line breaks. In a hard-line-broken environment, be it 80 col, 120 col, 132 col, or whatever.

        However, if you start changing tab width around, consistent line length goes to hell (not bad if you're shortening tabs, but if you lengthen them, you have a bunch of lines that are badly broken).

        This is a long, long debate.
        • Tab size has nothing to do with how a line is broken, though. A tab is a character only - how it's displayed is up to the application. How word wrapping is handled is also up to the application. If your application doesn't let you configure both of those things to your liking, then you're using the wrong application.
      • by mellon ( 7048 ) * on Friday August 06, 2004 @09:15PM (#9905570) Homepage
        Right, what happens if you do this is that the bozo that has tabs=4 sometimes uses tabs and sometimes uses spaces, and then when you try to load it into an editor with 8-character tabs, the indentation is all screwy. Whereas if everybody uses 8-character tabs, which is the usual meaning of ascii character number 9, then this never happens.

        The bottom line, though, is that this is a religious war, and as the person who's currently at the top of the list said, it's better for a team to just agree on what the indentation style is going to be, and stick with it. Otherwise you wind up with non-terminating flame wars (or terminated team members).
        • If everyone is going to agree on something, then agree on using tabs and not multiple spaces. Then everyone can view at whatever indentation they want and not screw anyone else over.
          • You _can't_ agree on tabs and not spaces, because there is no way to look at a piece of text and see that there are no spaces. Believe me, I've tried working with people who think that this isn't a problem, and it quickly becomes one. Editors will insert spaces for you instead of tabs, so even if you never hit the space bar, there's still no guarantee of anything. The only way you can have visual consistency between users is to agree on what width a tab has.
            • > Editors will insert spaces for you instead of tabs

              Only if they're crappy, and aren't configurable, or if they're misconfigured. If you can get everyone to agree on a 'tab width,' then you can get everyone to agree on using tabs for indentation. Then it's just a matter of using a decent text editor to let you display those tabs however you wish. Getting people to agree on using tabs consistently should be easier than getting people to agree on using a specific 'width.'
            • > there is no way to look at a piece of text and see that there are no spaces

              Oh yeah, forgot this bit of nonsense. This is also either a case of not knowing what your text editor can do, or of using a _really_ crappy text editor. Your text editor should have a mode where you can display spaces & such, and you can _very_ easily tell the difference between spaces and tabs.

              That this conversation is evening happening is amazing to me - how can so many people not know about the tab issue by now? How are
          • The problem with tabs is getting things to align neatly, particularly for functions and such. I like to align my function arguments (if need be):
            some_function(parm,
            other_parm,
            one_more_parm);
            Hard to do with tabs unless you mess with the whitespace around the parentheses which isn't a good idea.
      • Um, no: http://www.jwz.org/doc/tabs-vs-spaces.html
        • Um, yes. The page you quoted explains the situation adequately, then, DESPITE having the solution, advocates doing the exact wrong thing! Fucking amazing how people just don't get this.

          Tabs ARE a character, and should be TREATED as a character (since they ARE). Therefore, the emacs way is fucking idiotic, and the vi way is correct. I've never advocated one over the other for any other reason, until now (I hate the interfaces of both programs, so it didn't matter to me before now; UI-wise, they both suck pr
          • Re:not really (Score:4, Interesting)

            by wotevah ( 620758 ) on Friday August 06, 2004 @11:22PM (#9906336) Journal

            There are a few things in your post that you seem to feel strongly about, which are plainly false or wrong, and which made me think twice about replying. But I'll do it anyway.

            First, the emacs interface is not idiotic. It's not idiot-friendly, I give you that. vi's and emacs' interfaces do not suck. They are however tools meant to increase productivity if you spend the effort to learn them. And they do. If you go by the definition that a good UI is one you can just start using, then they don't have a good UI. Their are powerful tools way beyond joe or pico or whatever it is you consider a good UI that is not "broken".

            TAB is a special character. It is not printable, you need to convert it to a series of spaces to do that. Treating it as a character would mean inserting ONE item in the line, not a variable number depending on your current position.

            Finally, think about it for a moment.
            - A file with space indentation will look the same everywhere.
            - A file with TAB indentation will look good only when your TAB width setting happens to match the author's, so when you open such a file you have to figure that out and change your TAB setting first (which gets old really fast).

            The reason for that is that not all code starts on a TAB boundary, some of them may have a few more spaces (for example where wrapping a function call). Which begins to look nasty when your idea of what a TAB is differs from the author's. And don't say that everyone should use the standard 8-space TAB to fix that problem.

            Lots of programs already use TAB for something else, emacs is not the only one. Bash is another one. Any decent command-line interface now uses TAB for auto-completion. I'm sure there are other examples. If TAB were really a character they would just display it instead, I suppose.

        • Re:not really (Score:3, Informative)

          You might be interested in the Unix commands "expand" and "unexpand".

          :w
    • Learn to configure your favorite editor properly. Or switch to a better editor. I recommend vim.
  • by rossifer ( 581396 ) on Friday August 06, 2004 @07:24PM (#9904646) Journal
    What kills me is how few people realize that code conventions are not for their own personal readability of the code they write. Code conventions are for the benefit of the tens and possibly hundreds of people who are going to be reading the code well after you've moved on to another position.

    Also, for all of the people who assert that their convention (braces on the next line/end of previous line) is scientifically backed to be more readable than the alternative: most of the time, it doesn't matter nearly as much as consistency and being able to have the whole team agree.

    I happen to be the "conventions nazi" in my office (I was also the "unit test nazi" until we bought a tool that did it better than I could). I'm not an asshole about this issue because I'm a control freak, I'm an asshole because conventions really matter to the long term future of the project.

    The right way to be the "conventions nazi" is to get everyone into a room, get everyone to agree that consistency matters more than personal preference, then go down the list of issues and get some consensus (voting works well) on each one. Lone holdouts may need frequent reminding of the "consistency over personal preference" point. Don't leave the room until you have a set of conventions that (1) keep the code consistent in important ways (2) isn't so huge that nobody could hope to remember them and (3) can be easily supported by the tools commonly used by team members.

    Our convention is 132 characters on a line. Inner classes and Java/C++ class/method/variable naming conventions make 80 characters simply impractical. After trying it for a while, there were so many broken lines that the code was simply less readable. So we changed the convention and even though I was for 80 characters, I'm fairly happy with the improved readability of the code.

    Regards,
    Ross
    • As a VB coder who frequently gets lost in his own code while he's writing it, I'd like to assert that my code conventions are for my own personal readablity of the code that I write. If I went much over 60 chars per line, I'd have to scroll all the time to see the stuff that just ran under the File Explorer or the Properties Explorer or the control pallette. My usual response to this is to totally forget what function I was working on, and why.

      Oh, my God, I wish I was joking.
    • If its for the readability of everyone else why not run it through a standard pretty-printer-reformatter thingy on cvs checking and run it through the users own favourite reformatting mode on cvs (or whatever) checkout?

      Sam
      • I've written scripts and/or aliases to do just this on several projects. Somehow, the code-format nazis never seem to appreciate it.

        But it makes a lot of sense to me. Different people have different preferences. Some have poor eyesight or are working on small displays or have to have too many windows open at once, and for them it makes sense to have narrow, vertically-formatted code. OTOH, people always complain about my tiny fonts and wide code, which I do because I find that I can only work on what I
      • If its for the readability of everyone else why not run it through a standard pretty-printer-reformatter thingy on cvs checking and run it through the users own favourite reformatting mode on cvs (or whatever) checkout?

        I've tried that on two occasions in the past and talked to others who have had their own first hand experiences. Invariably, the reformatters tend to handle some conventions better than others and having everyone adjust their editor's settings to the team's conventions is a lot simpler for
      • Because when you format back and forth, you invariably break diffs generated by revision control software.

        Stuff like:

        foo () {
        some really long line
        }

        becomes:

        foo ()
        {
        some
        really
        long
        line
        }

        becomes:

        foo() {
        some really
        long line
        }

        or whatever.

        It's a pain in the arse.
    • I call bull.

      It is well and good to have a sandard format that everyone agrees to read and represents the format in which source code is maintained in the source code repository.

      However, when writing code, it is a real hinderance to be forced to format things in a manner to which one is not accustomed. You spend too much time worrying about how to indent large function call actual parameter lists, long chained pointer indirections (i.e. foo->bar->entryIndex].reference->lookup[lookupInd e x * loo

      • In this day and age there is no reason for someone like you to suffer under a formatting Nazi. Just download a copy of indent or astyle and save yourself a lot of trouble.
      • by ttfkam ( 37064 ) on Friday August 06, 2004 @11:52PM (#9906509) Homepage Journal
        So tell me. How much should I respect you if I am your boss? You've just told me that despite the myriad choices and possibilities available in programming that you cannot adapt to a simple change in bracing style.

        If it takes you more than a week to get accustomed to a new formatting style, you will forgive me if I doubt your ability to adapt to a new compiler or new editor or new operating system or development library.

        And please stop with the strawman of forbidding polymorphism. Yes, there are moronic shops that forbid certain practices that can be instrumental in solving certain problems. But the parent clearly wasn't talking about those instances. This wasn't a discussion of functionality, it was about aesthetics. Deciding about the amount of whitespace, the capitalization patterns, the bracing style, and the line length do not fall under your diatribe.

        And frankly, if you cannot adapt from

        if (1) {
        }

        to

        if (1)
        {
        }

        to

        if ( 1 )
        {
        }

        or from

        write_file()

        to

        writeFile ()

        to

        Write_File( )

        your problems extend far deeper than your code style.

        The question boils down to, "Which formatting style is best?" The answer is simple: "Whatever everyone else on your team is doing." If you cannot adapt to something as simple as this, you cannot be effective in a team. If you cannot be on a team, you are fundamentally useless to 99% of all projects out there. There are better ways to express yourself in code than through bracing style. If formatting style is the best way you can assert your skills and individuality, what does that say about your skills as a programmer overall?

        Have a nice day.
      • The worst part of coding standards is when they are so poorly thought out that they make it impossible or at least very difficult to write certain syntactically-valid programs.

        I agree. To my mind, the only thing worse than no conventions are conventions that get in the way of effective development. Your polymorphism example seems particularly egregious. In order to prevent something similarly annoying, our documentation standard leverages javadoc, which since the 1.2 jdk, allows for the inheritance of
      • "The solution is to use a pretty printer program that is sophisticated enough to understand and generate the source repository form, and automatically reformat to the tastes of most developers."

        Yeah, that works fine except that when translating your crack-induced style to the normal form and back again screws up revision control diffs, thereby making them completely useless.

        Also, your little rant about documentation basically boils down limitations in tools. Javadoc since 1.4 (1.3, maybe) automatically p
    • How about, instead of having standards people code to, have standard formatting tools. When people check out code, they apply their personal formatting, so things look like they want. When people check things in, they apply the group-standard formatting, so everything looks the same.
    • Code conventions are for the benefit of the tens and possibly hundreds of people who are going to be reading the code well after you've moved on to another position.

      And it's even more important if you'd like your code to become the basis of a successful open source project. By "successful," I mean "with code contributed by more than just you." While I think formatting beyond 80 columns reduces readability, there's a lot more to it than that. Everyone in my office adheres to the Indian Hills C Style Gui [chris-lott.org]
  • Here is the realistic situation. 80 columns was created as a formatting standard because of punchcards. Mosto fthe people I know have moved to 120, with the following justifications:

    A) pretty much all editors support more then 80 columns, and if you want to use an old version of VI that can't do mroe then 80, it's not really yopur right to enforce your unwillingness to stick even remotly code to the state of the art on everyone else.

    B) most programmers have a screen roughly in the 1280x1024 category, an
    • Re:we stick to 120 (Score:2, Insightful)

      by ezzzD55J ( 697465 )
      Reasonable, however here is my rationale for wanting to stick to something less with code - you can have 2 files open at the same time, visible next to each other, at the same time, with maximum height.. all screen real estate used. I find this really convenient for having two .c files open, where one is calling the other, or a .c file and a .h file, etc..
  • OK. Problem with 80c is that it makes it hard to indent your code. So the solution is obvious. Eschew the [TAB] key and don't indent your code.

    It's still hard to read, but hey, it'll fit in 80 cols in emacs just fine now.

  • Yeah yeah... this is gonna sound harsh...

    But really... is the 80 column limit that important to you?

    You know that you can bump up the number of columns on console displays, right?

    Read here [linux.com] :)

    There are also a number of tools [faqs.org] available to put code in a form that you find agreeable.
  • People still print code? I gave that up when I got a 17" monitor many years ago and could finally see enough code. Now with my 21" at 1600x1200, I can fit more code on my screen than I can on a page.

    Having said that though, I just started my first project where the 80 columns limit was specified. The customer, who writes some of the code for the project, does still print code. So, I'm finally limiting code to 80 columns.

    • When looking at another programmer's code, it's very convienent to print it,
      write notes, questions, and corrections on it, and then give it to them. If the
      code doesn't print well, then this becomes more difficult to do. If the code
      is unprintable, then you're reduced to writing notes some place else (email?)
      and referencing line numbers which is far less natural than simply writing
      notes beside the code in question.
  • But on a 1200X768 monitor, 80 columns is only about 1/8th of the screen in a readable font- I prefer 132 column limit these days.
  • ...that you're using a monospaced font! Personally, I much prefer to use a proportional font.

    Whoah there, all you folks who are about to reply questioning my eyesight, my coding abilities, or my sanity! Yep, I know what I'm doing. Yep, I've used 'vi' till it's come out of my ears (don't ask), and it's cool for certain types of editing. But I find that monospacing tends to give undue emphasis to small punctuation marks, and generally makes code far harder to read at a glance. I know code doesn't look

    • Re:That assumes... (Score:3, Informative)

      by Dan Ost ( 415913 )
      You should try Donald Knuth's CWEB environment. It combines coding and
      documentation into a single deliverable. I really like some things about
      it (the pretty printing is beautiful), but haven't made it my default yet.
      Warning: requires a little TeX to take full advantage of the documentation aspect.

      Check it out at http://www-cs-faculty.stanford.edu/~knuth/cweb.htm l
  • Readability (Score:5, Informative)

    by rangek ( 16645 ) on Friday August 06, 2004 @08:45PM (#9905327)
    It is well known [sfasu.edu] that beyond a certain width, readability drastically decreases. Here are some more links:

    Some random "web development" site [webstyleguide.com]

    Scroll down a bit to get to the chars per line bit [managedcaremag.com]

    All of these basically agree that more than 80 chars per line is quite hard to read.

    • Why argue when you have this [sourceforge.net]?
    • All of those studies you referred to are speaking of prose. If anything, they speak to having 80 column multi-line comments.

      Show me a study that compares code at 50 columns, 80 columns, 132 columns, and 200 columns and you'll get my full attention.

      Also of note: the first link which advocated shorter line lengths is on a page with unlimited line length.
      • by rangek ( 16645 )

        All of those studies you referred to are speaking of prose. If anything, they speak to having 80 column multi-line comments. Show me a study that compares code at 50 columns, 80 columns, 132 columns, and 200 columns and you'll get my full attention.

        This is true. But the REASON it is easier to read prose is that your eyes don't have to "carriage return" so far after each line. So a line of code really shouldn't be more than 70-80 characters wide for the same reason.

        So lets say you are using 5 space

  • I think this issue is really about how geeks love to create rules for everything and think everyone should follow their lead. Don't we have enough functional bugs in our code to worry about without finding additional ways for code to be defective (layout, column limits, naming conventions, etc.).
  • Using 80 columns is still very important (in my mind at least) when it comes to e-mail. Due to the differences in readers, wrap styles and so on it quickly becomes an issue. When was the last time you got something where the replys quickly screwed up and shattered something readable into a mess of short lines and quoted symbols stuck in the middle of sentences?

    A good e-mail program will properly wrap text to fit within these limits (specifically thunderbird comes set by default to wrap to 72 columns). If p
  • by Polo ( 30659 ) * on Friday August 06, 2004 @10:45PM (#9906109) Homepage
    It's well known that the saying "80 column mind" means that you're narrow minded. Google it. :)

  • by mystran ( 545374 ) on Saturday August 07, 2004 @12:11AM (#9906608)
    The reason why it's good idea to still keep stuff in 80 columns, is that while you CAN fit much more on modern terminals, you might not WANT to. Specifically, I DO format to 80 columns, because that's about as much as fits to my standard ViM window. My resolution is 1280x1024, and I'm using a 8pt font in 96dpi. Oh, and my ViM is fullscreen... The catch is, when the code is split to 80 columns, I can view TWO source files side by side. This also goes with terminals: having two (actually four, one in each "corner") is very nice. So yes, I think that 80 columns per row IS still a good rule.
  • My observations... (Score:3, Insightful)

    by bziman ( 223162 ) on Monday August 09, 2004 @09:52AM (#9919598) Homepage Journal
    What I've noticed, is that the more efficient coders on the team (myself included) need to be able to look at multiple pieces of code and documentation and applications simultaneously. Therefore, we have vi and terminals set up with an 80 character limit, so we can fit two windows side-by-side on the desktop.

    The more brain-dead coders don't realize that they have a windowing environment, and run with all of their windows maximized, preventing them from taking advantage of any of the benefits thereof. They produce bizarre lines that are over 150 characters wide, and they're slower than hell, because they have to cycle through all of their programs to find the docs or the other files they're working on. It's particularly hard for them when they're using a fancy schmancy editor, so they can't even Alt-Tab through their editing windows.

    Maybe I'm old fashioned, but I know what works, and what doesn't. Over many, many years of coding, I've used dozens of IDEs and operating environments, going way back to Borland Turbo C++ for DOS, using Visual C++, and even Eclipse. After many years of experimenting, I've settled on ViM and the command line for most tasks. It's just easier and more efficient for a trained user.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...