Is the 80 Columns Limit Dead?
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?"
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....
Why would vi have any problem with long lines?
when printing a monospace 12 point font on a piece of paper.
The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
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 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 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 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, of course.
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.
With most people using X
The proper technology name is ActiveX.
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.
"You might as well get your son a ticket to hell as give him a five string banjo." -unknown minister
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.
;), but sticking to 80 characters is truly limiting, especially these days when everyone has screens and editors that are capable of so much more.
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
(Spudley Strikes Again!)
...Hollerith cards
If we don't format our code to 80 columns, then how will we maintain back-compatibility with IBM punch cards?!
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!
"Can of worms? The can is open... the worms are everywhere."
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
We're still suffering from the days of card readers and punches.
I've not punched a card since 1981. But I've edited lots of MVS (aka OS/390 aka z/OS) datasets that are fixed to 80 bytes (sequence in 73-80) by the architecture.
Sigs. We don't need no steenking sigs.
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..
Some random "web development" site
Scroll down a bit to get to the chars per line bit
All of these basically agree that more than 80 chars per line is quite hard to read.
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.
May we never see th
The main reason for it is that (a) it lets people with default-width xterms and terminals read your code, and (b) it provides a reasonably universal standard to code around.
80 col seems pretty unused in the Windows world, where most people use that godawful Visual Studio Editor, and conventions are to extend lines to infinity.
80 col is common in the *IX world, where most folks doing a lot of coding are using emacs/xemacs or vi. Space-indented, 80 col code can be read by pretty much anyone and edited by anything, so it's a reasonably universal standard to base code on.
Some projects deviate from this -- it's considered good open source etiquette to stick with the format already being used in the file that you're hacking on, instead of mixing things up.
That being said, I rather like the idea of python's approach (where how the user chooses to view code, wrapped or scrolling, is independent of the storage format).
May we never see th
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.
*sigh* back to work...
You should try Donald Knuth's CWEB environment. It combines coding and
m l
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.ht
*sigh* back to work...
It's well known that the saying "80 column mind" means that you're narrow minded. Google it. :)
Or if you write a lot of Fortran77 code (common in engineering).
WeRelate.org - wiki-based genealogy
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.
You might be interested in the Unix commands "expand" and "unexpand".
:w
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.
Software should be free as in speech, but if we also get some free beer, all the better.
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 indents and you want to be able to indent 5 levels comfortably (usually I have found that more than five levels means something is wrong with the code). That is 105 chars per line.
Fortran95 for example will only swallow upto 132 chars per line. So I could see a few lines hanging out there at a hundred-something. In practice (perl and fortran95), I have never felt the need to go over 132 characters in a line...
It is not up to HTML to tell you how to display the information per say. With a comfortably sized browser window everything should wrap.
72 column is required in most COBOL environments I've worked in. *shudders*
Actually, I should put COBOl experience on my resume, I could probably score a really badass job with that. All of the old COBOL hackers are dying. Someone has to port that legacy code eventually.
"Why do you consent to live in ignorance and fear?" - Bad Religion
Except that you can't send the diffs to another person, attach them to bug reports, etc.
And some more reasons not to do automatic reformatting:
- formatters can't fix aything non-syntax related, like strange variable naming conventions.
- reformatting makes your environment completely different from everyone else's (including your coworkers and customers). Eg: stack traces you get on one machine are completely different compared to the ones you get.
Having a code convention (and sticking to it) makes everyone's life easier in the long run.
-- "So, what's the deal with Auntie Gerschwitz et all?"
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.