The C programming language

C, n.: A programming language that is sort of like Pascal except more like assembly except that it isn't very much like either one, or anything else. It is either the best language available to the art today, or it isn't.
   — Ray Simard
On this page:

How to program in C

"If it weren't for C, we'd be writing programs in BASI, PASAL, and OBOL."
  1. Use lots of global variables.
  2. Give them cryptic names such as: X27, a_gcl, or Horace.
  3. Put everything in one large .h file.
  4. Implement the entire project at once.
  5. Use macros and #defines to emulate Pascal.
  6. Assume the compiler takes care of all the little details you didn't quite understand.
  7. Rewrite standard functions and give them your own obscure names.
  8. Use obscure, proprietary, non-portable, compiled library packages so that you never have to move from the platform you love so well.
  9. Use very descriptive comments like /* printf("Hello world\n"); */ before each function call.
  10. REMEMBER - Carriage returns are for weenies. Tabs are for those who have not reached weenie-dom yet.
  11. Include LOTS of inline assembly code.
  12. "User Interfaces" are for morons. "Users" have no business interfacing with a professional product like yours.
  13. If you are forced to comment your code (in English), then borrow comments from somebody else's code and sprinkle them throughout yours. It's quick, easy, and fun to watch people's expressions as they try to figure it out.
  14. Remember to define as many pre-processor symbols as possible in terms of already defined symbols. This is considered 'efficient use of code'.


"It's 5:50 a.m., do you know where your stack pointer is ?"

How to debug a C program

  1. If at all possible, don't. Let someone else do it.
  2. Change majors.
  3. Insert/remove blank lines at random spots, re-compile, and execute.

  4. [CodingDrunk.png]
Coding while drunk.
  5. Throw holy water on the terminal.
  6. Dial 911 and scream.
  7. There is rumor that "printf" is useful, but this is probably unfounded.
  8. Port everything to CP/M.
  9. If it still doesn't work, re-write it in assembler. This won't fix the bug, but it will make sure no one else finds it and makes you look bad.
  10. Since you got it to compile, the problem must be in the Other Guys Code.
  11. If it's all your code then the problem MUST be in those unreliable Standard Libraries. See '1'.
  12. Claim the bug reports are vicious lies meant to tarnish your sterling reputation as a 'C' programmer (well aren't they ?). After all, those who wrote the reports couldn't even read your code. How could they possibly know if there was a bug or not?
  13. If they could read your code, review "How to program in C", above.
  14. Claim that there wouldn't be a problem if this stingy Company/School/Wife/etc would spring for a copy of C++.


"In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt."    — Blair P. Houghton

Creators admit Unix & C hoax

In an announcement that has stunned the computer industry, Ken Thompson, Dennis Ritchie and Brian Kernighan admitted that the Unix operating system and C programming language created by them is an elaborate April Fools prank kept alive for over 20 years. Speaking at the recent UnixWorld Software Development Forum, Thompson revealed the following:

"In 1969, AT&T had just terminated their work with the GE/Honeywell/AT&T Multics project. Brian and I had just started working with an early release of Pascal from Professor Nichlaus Wirth's ETH labs in Switzerland and we were impressed with its elegant simplicity and power. Dennis had just finished reading 'Bored of the Rings', a hilarious National Lampoon parody of the great Tolkien 'Lord of the Rings' trilogy. As a lark, we decided to do parodies of the Multics environment and Pascal. Dennis and I were responsible for the operating environment. We looked at Multics and designed the new system to be as complex and cryptic as possible to maximize casual users' frustration levels, calling it Unix as a parody of Multics, as well as other more risqué allusions. Then Dennis and Brian worked on a truly warped version of Pascal, called 'A'. When we found others were actually trying to create real programs with A, we quickly added additional cryptic features and evolved into B, BCPL and finally C.

We stopped when we got a clean compile on the following syntax:
for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("|"+(*u/4) %2);

To think that modern programmers would try to use a language that allowed such a statement was beyond our comprehension! We actually thought of selling this to the Soviets to set their computer science progress back 20 or more years. Imagine our surprise when AT&T and other US corporations actually began trying to use Unix and C! It has taken them 20 years to develop enough expertise to generate even marginally useful applications using this 1960's technological parody, but we are impressed with the tenacity (if not common sense) of the general Unix and C programmer. In any event, Brian, Dennis and I have been working exclusively in Pascal on the Apple Macintosh for the past few years and feel really guilty about the chaos, confusion and truly bad programming that have resulted from our silly prank so long ago."

Major Unix and C vendors and customers, including AT&T, Microsoft, Hewlett-Packard, GTE, NCR, and DEC have refused comment at this time. Borland International, a leading vendor of Pascal and C tools, including the popular Turbo Pascal, Turbo C and Turbo C++, stated they had suspected this for a number of years and would continue to enhance their Pascal products and halt further efforts to develop C. An IBM spokesman broke into uncontrolled laughter and had to postpone a hastily convened news conference concerning the fate of the RS-6000, merely stating 'VM will be available Real Soon Now'. In a cryptic statement, Professor Wirth of the ETH institute and father of the Pascal, Modula 2 and Oberon structured languages, merely stated that P. T. Barnum was correct.

"Trying to outsmart a compiler defeats much of the purpose of using one."    — B. Kernighan & Plauger, "The Elements of Programming Style"

In a related late-breaking story, usually reliable sources are stating that a similar confession may be forthcoming from William Gates concerning the MS-DOS and Windows operating environments. And IBM spokesmen have begun denying that the Virtual Machine (VM) product is an internal prank gone awry.

[COMPUTERWORLD 1 May]
[contributed by Bernard L. Hayes]



"A UNIX saleslady, Lenore
Likes work, but likes the beach more.
She found a clever way
To mix work with play...
She sells C shells by the seashore."

Write in C

To the tune of the Beatles' Let it Be

When I find my code in tons of trouble,
Friends and colleagues come to me,
Speaking words of wisdom:
"Write in C."

As the deadline fast approaches,
And bugs are all that I can see,
Somewhere, someone whispers:
"Write in C."

Write in C, Write in C,
Write in C, oh, Write in C.
LOGO's dead and buried,
Write in C.


[DilbertNickel.gif]
Condescending Unix User
I used to write a lot of FORTRAN,
For science it worked flawlessly.
Try using it for graphics!
Write in C.

If you've just spent nearly 30 hours
Debugging some assembly,
Soon you will be glad to
Write in C.

Write in C, Write in C,
Write in C, yeah, Write in C.
Only wimps use BASIC.
Write in C.

Write in C, Write in C
Write in C, oh, Write in C.
Pascal won't quite cut it.
Write in C.

Write in C, Write in C,
Write in C, yeah, Write in C.
Don't even mention COBOL.
Write in C.


More about the C programming language ? Check out the International Obfuscated C Code Contest for some interesting examples of C programs.

Go take a look at the computer quotes.