From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,37e683828bae12e2 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,37e683828bae12e2 X-Google-Attributes: gid1014db,public X-Google-Thread: 1164f8,b0b9a5eaad4ab6eb X-Google-Attributes: gid1164f8,public X-Google-Thread: f8c65,37e683828bae12e2 X-Google-Attributes: gidf8c65,public X-Google-Thread: 1008e3,37e683828bae12e2 X-Google-Attributes: gid1008e3,public From: fred@genesis.demon.co.uk (Lawrence Kirby) Subject: Re: [++] Tight coding Date: 1998/03/03 Message-ID: <888889283snz@genesis.demon.co.uk> X-Deja-AN: 330243270 References: <6csl81$rb9@news-rocq.inria.fr> <34F3B7C5.5FD1@earthlink.net> <34F49435.B6307838@hda.hydro.com> <6dbgjv$lg$1@andros.cygnus.com> <888802209snz@genesis.demon.co.uk> <6de8o0$kau$1@seagoon.newcastle.edu.au> X-Mail2News-Path: genesis.demon.co.uk Reply-To: fred@genesis.demon.co.uk X-Mail2News-User: fred@genesis.demon.co.uk X-Complaints-To: abuse@demon.net X-Trace: mail2news.demon.co.uk 888894228 6011 fred genesis.demon.co.uk Organization: none Newsgroups: comp.sys.dec,comp.lang.c++,comp.lang.c,comp.lang.modula2,comp.lang.modula3 In article <6de8o0$kau$1@seagoon.newcastle.edu.au> peter@ee.newcastle.edu.au "Peter Moylan" writes: >Lawrence Kirby wrote: >>In article >> 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 -----------------------------------------