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


In article <6de8o0$kau$1@seagoon.newcastle.edu.au>
           peter@ee.newcastle.edu.au "Peter Moylan" writes:

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

I'm not convinced that even with a 386 you could create a usable finely
segmented environment.

...

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

How you you like to see it used?

...

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

That's an argument for using C with a segmented environment so that these
checks can be performed efficiently at runtime.

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

Such software that it would break wouldn't be very portable anyway. What sort
of common practices require the use of out of bounds pointers?

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

The rules about bounds violations are specifically to allow C to be
implemented in non-linear environments. Going out of bounds with pointers
usually is an error (i.e. something that the programmer didn't intend). I
don't think the problem is as big as you're suggesting. Non-portable
assumptions about datatype sizes and alignment tend to be a bigger issue.

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

Sure, but we were discussing the compatibility between C and segmented
environments, not code quality. Good code will run whether the environment
is segmented or not.

>Furthermore, I have continued to resist the modern practice of
>charging an "upgrade" price for bug fixes that are delivered a
>year late.

I've no reason to doubt your competence and professionalism as a software
developer. You were however making some incorrect assertions about C and
appeared to be making value judgements based on those.

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

Right, but that is a different topic entirely to what we were discussing.

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

It takes a little more discipline to write error-free software in C but
it really isn't that hard. The language has progressed significantly since
the 1970's. 

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

Don't close your mind to the fact that people like the language on its
own merits. From what I've seen instructors are driven by demand and not
not the other way around. C survives despite the fact that it is no longer
the trendy language, instructors are much more interested in teaching C++
or Java.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------




  parent reply	other threads:[~1998-03-03  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     ` [++] 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         ` Larry Kilgallen
1998-03-01  5:00           ` [++] Tight coding (comp.sys.dec-only thread) Bill Moyer
1998-03-01  5:00         ` [++] Tight coding 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               ` 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             ` Kaz Kylheku
1998-03-02  5:00         ` Peter Moylan
1998-03-02  5:00           ` Scott Fluhrer
1998-03-02  5:00           ` Lawrence Kirby
1998-03-02  5:00             ` Peter Moylan
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 [this message]
1998-03-02  5:00           ` Kaz Kylheku
1998-03-02  5:00           ` Martin Harvey
1998-03-03  5:00           ` Larry Kilgallen
1998-02-25  5:00     ` Wildfire and NT Mike Albaugh
1998-02-25  5:00     ` Maynard Handley
1998-02-25  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-25  5:00   ` Wildfire and NT 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