File: bint.html

package info (click to toggle)
lg-issue89 1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,804 kB
  • ctags: 80
  • sloc: xml: 106; makefile: 34; sh: 34; perl: 1
file content (292 lines) | stat: -rw-r--r-- 7,975 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!--startcut  ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>Laurel and Hardy Try to Write a C Program LG #89</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->

<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->

<!--endcut ============================================================-->

<TABLE BORDER><TR><TD WIDTH="200">
<A HREF="http://www.linuxgazette.com/">
<IMG ALT="LINUX GAZETTE" SRC="../gx/2002/lglogo_200x41.png" 
	WIDTH="200" HEIGHT="41" border="0"></A> 
<BR CLEAR="all">
<SMALL>...<I>making Linux just a little more fun!</I></SMALL>
</TD><TD WIDTH="380">


<CENTER>
<BIG><BIG><STRONG><FONT COLOR="maroon">Laurel and Hardy Try to Write a C Program</FONT></STRONG></BIG></BIG>
<BR>
<STRONG>By <A HREF="../authors/bint.html">Stephen Bint</A></STRONG>
</CENTER>

</TD></TR>
</TABLE>
<P>

<!-- END header -->






<BLOCKQUOTE>
<STRONG>... featuring those Lovable Dolts,  Stan Laurel and Oliver Hardy.</STRONG><BR>
<A HREF="http://www.laurel-and-hardy.com/">(Official L&H site)</A> &nbsp;&nbsp;
<A HREF="http://www.laurelnhardy.co.uk/">(UK tribute page)</A>

<P> This article is a follow-up to the author's
<A HREF="../issue87/bint.html">The Ultimate Editor</A> in January and the
<A HREF="../issue88/lg_mail.html#mailbag.1">Mailbag letters</A> (three of them)
it received in February.
<HR>
</BLOCKQUOTE>

<P>
<EM>Ollie is sitting in front of a terminal. Stan enters, 
carrying a book.</EM>

<P>
<STRONG>Ollie:</STRONG> Where have you been?

<P>
<STRONG>Stan:</STRONG> I went to the bookstore to get a book like you 
said.

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

<P>
<EM>Stan hands Ollie the book.</EM>

<P>
<STRONG>Ollie:</STRONG> "A Guide to Programming in C". What is this?

<P>
<STRONG>Stan:</STRONG> It's a guide to programming in C, Ollie.

<P>
<EM>Ollie looks at camera - not amused.</EM>

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

<P>
<STRONG>Stan:</STRONG> But Mr. Bint said...

<P>
<STRONG>Ollie:</STRONG> Mr. Bint?

<P>
<STRONG>Stan:</STRONG> The man at the bookstore. Mr. Bint.

<P>
<STRONG>Ollie:</STRONG> <EM>[Impatiently]</EM> What did "Mr. Bint" say?

<P>
<STRONG>Stan:</STRONG> 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.

<P>
<STRONG>Ollie:</STRONG> How did he make that out?

<P>
<STRONG>Stan:</STRONG> 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.

<P>
<STRONG>Ollie:</STRONG> Oh, he did, did he?

<P>
<STRONG>Stan:</STRONG> <EM>[Nods]</EM> 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.

<P>
<STRONG>Ollie:</STRONG> Is that a fact?

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

<P>
<STRONG>Ollie:</STRONG> And what else does he say?

<P>
<STRONG>Stan:</STRONG> 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.

<P>
<STRONG>Ollie:</STRONG> Mmmph. Mr. Bint recommends Lint, does he?

<P>
<STRONG>Stan:</STRONG> Yes.

<P>
<EM>Ollie looks impatiently at the camera, then at Stan. </EM>

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

<P>
<EM>Ollie faces keyboard and prepares to type.</EM>

<P>
<STRONG>Ollie:</STRONG> OK, you read the book out to me and I'll type
in the program.

<PRE>
   while( ollie_waits ) {

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

      if( ollie_looks_around() )
         ollie_waits = false;
      }
</PRE>

<P>
<STRONG>Ollie:</STRONG> Well, what is it now Stanley?
       
<P>
<STRONG>Stan:</STRONG> <EM>[Blubbering]</EM> 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...

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

<P>
<EM>Ollie turns to give Stan his full attention.</EM>

<P>
<STRONG>Ollie:</STRONG> OK, tell me what we need to learn about C
before we can start.

<P>
<STRONG>Stan:</STRONG> 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...

<P>
<EM>Ollie looks at camera - not amused.</EM>

<P>
<STRONG>Stan:</STRONG> 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...

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

<P>
<STRONG>Ollie:</STRONG> Well, congratulations Stanley. This is another
fine mess you've gotten me into.

<PRE>
   while( camera_is_running() )
      Stan_blubbers();
</PRE>

<P>
<EM>Fin.</EM>


<!--
<H3>Further Reading (anti-Perl)</H3>

<a 
href="http://groups.google.com/groups?as_umsgid=2969@jato.Jpl.Nasa.Gov">
Readability suffers slightly...</a> (by Larry Wall)

<P>
<A HREF="http://www.garshol.priv.no/download/text/perl.html">What's Wrong with Perl</A>

<H3>Further Reading (obfuscated C)</H3>

<A HREF="http://www0.us.ioccc.org/2001/cheong.c">A rectangular program</A>

<P>
<A HREF="http://www0.us.ioccc.org/2001/anonymous.c">A program with one-letter #define's</A>
-->



<!-- *** BEGIN author bio *** -->
<P>&nbsp;
<P>
<!-- *** BEGIN bio *** -->
<P>
<img ALIGN="LEFT" ALT="[BIO]" SRC="../gx/2002/note.png">
<em>
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".
</em>
<br CLEAR="all">
<!-- *** END bio *** -->

<!-- *** END author bio *** -->


<!-- *** BEGIN copyright *** -->
<hr>
<CENTER><SMALL><STRONG>
Copyright &copy; 2003, Stephen Bint.
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR> 
Published in Issue 89 of <i>Linux Gazette</i>, April 2003
</STRONG></SMALL></CENTER>
<!-- *** END copyright *** -->
<HR>

<!--startcut ==========================================================-->
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</BODY></HTML>
<!--endcut ============================================================-->