Re: why still use C?
From: Jeff Mitchell (quixoticsycophant_at_yahoo.com)
Date: 10/10/03
- Next message: Mark McIntyre: "Re: Carriage Returns"
- Previous message: Severian: "Re: Source"
- In reply to: Sidney Cadot: "Re: why still use C?"
- Next in thread: Sidney Cadot: "Re: why still use C?"
- Reply: Sidney Cadot: "Re: why still use C?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Oct 2003 15:40:02 -0700
Sidney Cadot <sidney@jigsaw.nl> wrote in message news:<blqeq9$1lc$1@news.tudelft.nl>...
> I can't answer for people in general of course, but as a moderately
> able C programmer with a thorough dislike of C++ I can try to
> explain what my motives are.
<snip>
That was an excellent response, thank you.
For my current work (programming for an embedded device), use of C++
over C is really a matter of notational convenience. I turn off
exceptions and I do not use templates save for one trivial vector
class (hand-written, not STL).
By notational convenience I mean,
(1) I don't need to say self->data, I can just say m_data. It doesn't
sound like a big deal, but all that s-> clutter really adds up.
Applications for this device cannot use static data, so every
piece of data must come from a struct or class.
(2) The ARM CPU doesn't have floating point. It is an enormous
advantage to define my own fixed-point class with +, -, *, /, etc
operators.
(3) Virtual functions are used but not common. In this regard I trust
my C++ compiler. There is very little difference in code size. I
always know which virtual functions are overridden by which
subclasses so it's just a "distributed switch statement".
(4) I get a warm, fuzzy feeling using socket.open() verses
My_Library_Socket_open(socket). You could call this a straw man,
but I am especially careful about name clashes. The alternatives
are (a) to be not so careful or (b) to rig function pointers
inside structs. I don't like either.
(5) 'extern "C"' can be used if you want an application such as
Mathematica to call into your C++ library. In fact, that's
exactly what I'm doing.
What is your opinion on using a limited subset of C++, if only for
convenience?
Jeff
- Next message: Mark McIntyre: "Re: Carriage Returns"
- Previous message: Severian: "Re: Source"
- In reply to: Sidney Cadot: "Re: why still use C?"
- Next in thread: Sidney Cadot: "Re: why still use C?"
- Reply: Sidney Cadot: "Re: why still use C?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|