Re: advantages of C

From: Willem (willem_at_stack.nl)
Date: 01/31/04


Date: Fri, 30 Jan 2004 23:53:46 +0000 (UTC)


)> C++ is 'better' than C *because* it has classes.

Kevin wrote:

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

Most of these directly or indirectly have to do with classes, with the
possible exception of overloading. If, in C++, you did *not* have classes,
then what are you left with ?

SaSW, Willem

-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


Relevant Pages

  • Re: STL and "function try blocks"
    ... blocks have no value except for in constructors, ... but outside the function body. ... but I expect thay have sence in destructors too. ... exceptions in destructors are evil!). ...
    (microsoft.public.vc.stl)
  • Re: Portability
    ... The C++ language has tried to remain compatible with C. ... In this sense I mean that constructors and destructors are the ... What we need is compile time functions and an opening up of the ... Templates are the wrong solution since ...
    (comp.lang.c)
  • Re: Allocators and exceptions
    ... actually wrong vis-a-vis the language definition. ... Because there is no constructors. ... As for your concern about efficiency of construction with exceptions. ... contract and so the compiler would say - aha, this is what you want, then I ...
    (comp.lang.ada)
  • Re: advantages of C
    ... And constructors and destructors and templates and exceptions and ... inheritance and virtual functions and the STL and operator overloading ... cast to void* instead of writing template classes. ...
    (comp.programming)
  • Re: On assembly and portability (between Linux and Windows)
    ... >>any requirement to automatically call constructors and destructors. ... In order to be considered truely object oriented, a programming language ... and structure in an object-oriented computer program. ... I see no reason to require Constructors or Destructors. ...
    (alt.lang.asm)