ALINK="#FF0000">
LINUX GAZETTE
...making Linux just a little more fun!
Laurel and Hardy Try to Write a C Program
By Stephen Bint

... featuring those Lovable Dolts, Stan Laurel and Oliver Hardy.
(Official L&H site)    (UK tribute page)

This article is a follow-up to the author's The Ultimate Editor in January and the Mailbag letters (three of them) it received in February.


Ollie is sitting in front of a terminal. Stan enters, carrying a book.

Ollie: Where have you been?

Stan: I went to the bookstore to get a book like you said.

Ollie: Well, you took your sweet time. We have to get this CGI script finished by tomorrow morning. Let's see what you've got.

Stan hands Ollie the book.

Ollie: "A Guide to Programming in C". What is this?

Stan: It's a guide to programming in C, Ollie.

Ollie looks at camera - not amused.

Ollie: I can see that, you idiot. I thought I told you we were going to write it in Perl.

Stan: But Mr. Bint said...

Ollie: Mr. Bint?

Stan: The man at the bookstore. Mr. Bint.

Ollie: [Impatiently] What did "Mr. Bint" say?

Stan: He said he was all sold out of books about Perl, but he had a whole shelf full of books about C. He said I was lucky.

Ollie: How did he make that out?

Stan: He said C is a better choice for CGI programs. He said C is a professional programming language, but Perl is a toy language. He said Perl is a jumped up scripting language that's gotten ahead of itself.

Ollie: Oh, he did, did he?

Stan: [Nods] Mr. Bint says that though the learning curve with C is initially steeper, ultimately there is less to learn, because C has fewer rules. He said Perl does most things for you and you need to learn exactly what it does in every case, to understand what your program is doing. He said that's why books about C are so thin and books about Perl are so fat. He says the reason he is sold out is that Perl books are so fat he can only fit four on a shelf. Not only that, but the trucks that deliver them often fail to arrive because their tyres keep exploding.

Ollie: Is that a fact?

Stan: [Nods] That's what Mr. Bint says. He says that Perl has confusing syntax and fails to define function interfaces correctly, which invites sloppiness.

Ollie: And what else does he say?

Stan: He says that C is often made out to be full of danger and potential for disaster compared to Perl, but in fact, Perl is only proof against a couple of common bugs and its lack of readability makes other bugs more likely. He says the gcc compiler gives good warnings about badly written C, there are tools which can check for memory leaks and Lint to check for other common errors.

Ollie: Mmmph. Mr. Bint recommends Lint, does he?

Stan: Yes.

Ollie looks impatiently at the camera, then at Stan.

Ollie: Well, I suppose we will just have to write it in "C".... "Mr. Bint". Mmmpph!

Ollie faces keyboard and prepares to type.

Ollie: OK, you read the book out to me and I'll type in the program.

   while( ollie_waits ) {

      Stan_looks_at_book();
      Stan_looks_at_Ollie();
      Stan_looks_panic_stricken();

      if( ollie_looks_around() )
         ollie_waits = false;
      }

Ollie: Well, what is it now Stanley?

Stan: [Blubbering] I'm sorry Ollie... blubber... I don't think we can just start straight away... snivel...I think we have to read the book and learn the language first...

Ollie: Will you stop sniveling? How hard can it be? We'll simply learn the language, then we'll write the program.

Ollie turns to give Stan his full attention.

Ollie: OK, tell me what we need to learn about C before we can start.

Stan: According to this table of contents... variable types, user-defined types, typedefs, static variables, initialisation vs. assignment, constants, statements, binary operators, unary operators, arithmetic operators, logical operators, bitwise operators, operator precedence, if, for, switch, while, continue, break, arrays...

Ollie looks at camera - not amused.

Stan: multi-dimensional arrays, pointers, pointer arithmetic, function pointers, function declaration and definition, preprocessor directives and macros, printf formats, automatic and allocated memory, command-line arguments, recursion...

Ollie removes Stan's hat, slaps him round the chops with the mouse mat (both sides), carefully replaces hat. Stan stops reading.

Ollie: Well, congratulations Stanley. This is another fine mess you've gotten me into.

   while( camera_is_running() )
      Stan_blubbers();

Fin.

 

[BIO] Stephen is a homeless Englishman who lives in a tent in the woods. He eats out of bins and smokes cigarette butts he finds on the road. Though he once worked for a short time as a C programmer, he prefers to describe himself as a "keen amateur".


Copyright © 2003, Stephen Bint. Copying license http://www.linuxgazette.net/copying.html
Published in Issue 89 of Linux Gazette, April 2003