Re: advantages of C

From: Kevin Cline (kcline17_at_hotmail.com)
Date: 01/30/04


Date: 30 Jan 2004 08:25:21 -0800

Willem <willem@stack.nl> wrote in message news:<slrnc0tivl.1g0f.willem@toad.stack.nl>...
> osmium wrote:
> ) The point is often made that C++ is a better C, and I agree. But I don't
> ) know of any book that one could use to learn, in a reasonable fashion, this
> ) "better C". Somewhere about chapter ten they introduce classes and the
> ) world collapses. How does the reader skip this chapter and finish reading
> ) chapters 11 though 20 without a great sense of unease?
>
> C++ is 'better' than C *because* it has classes.

And constructors and destructors and templates and exceptions and
inheritance and virtual functions and the STL and operator overloading
and ...

In C++, it's easy for me to write code that is obviously correct. In
C, life is harder. I have to manually make sure that there is a free
for every malloc, and an unlock for every lock, instead of just coding
a constructor and destructor. I have to handle error returns after
every function call, instead of handling them all together in a single
catch clause. I have to use the preprocessor, cut and paste code, or
cast to void* instead of writing template classes. I have to replace
operator expressions with function calls if I switch from a built-in
type to a user-defined type, instead of overloading those operators
for my type. I have to worry about overflowing char[] buffers,
instead of using std::string. Correctly used, C++ is a great tool for
keeping bugs out of code.



Relevant Pages

  • Re: UNIX, C, Perl
    ... I already use constructors and destructors in C, so I know what you mean, ... C is just about as modern as C++ is. ... Adding operator overloading would make it slightly less ...
    (comp.lang.c)
  • Re: UNIX, C, Perl
    ... I already use constructors and destructors in C, so I know what you mean, ... and the cost of overlooking cleanup could become ... Adding operator overloading would make it slightly less ...
    (comp.lang.c)
  • Re: UNIX, C, Perl
    ... I already use constructors and destructors in C, ... if ISO were to introduce operator overloading into C, ... of overlooking cleanup could become arbitrarily high. ...
    (comp.lang.c)
  • Re: Boost process and C
    ... YOU, because you needs operator overloading, that requires constuctors ... to define the operators to overload and destructors to undefine them. ... There no necessary connection to constructors and destructors. ...
    (comp.lang.c)
  • Re: advantages of C
    ... And constructors and destructors and templates and exceptions and ...
    (comp.programming)