[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FileAccess: C or C++ ?

On Thu, 12 Nov 1998, Christian Reiniger wrote:

> Eelke Klein wrote:
> >> C is more controllable (in terms of size and speed), but C++ makes it
> >> easier to handle the dir structure etc.
> >As long as performance is not really critical it's better to use c++
> >streams because its stronger typed, this will make it easier to write
performance _is_ critical.  As is code size.

> >So as long quality and correctness is more important then speed I would
> >say c++ otherwise c should be used. This asumes that the c file
> >functions are faster then streams which I believe is allmost allways
> >true, thought I did not test it.
I think you might be surprised here.  There is no inherent reason
why C++ streams shoud be slower.  (They all have virtualization anyway).
Under GNU there is some complicated thing where they both use libio
which is part of the c++ library, or something, it's weird.  Go
look in /usr/inlcude and see what you can figure out.

> I mean - the C++ reatures I cited above AFAIK don't slow things down if an
> averagely (expr?) well optimizing compiler is used (such as egcs).
It has to do with the library. If you don't use the << operatiors,
I can't see any reason why even a naive library should be slower
than stdio.  If you _do_ use them, I think the C++ spec allows
the libary to do some weired c++ stuff involving type conversion
opertions etc. to optimize with.  Not sure about that last bit though.