Related articles |
---|
C compiler warning messages? johnr@ims.com (1997-04-06) |
Re: C compiler warning messages? trt@duke.cs.duke.edu (1997-04-07) |
Re: C compiler warning messages? morris@CAM.ORG (1997-04-08) |
Re: C compiler warning messages? chase@naturalbridge.com (David Chase) (1997-04-11) |
Re: C compiler warning messages? joshua@intrinsa.com (1997-04-16) |
Re: C compiler warning messages? morris@CAM.ORG (Morris Bernstein) (1997-04-16) |
Re: C compiler warning messages? oz@ds9.rnd.border.com (1997-04-18) |
From: | Morris Bernstein <morris@CAM.ORG> |
Newsgroups: | comp.compilers |
Date: | 16 Apr 1997 00:25:12 -0400 |
Organization: | Communications Accessibles Montreal, Quebec Canada |
References: | 97-04-042 97-04-059 97-04-064 |
Keywords: | C, debug, design |
David Chase <chase@world.std.com> wrote:
>My solution to this problem is simply to program in a language where
>such gaffes are forbidden; Java, Modula-3, Scheme, and ML are all fine
>choices. For some reason, most other people don't see the obvious
>superiority of these solutions, and they program in other languages
>like C and C++. I quit worrying about trying to educate people out of
Careful: statements like that have starteed more religious wars ;-).
According to an Authority: "The presence or absence of any programming
language feature cannot _guarantee_ defect-free programming".
Personally, Common Lisp is my language of choice for hacking around,
but I believe that a programming language should allow one to do what
is needed to to get the job done (if necessary, in CL, I can write
some critical code in C or assembler).
In my software engineering course, I use C to teach the students how
to use power tools without getting their fingers cut off. Sure you
can create big messes in C/C++, but you can also get the job done if
you're a professional and you know what you're doing. It _is_ an
educational issue.
I agree that C was never intended for building applications and as a
compiler writer, I know that you can usually generate better code if
the language is constrained in almost exactly the sort of way C isn't,
but the market has spoken. The customer may not always be right, but
the customer is the customer.
For prototyping, I'd generally prefer to use anything from 4GLs to
Smalltalk, CL, or Prolog, but I generally feel more comfortable
building large applications using C/C++. I use the lower-level
language to implement application-domain concepts (as modules or
objects, or whatever we're calling them this week) and then use those
words to build sentences.
IMHO, one of the most important features of a programming language is
that it not get in my way. Usually, this means the programming
language should be shaped to match the problem domain. C is very
suitable for bit tiddling, and people are still thinking very much in
those terms. At least, most programmers want control down to that
level (even if you could convince them it's less efficient).
>shooting themselves in the foot, and have spent the last few years
>either increasing performance of the firearms ("now with faster
>bullets"), or building better diagnostic equipment ("that there is a
>hole in your foot").
That's reasonable. One of the ways to recognize experts is by the
quality of their tools and how they use them.
>> [It's certainly useful to warn about returning a direct reference to an auto
>> variable, which is an error 99+% of the time. Saber C is indeed still around,
>> now it's called Code Center and the vendor is called Centerline. -John]
I agree that "return &local" is almost certainly an error, but it's a
special case and the general case can be handled effectively using an
interpreter. How many ad hoc special cases do we want to add to the
compiler? Maybe we should create separate checkout and optimizing
compilers. Waitaminute, it's been done already.
Flame retardant: I'm not saying that there shouldn't be special cases
handled in a compiler. I'm not even saying that this special case
shouldn't be handled. What I am saying is that there are costs in
adding special cases and engineering is about weighing the costs with
the value they produce.
BTW, I did know about the name change to Centerline, but had
temporarily forgotten. I used the product way back when it had the
old name and was really impressed with it. Unfortunately, for various
reasons, I haven't been in a position to convince subsequent
employers.
>Code Center is probably still available, but they sell a newer product
>called "C++ Expert", which also handles C just fine. I ran your
>trickier example through the demo server that CenterLine has on the
>web (http://lumiere.centerline.com:9000, when the machine isn't
>crashed), and it did a pretty good job of complaining about it and
>pointing out the offending line (this is running in batch mode, of
>course).
...
>David Chase
>(a former CenterLine employee, who worked on this very product, and
>wrote the demo server, too.)
Cool.
Morris
--
Morris Bernstein morris@cam.org
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.