37

I like to keep my lines of code under 80 characters because:

  • I don't have to do any horizontal scrolling;
  • I know the line is probably too complicated if it exceeds this limit; and
  • it prints out nicely on paper.

Concerning the latter, I've met only a few who actually print out code to look at (I'm one of them). So how common is it to print out code?

15
  • 2
    I think the question is why do you print out code on paper?
    – Anon.
    Jan 10, 2011 at 20:45
  • 14
    I can't speak for how common it is to print out code, but unless the printer is a relic from a long-forgotten time, it can print out more than 80 characters per line. 80 characters is used to foster readability and historically because many terminals were only 80 columns wide, not because of printers.
    – user8
    Jan 10, 2011 at 20:47
  • 14
    @Mark Actually 80 characters comes from when code was written on punch cards which were 80 characters wide. And the first 6 were for control codes and line numbers. That's why FORTRAN code has to start at column 7.
    – ChrisF
    Jan 10, 2011 at 20:51
  • 3
    @Aaron - that's probably good on Programmers'
    – ChrisF
    Jan 10, 2011 at 20:52
  • 5
    @Aaron - Programmers' is meant for the more subjective (but still constructive) questions that surround our profession.
    – ChrisF
    Jan 10, 2011 at 21:23

30 Answers 30

50

I still very occasionally print out code - but only if it's a particularly knotty problem.

It usually indicates that the code is too complicated and needs refactoring, so in the first instance having something to scribble on helps find and fix the problem and then it helps work out where the code should be split.

In an ideal world of SOLID and DRY principles you should be able to see the whole of a method on a single screen. However, we don't work in an ideal world...

4
  • 4
    +1 for "[needing to look at printed code] usually indicates that the code is too complicated and needs refactoring..."
    – Bill
    Jan 10, 2011 at 23:27
  • It has also worked well to understand race conditions. Print the stack traces and compare them side-by-side, make notes, etc...
    – rperetti
    Jan 11, 2011 at 3:54
  • 4
    @rperetti: Printing things like stack traces is very different than printing code. Don't compare them side by side, though--find a window (the glass type, not the Microsoft type.) Put the two printouts on top of each other on the glass and discrepancies stand out. (Obviously, only in daylight.) Jan 11, 2011 at 4:21
  • 5
    Wouldn't it be easier to just compare them with a diff tool? May 22, 2012 at 15:12
16

You bet. But remember printing in landscape allowed 132 characters.

alt text

At Uni, I used to regularly print my code on green bar paper, it is amazing how well you get a physical sense of how deep and convoluted your code is when you look at it on paper. We're (at least as of today) still mentally imprinted from our Elementary school days on reading pages and how much each page can represent. It puts a good complexity metaphor to computer code.

alt text

0
13

Sometimes I print it to read on the train and make notes. When I get stuck, I like to spread it out over a table in a quiet conference room. Not sure if it really helps, but it's a nice change of pace.

Another One: Found some old code that was a multi-nested If/Then statement that wouldn't fit on the screen. They should have fired the former programmer who wrote that, but then I'd be out of a job ;)

3
  • 4
    +1 for a change of scene. Sometimes just seeing something in a different context makes you think about it differently. Jan 11, 2011 at 9:15
  • 3
    +1 You can put more pages side-by-side on a large conference table than on the computer screen. And you don't get distracted by Twitter or email Aug 28, 2011 at 20:00
  • 1
    If you get distracted by Twitter or email - you are doing it wrong. Email as well as twitter or various other mesengers are asynchronous. You don't need to reply asap.
    – mhr
    Dec 10, 2013 at 13:43
13

occasionally you may need to have a close look at some code (usually new to you) where you essentially need to see a lot at the same time. Then a printout can be invaluable for you to be able to look at the whole thing at one time.

Combined with a highlighter and a red and a green pen it really helps getting the overview. The notes you put down on paper is then later added in some form to the code.

Note, with modern day color printers, you can get syntax colouring on paper too. That is really a great help and is highly recommended.

(I also print out specifications for reading - that is for putting notes in the margin.)

4
  • 9
    +1 When someone hands me a mess to refactor, I usually print it out and go spend some quality time in a nice sunny place.
    – Sharpie
    Jan 10, 2011 at 21:11
  • As a general rule, if the whole module won't fit on one display screen, it probably needs heavy rework. This has been especially true ever since 50-line VGA mode became available, not quite 20 years ago. I've said this before, and I'll say it again: in close to 40 years in this crazy racket, I've seen exactly ONE (1) module that needed to be more than about 60 lines (one printed page) long. (I've seen LOTS of modules that were longer than that, and they all "left a great deal to be desired". (Polite phrase.) Jan 11, 2011 at 5:15
  • @John, why did it need to be longer than 60 lines?
    – user1249
    Jan 11, 2011 at 7:27
  • @user1249: It was the photon torpedo routine from the Matuszek-Reynolds-McGehearty-Cohen "STARTRK" ("Star Trek") game. It was written in FORTRAN IV. It had to parse the command, simulate the flight of either one or three photon torpedoes (possibly aborting if a misfire occurred), with perturbations, AND set up a stack to do 8-way connectivity of stars going nova when torpedo'ed or being adjacent to a star going nova, and killing off any Klingons adjacent to said stars. FORTRAN IV did not do recursion, and there just wasn't any way to factor it that didn't make it worse. Apr 23, 2015 at 19:47
8

I only print out code in order to do a peer review of the code. Doing the review offline is in my opinion more efficient than doing it on a computer with all the disturbing (yet sometimes helpful) IDE stuff.

If you have one (or two or more) reasonably wide monitors, you can easily open two source files vertically split in full screen mode and don't have to obey any too restrictive line-width regulations.

And in some cases, I don't need to see the whole line content (i.e. the lines printing out debug messages or such) and therefore it doesn't matter if the line is chopped on the right.

But to answer your question: in my opinion it's no longer that common to print out code on paper.

0
8

Well I print code on paper infrequently now, but used to do it all the time back in the day.

The usual reasons these days are to sit down somewhere quiet and explain code to a junior, or if a long method is really bugged and needs some very through pen and paper work. Screens do not always suffice, especially when you want notes and highlighting everywhere.

I almost always keep to the 80-character limit, as I'm inclined to make quick amends to bugs via SSH in emergencies and do not like to have wide terminals. Also, horizontal scrolling is the devil.

1
  • 5
    +1 "horizontal scrolling is the devil". I was just telling someone that same exact thing last week.
    – morganpdx
    Jan 10, 2011 at 22:46
8

When I was in my teens attending high school (21 now) I didn't have an internet connection at home. So I would frequently print off code samples and various API documentation to take home with me.

Side note: it's amazing how much more work you can do without an internet connection, provided that you have the information you need already.

6

I never printed my source code. I never had to do that. The only source code I saw outside a computer screen was in books.

I used my printers for something else.

alt text

2
  • 1
    Now I feel old :D
    – wildpeaks
    Jan 10, 2011 at 22:42
  • As a person who was born after this software, that was fun to look up.
    – Naltroc
    Dec 26, 2018 at 15:08
5

I print out code when both of my monitors are filled and I need to constantly reference something. A sheet of paper on the desk is a poor mans additional monitor.

1
  • Put it on monitor #3 then! Mar 16, 2011 at 22:42
4

So how common is it to print out code?

It was common many years ago in the times of the DOS programming, 80 characters were precisely filling a printed page. We had matrix printers then so the limitation was probably on the hardware side. It was also the limit on a console screen.

Nowadays people hardly print code at all, the only exception being little code snippets printed as test examples for job interviews.

People mostly work with large monitors these days, Full HD and more. I typically stretch to 150-200 characters without thinking of any printing side effects.

When it is a time to discuss in a team, somebody usually grabs a laptop and connects it to a projector. Again, nobody prints the code.

Last time I printed code was about 8 years ago for my university diploma which I'm pretty sure nobody read - the code I mean :-). Never had to since.

4
  • It's been eons since I've printed code other than on a web page. I disagree with your line length, though--even if you can get that much on it's hard to follow. I rarely go past about 100 characters and I like to keep it to about 80. Jan 11, 2011 at 4:24
  • @Loren Pechtel: Thing is I like long descriptive names for methods and variables. With only 80 characters-wide I would be struggling to keep it compact and properly formatted. Of course it is just my case.
    – user8685
    Jan 11, 2011 at 9:03
  • You did DOS programming on a crt console? We had punch cards. The 80 character limit was a result of the punch cards. Being able to study code over 3 or 4 pages at once is pretty handy. I guess that's why I still prefer print-outs. It's easier to navigate amongst related functions. Jan 11, 2011 at 9:31
  • I like long names, also--that's why I sometimes end up going to 100 characters. Jan 11, 2011 at 16:59
4

Printing code has become obsolete somewhere between 1975 and 1982, except for special reasons:

  • code to read it during a commute
  • old code that goes into the specification of a new project that shall replace it
  • to deal with blatant errors; it's safer to pummel a coworker with a stack of paper than a monitor
1
  • 1
    Pummeling is underrated. Aug 28, 2011 at 19:51
3

Our intellectual property lawyers require a "hardcopy" for copyright filing.

I don't know if they actually print it on paper. I send them a PDF that they can print or include in the copyright filing.

3

Not anymore. I used to do it all the time in the pre-IDE days, back when dot-matrix with continuous feed was the norm. You could spread those printouts out and flip through them quite easily. Modern sheet-fed laser/inkjet printers are a huge step backwards. Stapling them together doesn't flow as well, and not stapling results in loose sheets that get mixed up. Modern IDEs with automatic highlighting and method navigators also eliminate whole classes of errors that were caught by examining printouts.

2

I sometimes print my code because I am on a smallish (15") single monitor. I sometimes need to combine two programs and it is very hard to switch back and forth between them. I don't do this often though, only when necessary.

3
  • Dual Monitors! ;)
    – Pemdas
    Jan 10, 2011 at 20:49
  • @Pemdas I wish, lol.
    – sange
    Jan 10, 2011 at 20:51
  • I use a 15" at home due to lack of desk space.
    – Orbling
    Jan 11, 2011 at 2:30
2

I print out my code on paper very occasionally and only when I want to do some serious offline debugging or get acquainted with someone else's code - so it might be worth doing just out of courtesy.

Also, I'd probably be more apt to print a database schema out on paper than code.

I think the horizontal scrolling issue is a bigger annoyance and reason to keep to < 120 chars or so.

3
  • Actually, 80 char is still a good marker for the horizontal scrolling issue. Developers often have two panes of source, and even on my 1680 resolution, I can only get 107 char before I would have to scroll when I have two panes side by side. Also, I prefer if code doesn't go completely to the right margin.
    – Craige
    Jan 10, 2011 at 20:56
  • 1
    @Craige kinda depends on your font size and DPI though as well as how much junk you've got on either side of your screen (if you're in an IDE). I've started using XTerm instead of the standard Gnome Terminal when coding via SSH for this reason - not that I couldn't have just changed the font. Jan 10, 2011 at 21:01
  • @Petur Turner - that's true, but my Eclipse is setup in a way that minimizes wasted space when I need to get to coding. There is almost no wasted space on the left and right of my editors. Font size is also pretty standard. Point being - 80 char is a good target length to make source readable under the most diverse conditions.
    – Craige
    Jan 10, 2011 at 21:05
