Re: Why We Use C Than C++...



> Another important factor is that C++ requires more run-time support
> code to work properly.

Nope.

The objective of C++ is that you do not pay for features you do not
use.

C++ is not faster or slower than C if you DO the same.

For example: C functions have no parameter "this". But static C++
function do not have a "this" parameter either.

So, compare only apples with apples....

I use C++ in an embedded environment. Mostly because of it's better
code encapsulation. You can write small and lean wrappers for
interfaces that actually contain mostly inline functions. So you have
no overhead but you can protect the user of your class from using it in
an unwanted way much better than in C, i.e. forget to call init in C
vs. do the init within the constructor.

There are a lot examples of C++ features that are done at compile time
and have no effect at runtime. They all help you to write more robust
code. Reference objects vs. pointers, const methods, const return
values and all this stuff...

The are only 3 reasons to use C over C++:
- you have no decent C++ compiler for your platform
- you have to continue a C project
- you are not allowed to use C++ because your boss still believes that
C++ is SLOW

Greets

Henryk

.



Relevant Pages

  • Re: allocatrouble arrays
    ... Intel the relative overhead was small compared to the AMD. ... For arrays not passed out to any subprograms, ... feeling that specifying information known at compile time could only do ... But I know I'm a bit too eager about new features like this, ...
    (comp.lang.fortran)
  • Re: dynamic vs. static: the age-old debate
    ... compile time is not wanted. ... language; it doesn't somehow make your language dynamically typed, ... the lang is actually intended to be a little closer to statically typed, ... offers a lot of traditionally dynamic features (lexical closures, ...
    (comp.lang.misc)
  • Re: Which programming language is better to start
    ... >> It may happen that some features in LISP render slower implementations ... > In that kind of situations, static typing gets in the programmer's way ... discover many mistakes at compile time. ...
    (comp.programming)
  • Re: Program to convert binary <-> gray
    ... intent; remove while; and assumed-shape arrays. ... Those features can justify ... compile time and run time and because code can be easier to ...
    (comp.lang.fortran)
  • Re: [PATCH 1/3] firmware: allow firmware files to be built into kernel image
    ... But do we need the firmware after init? ... In other owrds could it be inside a discard after init block? ... Let us get it working as is - then we can add such features later. ... want to avoid taking kernel memory, ...
    (Linux-Kernel)