When I teach introductory computer science courses, I like to lighten the mood with some humor. Having a sense of fun about the material makes it less frustrating and more memorable, and it's even motivating if the joke requires some technical understanding to 'get it'!

I'll start off with a couple of my favorites:

Q: How do you tell an introverted computer scientist from an extroverted computer scientist?

A: An extroverted computer scientist looks at your shoes when he talks to you.

And the classic:

Q: Why do programmers always mix up Halloween and Christmas?

A: Because Oct 31 == Dec 25!

I'm always looking for more of these, and I can't think of a better group of people to ask. What are your best programmer/computer science/programming jokes?

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

Indeed, when I design my killer language, the identifiers foo and bar will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice.

A programmer and a business analyst are sitting in the break room one day eating lunch when suddenly the microwave catches fire. Thinking quickly, the analyst leaps up, unplugs the microwave, grabs the trash can, fills it with water from sink, and dumps the water on the microwave to put out the flames.

A few weeks later the two are again having lunch in the break room when suddenly the coffee maker bursts into flames. The programmer leaps up, grabs the coffee maker, shoves it into the microwave oven, and then hands the trash can to the business analyst, thus re-using the solution developed for the previous project.

Reminds me of the zen of Python: "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
–
sebnowFeb 11 '09 at 7:44

This one is funny because of the amount of time it took me to explain it to my non-programming friends. ("I've got a great joke--but first, a quick lesson on transmission protocols.")
–
Michael Myers♦Jun 16 '09 at 15:28

Back in the mid-1970s, several of the
system support staff at Motorola (I
believe it was) discovered a
relatively simple way to crack system
security on the Xerox CP-V timesharing
system (or it may have been CP-V's
predecessor UTS). Through a simple
programming strategy, it was possible
for a user program to trick the system
into running a portion of the program
in "master mode" (supervisor state),
in which memory protection does not
apply. The program could then poke a
large value into its "privilege level"
byte (normally write-protected) and
could then proceed to bypass all
levels of security within the
file-management system, patch the
system monitor, and do numerous other
interesting things. In short, the
barn door was wide open.

