Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: peter@PJM2.newcastle.edu.au (Peter Moylan)
Subject: Re: [++] Tight coding
Date: 1998/03/02	[thread overview]
Message-ID: <6de8o0$kau$1@seagoon.newcastle.edu.au> (raw)
In-Reply-To: 888802209snz@genesis.demon.co.uk


Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
>In article <slrn6fk0pe.5t2.peter@eepjm.newcastle.edu.au>
>           peter@ee.newcastle.edu.au "Peter Moylan" writes:
>
>...
>
>>One of my major gripes about C is the strong influence it's
>>had on operating systems design.
>>
>>We have memory segmentation.  We've had it for years.  What
>>we don't have are operating systems that make proper use
>>of the segmentation hardware.
>>
>>It's true that the earliest attempts to introduce segmentation
>>were killed off by considerations of hardware cost and speed.
>>But those problems were solved some years ago, when the
>>80286 first appeared.
>
>The 8086 and 80286 employ segmentation as a hack to increase memory
>address space. It is totally inadequate as a vehicle for providing the
>benefits of a true segmented archetecture.

You're mixing two things here.  The 8086, it is true, did not have hardware
segmentation.  The 80286 did.  It had some shortcomings - e.g. the
limit on segment size - but this was still better than no segmentation at
all.  Some of the shortcomings were removed in the 80386.
>
>> Once you can get the segmentation
>>hardware onto the processor chip, and have some space left over
>>for decent-sized caches, you've got the technology to bring
>>segmentation to the masses at an affordable cost.
>
>Perhaps, but it is the x86 archetecture that has given segmentation a bad
>name, not any specific programming language.

Specifically the 8086.  Yes, I agree.  Intel tried to say that the 8086 had
a segmented address space; the programmers discovered that it
didn't; and then companies like Microsoft simply ignored the segmentation
hardware of the 80286 and treated it as a pseudo-8086.  Subsequently
operating systems like OS/2, Windows NT, and Linux used a small
subset of the segmentation possibilities, just enough to get a large
address space without going all the way towards using true segmentation.
What's worse, the majority of 80x86 users are still running DOS shells
like Win95, which treat the segmentation hardware like an add-on kludge.
The hardware supports true segmentation, the system programmers don't.

>>The catch is that you have all those C programmers demanding
>>a "linear address space". [...]
>
>ANSI C is designed to work in a segmented archetecture, it in no way
>requires a linear address space. It is invalid in ANSI C to perform
>pointer arithmetic beyond the bounds of the current object (except a
>one-past-the-end-rule which isn't a major issue). == and != can be used
>to compare pointers into different objects but not > >= < or <=. Every
>variable you define and every object you allocate with malloc/calloc/realloc
>could be placed in a different segment and that would be a valid ANSI C
>implementation. The standard was quite carefully crafted to make an
>efficient implemenattion of the language possible on a segmented
>archetecture.

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.)  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.

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".
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".

>>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.

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.

I'm going to be flamed for saying this, but I'll say it anyway.  The
C programming language was good for its time, but it became
obsolete somewhere in the 1970s.  There are just two reasons why
C remains in widespread use today.  First, the incredible but
growing conservativeness of today's CS instructors who work
so hard at protecting their discipline from the heresy of innovation.
Second, the fact that it's still possible to make a profit delivering
buggy products.

-- 
Peter Moylan                       peter@ee.newcastle.edu.au



  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   ` 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     ` John Hascall
1998-02-25  5:00       ` Rob Rodgers
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-24  5:00   ` Wildfire and NT Sean Burke
1998-02-25  5:00     ` brianh
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             ` Martin Tom Brown
1998-03-02  5:00             ` Terry Moore
1998-03-02  5:00               ` Kaz Kylheku
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-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           ` Kaz Kylheku
1998-03-02  5:00           ` Lawrence Kirby
1998-03-02  5:00             ` Peter Moylan [this message]
1998-03-02  5:00               ` Kaz Kylheku
1998-03-02  5:00               ` Ketil Z Malde
1998-03-04  5:00                 ` Lyn A Headley
1998-03-03  5:00               ` Lawrence Kirby
1998-03-02  5:00           ` Scott Fluhrer
1998-03-02  5:00           ` Martin Harvey
1998-03-03  5:00           ` Larry Kilgallen
1998-02-25  5:00     ` Wildfire and NT Maynard Handley
1998-02-25  5:00   ` Bernd Paysan
1998-02-25  5:00     ` brianh
1998-02-26  5:00       ` Bernd Paysan
1998-02-27  5:00         ` brianh
1998-03-01  5:00           ` Ketil Z Malde
1998-02-26  5:00       ` Doug
1998-02-26  5:00         ` Jeffrey S. Dutky
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