Article View: comp.lang.modula2
Article #2598Re: Report on defect in M2 vs C (Was Modula-2, Modula-3, C or C++)
From: Robert A Duff
Date: Tue, 10 Oct 1995 20:24
Date: Tue, 10 Oct 1995 20:24
27 lines
1909 bytes
1909 bytes
In article <Pine.SUN.3.91.951010144335.13726A@lagrange.uwaterloo.ca>, Viet-Trung Luu <vluu@lagrange.uwaterloo.ca> wrote: >Well, the cost for checking in C/C++ programs shouldn't be much more than >for programs written in other languages. Is that an indication of how >slow other languages are or are you saying that C/C++ programs are >unchecked because those who use C/C++ want small fast programs? No, I don't think it's true (that checking in C/C++ is the same as in other languages). For example, in C, a variable declared as pointer-to-something might be the sort of pointer that links through heap objects (a linked list, or whatever), or it might be the sort of pointer that steps through an array. It's very difficult (and in the general case, impossible), to tell which is which. So, for a C compiler to check array bounds, it has to include several words of extra dope with every pointer, just in case it *might* be the sort that steps through an array. Other languages (e.g., Ada, Pascal, etc) make this bounds-checking much simpler, and much more efficient. >(Obviously, it is more difficult and thus "costly" to check C/C++ >programs, but not so much more than for other languages. I guess most of >the cost is due to the freedom that C/C++ allow.) But is that "freedom" useful? If you know ahead of time that you're indexing into an array, why not tell the compiler (or bounds-checking tool)? - Bob
Technical Details
Message-ID:
<DG920p.L2K@world.std.com>Path:
arc1-ca.pugleaf.net!news.kei.com!world!bobduffReferences:
<Pine.SUN.3.91.951010144335.13726A@lagrange.uwaterloo.ca>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2,comp.lang.modula3,comp.lang.c,comp.lang.c++,comp.lang.ada Path: arc1-ca.pugleaf.net!news.kei.com!world!bobduff From: bobduff@world.std.com (Robert A Duff) Subject: Re: Report on defect in M2 vs C (Was Modula-2, Modula-3, C or C++) Message-ID: <DG920p.L2K@world.std.com> Organization: The World Public Access UNIX, Brookline, MA References: <Pine.SUN.3.91.951010144335.13726A@lagrange.uwaterloo.ca> Date: Tue, 10 Oct 1995 20:24:25 GMT