comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: conditional compilation
Date: 2000/08/03
Date: 2000-08-03T00:00:00+00:00	[thread overview]
Message-ID: <87vgxjgv3q.fsf@deneb.enyo.de> (raw)
In-Reply-To: wccwvhzbnwc.fsf@world.std.com

Robert A Duff <bobduff@world.std.com> writes:

> Simon Brady <see@below.for.email.address> writes:
> 
> > Been there, done that... I think the literate programming crowd offer a
> > useful insight here: programs aren't the same thing as representations
> > of programs, and what the compiler sees isn't necessarily what the
> > programmer should see.
> 
> I don't like so-called literate programming for the same reason I don't
> like C macros.  In order to understand the code, you have to imagine the
> actual output of the macro preprocessor.  (I admit that C macros are the
> worse of the two, of course.)

I think this argument is valid only to a limited extent.  After all,
there are plenty of language constructs which can be used to hide
details, and if a programmer has hidden the wrong details, this will
always make maintenance unnecessarily complicated.

Of course, the C preprocessor is bad, and its usage results in quite
a lot of bugs.  (IIRC the study carried out by Bell Labs on some of
their telephone switching software showed this quite drastically.)

Many of them are extremely non-obvious because there are many common
idioms associated with C macros which you tend to ignore when
reading the source, but which are quite intrusive and can cause
bugs by itself.  For example, after a while, you start to overlook
the "do { ... } while (0);" construct to make a macro expansion a
statement---until a "continue;" statement is part of the macro, which
is supposed to effect an outer loop. :-/ (I guess C macros are used
quite regularly to obfuscate flow of control because you can't use
subroutines for that.)

I don't have any experience in maintaining literate programs, but
the last time I tried to read such code, the algorithms were in fact
nicely documented, but even at the lower levels, the data flow was
very hard to trace even locally (in contrast to the control flow,
which was properly outlined, but which you could hide as well).  In
my experience, understanding the data flow is quite important if you
want to do some non-trivial changes to existing code.  I doubt that
the literate programming approach as exemplified by TeX is really that
maintainer-friendly.  If you are interested in such stuff, TeX is
very nice to read, but it's generally considered a dead end regarding
future development.  In fact, TeX has already been reimplemented in
Java, AFAIK not in strict literate programming style.  (Well, this
reimplementation is also an involuntary case study in the portability
of Java code with rather disappointing results.)

> In any case, from a language design point of view, if you think the
> compiler should see things in a different order or different
> organization than human beings, then clearly the programming language is
> poorly designed.  

This is a very good point.  On the other hand, with most programming
languages, you need some separate documentation for the overall
structure of the code, general design decision and so on.  AFAIK
literate programming tries to merge this kind of documentation with
the actual code.




  parent reply	other threads:[~2000-08-03  0:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-31  0:00 conditional compilation Matthew Woodcraft
2000-07-31  0:00 ` Marin D. Condic
2000-07-31  0:00   ` Ira D. Baxter
2000-08-01  0:00   ` Simon Brady
2000-07-31  0:00     ` Marin D. Condic
2000-08-01  0:00     ` Ted Dennison
2000-08-01  0:00       ` Robert A Duff
2000-08-01  0:00         ` Laurent Guerby
2000-08-02  0:00       ` Simon Brady
2000-08-02  0:00         ` Robert A Duff
2000-08-02  0:00           ` Georg Bauhaus
2000-08-03  0:00             ` Robert A Duff
2000-08-02  0:00           ` Brian Rogoff
2000-08-03  0:00             ` Robert A Duff
2000-08-03  0:00           ` Florian Weimer [this message]
2000-08-02  0:00         ` Simon Brady
2000-08-01  0:00           ` William J. Thomas
2000-08-02  0:00         ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2000-09-19  0:00 Conditional Compilation Kenneth Kueny
2000-09-19  0:00 ` David Starner
2000-09-19  0:00 ` Richard Riehle
2000-09-19  0:00 ` E. Robert Tisdale
2000-09-19  0:00   ` David Starner
2000-09-20  0:52     ` Robert Dewar
2000-09-19  0:00   ` Larry Kilgallen
2000-09-19  0:00     ` Jeff Allen
2000-09-20  0:49       ` Robert Dewar
2000-09-19  0:00         ` Bobby D. Bryant
2000-09-24  0:00           ` Robert Dewar
2000-09-20  0:47   ` Robert Dewar
2000-10-09  0:00   ` John McCabe
2000-09-19  0:00 ` Jeffrey Carter
2000-09-19  0:00   ` Samuel T. Harris
2000-09-20  0:44     ` Robert Dewar
2000-09-19  0:00 ` Ted Dennison
2000-09-20  1:33 ` tmoran
     [not found]   ` <8qauu3$7ei$1@nnrp1.deja.com>
2000-09-24  0:00     ` Robert Dewar
2000-09-25  2:45       ` Ted Dennison
2000-09-25  0:00         ` peter
     [not found] ` <39CA31F2.E160F0D8@res.raytheon.com>
2000-09-24  0:00   ` Robert Dewar
2001-01-02 13:27 ` Andrew Hately
2001-01-02 16:46   ` Robert Dewar
1989-12-12  0:08 conditional compilation Emery
1988-06-13  0:24 Conditional compilation Steinar Haug
1988-06-17 13:53 ` rds
1988-06-22  0:44   ` Jeff Bartlett
1988-06-23 13:01   ` Arny B. Engelson
1988-06-27 18:01     ` Dave Seward
1988-06-29 13:32   ` brucej
1988-06-17 14:48 ` rjs
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox