Why is not more FreeBSD software written in C++?
Dag-Erling Smørgrav
des at des.no
Sat Apr 22 17:36:08 UTC 2006
Don Dugger <dugger at hotlz.com> writes:
> But "streams" have been around a lot longer then c++. I first encountered
> them in AIX protocol stacks. Didn't like 'em then either.
SysV streams and C++ I/O streams are completely unrelated (except that
they both originated at AT&T and one probably inspired the other)
> Although the idea of pushing functional units down a pipe does seem
> interesting, however I have never found it works very well in
> practice, and the reason was always performance.
No "functional units" are being "pushed down the pipe" with C++ I/O
streams. The << stuff is mere syntactic sugar. What happens is
simply that the correct function is called to format each element and
pass it to the output stream.
> I think the problem is in fact is a general problem the more under
> lying functionality you have the less performance.
Wrong. Higher-level constructs allow the compiler more latitude to
optimize the code. This is why well-written Lisp, for instance, can
outperform well-written C (provided you use a decent Lisp compiler).
> If you need to you can use the c lib stuff and only use the c++
> added functionality when it pays to. After all some of the c++ stuff
> is just better, "//" comments and passing by reference and etc.
// comments are neither better nor worse than /* */ comments, and they
have been available in C for seven years now.
C++ references are very nice, but almost impossible for a non-expert
to use properly (any object passed by reference *must* be of a class
which has a correctly designed copy constructor)
> I think the reason streams was added to c++ early on was that a lot
> of people didn't like printf(), the found it hard to use, which I
> never understood.
Nobody claims printf() is hard to understand, but it is neither
extensible nor type-safe.
What C++ lacks to be a top-notch OO language is garbage collection and
iterators which aren't a PITA to use. Both will be present in C++0x.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-chat
mailing list