2

I only print out the code that comes together with a scientific article. Because this code frequently provides the implementation of an algorithm (a complex one I'd say), and you need a couple of hours to process it.
I doubt I would print out the code that contains SQL statements, or some GUI programming.

2

I print the code sometimes to try to make sense of thorny multi-page problems.

2
  • +1 Makes me wish we still had a dot matrix printer with never ending reems of paper. Jan 10, 2011 at 21:54
  • with alternating green and tan lines? But so slow!!! Jan 11, 2011 at 17:03
2

Almost Never

I've thought really hard to remember a time when I've either printed code, or have seen code printed. And I can honestly say I don't recall a single time (barring Pseudo code).

I'm not suggesting there are no legitimate reasons to print code.

2

I find it easier to figure out large modules if I can print them out and quickly see various sections. I could probably do something similar with multiple monitors, but if I have more than 2-3 places in the code to look at, it's quicker to have it all spread out in one place than to keep scrolling and keeping track of bookmarks. I also like to mark up printouts with changes rather than make them in the editor, because I can see the old code and the new code side-by-side. Sure, I could comment out the old code in the editor, but if you're replacing more than a few lines then you wind up scrolling the old code off the monitor, so you're no better off.

That said, I almost never print code anymore. It was great on fanfold paper, where the whole listing was continuous and you had plenty of space for notes in the margins, but printing everything out on individual letter-size pages is almost as bad as just keeping it on-screen. Especially when your editor insists on putting headers and footers in 1" margins. Fortunately, modern IDEs offer a lot of tools that reduce the need to print things out.

1

I don't print anything for myself, and I only print for others when I can't get out of it. I hate receiving printouts as well. They clutter up my desk and then I'm responsible for them (save it? file it? shred it? use it as scrap?)

Mind you I work near someone who's been doing mainframe coding for a few decades and has a foot-high pile of code printouts beside him.

Do what works for you I guess. Just don't leave your printouts at my desk, thank you.

1

A slightly different answer to the above ones.

I'm a student, and I find myself printing out code for various coursework hand-ins, but not for every unit where I have to write code.

In my first year most units required a hard-copy in addition to either an electronic upload, or a copy burnt to CD (yes, a CD for a 5 Mb zip file...) [Lecturer's choice]

I'm currently in my second year and so far we've had one electronic only upload, and one Hardcopy + CD hand-in.

Considering we have Moodle which allows electronic submission of coursework, quite why we don't always upload code is beyond me - we have to pay to print things out on the University Printers, and there is not a single CD burner on any of the PC's that I know of. Of course, the lecturers don't like Moodle - but that's another question entirely.

BTW, I'm a UK University Student, and not at a small, unknown one. Mine was in the top 10 of Uni's according to The Times / Guardian when I last looked.

1
  • That reminds me of a project I did at uni, where a written report was required. It had to be within 10 pages, and the code had to be attached as an appendix because the lecturer liked to look at the code while reading the report. Fortunately, the appendix didn't count to the total number of pages. So the lecturer was handed a 90-page PDF file. Don't know if he actually printed the document. ^^
    – gablin
    Jan 11, 2011 at 8:52
1

The new tools support me better and allow me to navigate fast and they deliver many types of summaries and views. Therefore I do not print as often as before. But sequential reading of printouts is still easier. My personal main reason to print is psychological: It prevents me from continuing to search and while the printer prints I start thinking! Also the beneficial effect of standing up and walking to the printer should not be underestimated :)

0

I print code so I can do a side-by-side comparison (my monitors at work are not widescreen). At home, I have a wide-screen so I can comfortably view two documents side by side.

0

Back in the days when US laws didn't allow export of strong cryptography, US-based open source developers used to print code and snail-mail them outside US, where they were scanned by volounteers. But I'm not sure if this answers your question ;)

0

I print hairy code on occasion to try and figure it out. I've also printed disassembly when debugging something "weird".

0

At my last job I would print out code for code reviews. It's nice to be able to highlight/mark up a bit of code when sitting around doing a code review so you have a good reference for any issues that were brought up during the review.

Also, when I had to refactor (ended up being a re-write) a particularly gnarled and twisted bit of code, I actually printed out the source code, taped the printouts up on the wall, then used bits of string to show how the logic was weaved together.

0

These days, never. I have the support of multiple monitors if I need to reference some particularly difficult code. Modern hard drives aren't going to blink at me storing code that's even several thousand lines long. Printing code IMHO is wasteful and generally useless but that's just me.

That said when I was first learning up to develop/program I thought nothing of printing 20 pages of code, so I suppose there might be a time and a place for it but I just find these days there isn't much use for it.

0

I print out my code all the time, but only because I'm a student who needs to do it to turn it in to the instructor.

However, because I have access to multiple monitors (like any good developer), I haven't had many situations where I need to print out source code for reference. I once printed out one of the scripts I used to populate a database so that I can see the schema at a glance, but I don't seem to use it much.

0

I used to print out code fairly often, but do so less now that I have multiple monitors on my desk -- I will often keep one part of a listing which I am using as a reference on my right monitor (which is somewhat off to the side), and my current work in front of me.

If I do print out ode, it is almost always code from someone or somewhere else (library) that I want to study, and need to flip pages back and forth.

I almost always print out code in landscape mode, because of the tendancy to use long lines.

0

In the last 10 years or so, I only recall printing out code, so I can use highlighter pens on it, to mark up sections that have something in common before planning how to refractor the code.

I do however sometimes miss being able to print out onto wide continuous paper, as laying the code out on the floor, could give a good overview, mostly along with coloured highlighter pens and postit notes. A4 printed pagers are no better then what a reasonable monitor gives.

Monitors have got a lot better and bigger while printers are worse for code then they used to be.

Not the answer you're looking for? Browse other questions tagged or ask your own question.