[ome-devel] Existing client side code in C
Zachary Pincus
zpincus at stanford.edu
Fri Aug 6 19:02:18 BST 2004
Thanks Harry for your vote, and for your earlier advice.
The primary advantages of C++ are as follows:
(1) Much more natural syntax for dealing with the data transfer
objects. Since they need to maintain internal state (e.g. a "tainted"
variable and so forth), they need to be abstract data types in C, and
not just bare structs. ADTs are just a little harder to write, use, and
maintain than real objects in C++: less simple call semantics, no
equivalent of dynamic_cast<> for type-safe down-casting (I'd actually
have to provide one), and nastier memory management (easier for a
client to introduce leaks by freeing a DTO* but forgetting to call the
explicit "destructor").
(2) The concomitant decrease in amount of code written (and bugs
introduced!) with the amount of for-free functionality from the
language.
(3) Subclassing mechanisms to further decrease the amount of
auto-generated code. (Easier to fix a bug in a superclass than fix the
bug in the code-writing code and regenerate that code.)
(4) Much easier to generate a clean OO SWIG interface for higher-level
scripting languages if the code is C++ rather than C.
That said, these advantages aren't that huge and certainly aren't
deal-breakers for me. I'm fairly neutral between the two language
choices... especially if more people would be able to use a C version.
I just wanted to know to what degree people's usage scenarios seriously
blocked a C++ implementation.
Anyhow, if I get a couple more votes either way (IIRC, Ilya also voted
for C earlier, and Doug thinks that's a good idea too) I'll stop my
dithering and finally get started on this all.
Zach
<ramble>It's just too bad that it took five years for C++ compilers to
match the ANSI spec (blame should be applied liberally: it's a
sprawling and complex spec [templates are turing-complete!], and they
didn't define an ABI so that code compiled with different compilers
can't link together) so that even now it's not considered as portable
as C.
On Aug 6, 2004, at 7:03 AM, Harry Hochheiser wrote:
> Zach:
>
> I'd vote for C if it's not too much harder. The
> portability/flexibility are very appealing.
>
> But then again, I'm not the one doing the work.
>
> Can you be a bit more specific about how/what would be easier with C++?
>
> thanks,
>
> harry
>
More information about the ome-devel
mailing list