Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: bill@cafe.net (Kaz Kylheku)
Subject: Re: [++] Tight coding
Date: 1998/03/02	[thread overview]
Message-ID: <bEDK.1724$Jb.2763732@brie.direct.ca> (raw)
In-Reply-To: 6de8o0$kau$1@seagoon.newcastle.edu.au


In article <6de8o0$kau$1@seagoon.newcastle.edu.au>,
Peter Moylan <peter@ee.newcastle.edu.au> wrote:
>OK, I expressed myself badly.  True, the standard says that you shouldn't
>perform dirty tricks on pointers.  But the standard does _not_ say that
>compilers should check for violations, or even that compilers should
>issues warnings about doing something stupid.  So in practice the
>compilers accept questionable pointer arithmetic, and most C compilers
>have things like bounds checking disabled by default.  They have to,
>for at least two reasons.  First, that sort of checking is very expensive in
>a language like C.  (The language rules mean that very little checking
>can be done at compile time; they also make it very difficult to detect
>pointers that run outside their bounds.) 

Actually, the extent of the success of the bounds checking GCC project
would tend to indicate that such checking is feasible. It is surprising how
simple it is and the extent to which it can pin-point errors, and it does
this without changing the representation of pointers. The run time hit isn't
all that bad either (but you still wouldn't want it in production code,
needless to say). It's acceptable for ``smoke testing''. 

 Second, and perhaps more
>important, thousands of programmers and project managers would
>scream blue bloody murder if a compiler/runtime system enforced those
>rules, because it would break 90% of their existing software.

That may be true, but how do we now leap to the conclusion that
C has influenced operating system design toward ignoring segmentation
hardware? That is really the only assertion made in this
discussion thread that is worthy of controversy.

I think that most programmers and managers would have a positive response to a
tool that would catch deep errors. We can't let Dilbert comics completely
determine our view of managers and developers.

>The rules in the C standard are a token effort at saying "don't make
>mistakes, or I'll call you a naughty boy and make you stand in the corner".

No, the rules in the C standard exist to enable certain kinds of
implementations. Because one may not compares pointers to distinct objects for
anything other than exact equality, compilers may be constructed which place
objects in separate logical memory segments. Requiring diagnostic capability
for a violation of this rule, on the other hand, might place a severe
burden on some implementors---at least according to the best collective wisdom
of the standard writers.

If the C standard allow arbitrary pointers to be compared in arbitrary ways,
with well-defined results, such implementations would have difficulty meeting 
its requirements.

>There is absolutely no enforcement built in.  In fact, the rules about
>bounds violations are simply a disclaimer to protect compiler
>developers, so they can say "yes, I know the compiler failed to warn
>you of this error, but it's not our fault; the warranty doesn't cover the
>sort of software you're writing".

It's not an uncommon opinion that undefined behaviors in the language
standards are there in order to absolve the compiler implementors of blame for
software failure. However, I believe that it is an unrealistically cynical
opinion.

The real reasons are that by leaving certain aspects of the language
undefined, implementors have more choices as to how something should be
implemented. Also, we have to remember that the C language was in widespread
use before it was standardized, for better or worse.

Sometimes the most ridiculous and easily diagnosable aspects are undefined.
For example, if, in a string or character literal, a backslash is followed
by something that isn't a valid escape sequence, the behavior is undefined.
It's obvious that this is trivial to diagnose, but there is probably a good
reason why a diagnostic is not required.

The C language has had only one standard approved by ISO so far, and is
nearing the completion of a second. As time goes on, we can expect at least
some parts of the language to ``tighten up''. But the first standard had to be
workable in the way of reflecting existing practice.

>>>Perhaps you hadn't noticed the newsgroups to which this was
>>>cross-posted.  Most of us are already doing a lot better 
>>>than C.
>>
>>You don't appear to know C well enough to make that judgement.
>
>You're probably right, people have been telling me that for the
>last 25 years.  But the software I produce - using C among other
>languages - works, and it's delivered on time and within budget.
>(Not many developers can make that claim.)  So I think I'm
>entitled to an opinion.
>
>Furthermore, I have continued to resist the modern practice of
>charging an "upgrade" price for bug fixes that are delivered a
>year late.

That's hard to do if the bug fixes are not well separated from genuine
enhancements that were also done to the software.   There is a difference
between a genuine upgrade and strictly bug-fix patches done to the older
release. If the software you are getting includes many enhancements that you
want as well as bug fixes, what are you paying for? In one sense, you are
paying for everything the developer does; including support, marketing, sales.
Should you also object that part of the price you pay goes to paying the
developer's receptionist, and marketing staff, or office rent? 

I believe in free bug fix patches; it's hard to disagree with such a
policy, because it is based on well-founded ethical principles. 
The developer should put in as many bug fixes into the older version
of the software as possible and make that available to the end user
as an alternative to the upgrade option, but it's almost inevitable
taht some problems will only be resolved in an upgrade. Sometimes
only a design change can resolve some problems, or the bug fix 
came about as a result of a complete rewrite of some subsystem which
can't be retrofitted into the old version for whatever reasons.

>Just recently, a builder came to my house and repaired an error
>made by one of his carpenters.  He didn't charge me, because
>the error was his responsibility.  In practically every industry, fixing
>the bugs is part of the original contract price.  If the same idea was
>accepted in the software industry, the use of bug-prone programming
>languages would disappear overnight.

If things are so rosy outside of the software industry, why do there exist
``home owner protection'' type insurance schemes? ;)



  parent reply	other threads:[~1998-03-02  5:00 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-23  5:00 Wildfire and NT Robert Harley
1998-02-24  5:00 ` brianh
1998-02-24  5:00   ` Sean Burke
1998-02-25  5:00     ` brianh
1998-02-25  5:00     ` Maynard Handley
1998-02-25  5:00     ` Mike Albaugh
1998-02-25  5:00     ` [++] Tight coding (Was: Re: Wildfire and NT) Terje Mathisen
1998-02-28  5:00       ` Piercarlo Grandi
1998-03-01  5:00       ` [++] Tight coding Bill Moyer
1998-03-01  5:00         ` Ruud Bruijnesteijn
1998-03-01  5:00           ` scott
1998-03-02  5:00             ` Kaz Kylheku
1998-03-02  5:00             ` Terry Moore
1998-03-02  5:00               ` Pete Becker
1998-03-03  5:00                 ` Ruud Bruijnesteijn
1998-03-03  5:00                   ` Pete Becker
1998-03-04  5:00                     ` Terry Moore
1998-03-03  5:00                       ` Pete Becker
1998-03-04  5:00                       ` Ruud Bruijnesteijn
1998-03-02  5:00               ` Kaz Kylheku
1998-03-02  5:00             ` Martin Tom Brown
1998-03-01  5:00         ` Larry Kilgallen
1998-03-01  5:00           ` [++] Tight coding (comp.sys.dec-only thread) Bill Moyer
1998-03-02  5:00         ` [++] Tight coding Peter Moylan
1998-03-02  5:00           ` Lawrence Kirby
1998-03-02  5:00             ` Peter Moylan
1998-03-02  5:00               ` Ketil Z Malde
1998-03-04  5:00                 ` Lyn A Headley
1998-03-02  5:00               ` Kaz Kylheku [this message]
1998-03-03  5:00               ` Lawrence Kirby
1998-03-02  5:00           ` Kaz Kylheku
1998-03-02  5:00           ` Scott Fluhrer
1998-03-02  5:00           ` Martin Harvey
1998-03-03  5:00           ` Larry Kilgallen
1998-02-24  5:00   ` Wildfire and NT David Hinds
1998-02-25  5:00     ` brianh
1998-02-25  5:00     ` Del Cecchi
1998-02-24  5:00   ` Bill Moyer
1998-02-25  5:00     ` Larry Kilgallen
1998-02-25  5:00       ` brianh
1998-02-25  5:00         ` Epiphanies (was: Wildfire and NT) Carlie Coats
1998-02-25  5:00     ` Wildfire and NT John Hascall
1998-02-25  5:00       ` Rob Rodgers
1998-02-25  5:00   ` Bernd Paysan
1998-02-25  5:00     ` brianh
1998-02-26  5:00       ` Doug
1998-02-26  5:00         ` Jeffrey S. Dutky
1998-02-26  5:00       ` Bernd Paysan
1998-02-27  5:00         ` brianh
1998-03-01  5:00           ` Ketil Z Malde
1998-02-27  5:00   ` Paul Kahler
1998-03-02  5:00     ` Joel Gallun
1998-03-02  5:00       ` Przemek Klosowski
read-only archive

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