Motorola quite properly reported this
problem to XEROX via an official
"level 1 SIDR" (a bug report with a
perceived urgency of "needs to be
fixed yesterday"). Because the text
of each SIDR was entered into a
database that could be viewed by quite
a number of people, Motorola followed
the approved procedure: they simply
reported the problem as "Security
SIDR", and attached all of the
necessary documentation,
ways-to-reproduce, etc. separately.

Xerox apparently sat on the problem...
they either didn't acknowledge the
severity of the problem, or didn't
assign the necessary
operating-system-staff resources to
develop and distribute an official
patch.

Time passed (months, as I recall).
The Motorola guys pestered their Xerox
field-support rep, to no avail.
Finally they decided to take Direct
Action, to demonstrate to Xerox
management just how easily the system
could be cracked, and just how
thoroughly the system security systems
could be subverted.

They dug around through the
operating-system listings, and devised
a thoroughly devilish set of patches.
These patches were then incorporated
into a pair of programs called Robin
Hood and Friar Tuck. Robin Hood and
Friar Tuck were designed to run as
"ghost jobs" (daemons, in Unix
terminology); they would use the
existing loophole to subvert system
security, install the necessary
patches, and then keep an eye on one
another's statuses in order to keep
the system operator (in effect, the
superuser) from aborting them.

So... one day, the system operator on
the main CP-V software-development
system in El Segundo was surprised by
a number of unusual phenomena. These
included the following (as I recall...
it's been a while since I heard the
story):

Tape drives would rewind and dismount their tapes in the middle
of a job.

Disk drives would seek back&forth so rapidly that they'd attempt to walk
across the floor.

The card-punch output device would occasionally start up of itself and
punch a "lace card" (every hole
punched). These would usually jam in
the punch.

The console would print snide and insulting messages from Robin Hood
to Friar Tuck, or vice versa.

The Xerox card reader had two output stackers; it could be instructed to
stack into A, stack into B, or stack
into A unless a card was unreadable,
in which case the bad card was
placed into stacker B. One of the
patches installed by the ghosts
added some code to the card-reader
driver... after reading a card, it
would flip over to the opposite
stacker. As a result, card decks
would divide themselves in half when
they were read, leaving the operator
to recollate them manually.

I believe that there were some other
effects produced, as well.

Naturally, the operator called in the
operating-system developers. They
found the bandit ghost jobs running,
and X'ed them... and were once again
surprised. When Robin Hood was X'ed,
the following sequence of events took
place:

Each ghost-job would detect the fact
that the other had been killed, and
would start a new copy of the
recently-slain program within a few
milliseconds. The only way to kill
both ghosts was to kill them
simultaneously (very difficult) or to
deliberately crash the system.

Finally, the system programmers did
the latter... only to find that the
bandits appeared once again when the
system rebooted! It turned out that
these two programs had patched the
boot-time image (the /vmunix file, in
Unix terms) and had added themselves
to the list of programs that were to
be started at boot time...

The Robin Hood and Friar Tuck ghosts
were finally eradicated when the
system staff rebooted the system from
a clean boot-tape and reinstalled the
monitor. Not long thereafter, Xerox
released a patch for this problem.

I believe that Xerox filed a complaint
with Motorola's management about the
merry-prankster actions of the two
employees in question. To the best of
my knowledge, no serious disciplinary
action was taken against either of
these guys.

Several years later, both of the
perpetrators were hired by Honeywell,
which had purchased the rights to CP-V
after Xerox pulled out of the
mainframe business. Both of them made
serious and substantial contributions
to the Honeywell CP-6 operating system
development effort. Robin Hood (Dan
Holle) did much of the development of
the PL-6 system-programming language
compiler; Friar Tuck (John Gabler) was
one of the chief
communications-software gurus for
several years. They're both alive and
well, and living in LA (Dan) and
Orange County (John). Both are among
the more brilliant people I've had the
pleasure of working with.

Disclaimers: it has been quite a while
since I heard the details of how this
all went down, so some of the details
above are almost certainly wrong. I
shared an apartment with John Gabler
for several years, and he was my Best
Man when I married back in '86... so
I'm somewhat predisposed to believe
his version of the events that
occurred.

A mathematician asks an engineer a question, "Here are 5 birds in the tree, if I shoot one, how many are left?"

The engineer answers, "0, since the birds will all fly away when they hear the gunshot."

"The correct answer is 4, but I like the way you think" said the mathematician.

The engineer then says, "Well then, I will ask you a question. Three women are sitting on the park bench eating ice cream. The first one is licking it, the second one swallows the ice cream and starts sucking on the cone, the third takes a bite out of the ice cream, which one is married?"

The mathematician blushes and answers: "The second one?"

The engineer then says, "Wrong, the answer is the one wearing the wedding ring, but I like the way you think."

I've always thought of it as if you are filling up the glass, then it's half full. If you are drinking from the glass, then it's half empty.
–
CrispyMay 11 '09 at 20:54

7

More an engineer. If a programmer was designing a glass, I'd be afraid to drink from it.
–
Andrei KrotkovMay 16 '09 at 9:30

3

I think this joke is more in terms of data structures. "This array is twice as large as necessary."
–
Martin CoteMay 17 '09 at 13:49

2

If a programmer was designing a glass, when it reached half full, the glass would be replaced by a new glass, twice as large, and all the liquid poured into the new one, so as to achieve amortized constant time glass filling.
–
EclipseJul 13 '09 at 14:25

4

The programmer should just think the glass is padded.
–
jmucchielloAug 21 '09 at 20:59

I hear they make gender-specific versions of ActiveX now: ActiveXX and ActiveXY. Unfortunately, ActiveXX overflows for a few days every month and ActiveXY constantly tries to mount drives it shouldn't.

maybe it's classic C. I think it's missing a \n at the end of that string there though.
–
wdsJul 8 '09 at 11:41

1

@wds it is classic C. You don't include stdio.h in a C++ program.
–
MatthewDec 4 '09 at 7:25

2

Correct and well-written C90 code, except for the lack of the '\n' at the end of the string. (It's '\n' instead of "\r\n" or '\r'; it's the compiler's job to translate '\n' to whatever characters the OS needs to end the line with.)
–
David ThornleyDec 29 '09 at 20:29

My grandpa told me a non-CS variant of this several years ago. It went something like this: A young man finds a genie's lamp. He rubs it, and out pops the genie. "For freeing me from the lamp, I shall grant you one wish," the genie says. The man thinks for a moment, then says "I wish for a road to Hawaii." The genie gasps. "What a thing to ask for! Even for me it would take years to complete! Do you have a simpler wish?" The man thinks long and hard this time, then he says "I wish to understand women." The genie looks at the man, sighs, and says "You want two or four lanes on that road?"
–
bcatJun 28 '10 at 0:37