John Reid wrote:
> Hi Franck, all,
> I wrote this prior to Alastair' s mail. Might expand on a few issues. Alastair -
> any comments, especially about the bounds checking and C++ templates? You sound
> like you know a lot more about this stuff much more than I do. I'm just a sysadmin
> with an interest in GIS, not a quality hacker.
Well, thanks. Comments below. I have been more involved in the
programming side of
things for years, and I've been through the C vs C++ wars before --
while working at
a GIS company :-)
> That's not my problem - try thinking about the potential scope of what we are
> trying to achieve. That has got me scared <insert expletive[s] of choice>! With
> that in mind, I think we should make every attempt to:
> * Make maintainability a very high priority
Agreed! *Especially* with open source projects.
> * Interoperate with related projects - in fact avoid all duplication of effort
> where possible (that is one of the reasons we are working with a standard,
> isn't it?). I hate to use the work synergy, but ... aren't we trying to
> achieve a "GnuGIS"? (thanks Adrian Custer - speaking of whom, I should go and
> re-read that paper of his).
Also agreed in principle. Has anyone done a survey of "related
projects" to get
some idea of both how to best achieve interoperability and avoid too
(I've done some -- that's how I stumbled onto FMaps when working on
> My understanding is that :
> * C is retained as a subset of C++
Mostly true. I believe that strictly speaking standard C isn't a
perfect subset of
standard C++, but darn near it. But there's a danger there... (see
> * C++ can use the same function call and return sequences as C (in conjunction
> with the 'extern "C"' linkage directive).
True, as I mentioned in an earlier message.
> > Secondly gnome has
> > implemented C++ type objects in C with not too much trouble... Just have a look
> > on any gnome source (cvs.gnome.org)..
I haven't looked closely at the gnome source, but I have seen other
implement C++ in C. I suppose once you get used to it it's usable, but
it's a maze of structs containing pointers to functions and other
structs that quite
honestly leaves me wondering "why not let the C++ compiler deal with all
Really, except for the name mangling (humans tend to do a better job),
looks a lot like what the old cfront C++ to C preprocessor produced.
> Can you please give me an example? It might actually be C++ code (see gcc comment
> above). Also, what about methods? IIRC, that is one of the main differences
> between the two language standards - the ability to explicitly attach behaviour to
> the "data type".
They do it by including function pointers in structs. I've seen the
in C even before C++ gained wide popularity.
> The reason that I am pushing C++ is that, as far as I know, inheritance is a
> concept alien to C. If used properly (and I'm not sure I know how to do that - so
> any advice much appreciated!), I think this could have very real benefits for the
> FMaps project. The ISO schemas are defined using an OO modelling approach, so to
> me it only makes sense to use an OO language. Out of the choices available, C++ is
> probably the simplest to adopt (even though it may not be the best technically - I
> vaguely recall Eiffel being touted as a candidate for this by some OO gurus).
Use of an OO language to solve problems in an OO domain always made
sense to me.
My personal preference might be something like compiled-to-native-code
I don't think we're there yet. So yeah, C++.
> I also think that in the long run (we are programming for posterity, aren't we?)
> C++ is probably easier to maintain. See my comments about pointers in previous
> mails - I think they are abstracted to a large extent in C++, thus making it easier
> for mere mortals like myself to understand.
Here we get to the danger of C++ being a superset of C.
Because it is, it means that all the bad and horrible things that one
can do in C
one can also do in C++, and worse. That doesn't mean you *have* to,
but most of
the really horrible C++ code that it has been my displeasure to maintain
confess to including some of my own in there) was written by programmers
C first. A weird hybrid of OO and non-OO. (Now true, some of it dates
early versions of C++, which didn't support "OO-ness" as well as current
C++ does, so
there's at least some small excuse.) C++ as it is now taught seems to
be a lot
cleaner. (My wife just went through a "high tech boot camp" to retrain
a materials engineer to the IT field, so I got a chance to see
reasonably close up
how they're teaching C++ these days. I'll admit that *I* learned stuff
her with her homework.)
> AFAIK, C++ is also supposed to have
> better type checking. Also has nice features like the String class, so we don't
> have to worry about bounds checking to the same extent (think buffer overflow
> attacks, or even just the joy of not having to code tests for overflow events
> etc.). Am I correct in this assumption?
To a degree, yes, although perhaps you're thinking of Java which goes
in this regard.
> Please note that this is all theoretical knowledge on my part. Last time I did any
> C++ coding (or any real coding for that matter) was about 10 years ago. I seem to
> recall a large disparity between the OO modelling paradigm as I perceived it and
> what it implied for code reuse, and the actual language implementation. In fact
> IIRC, back then it was a pig of a thing due to this mismatch impedence between the
> model and available compilers, resulting in probably no real benefit over C. Then
> again, that was before templates :-) Now I think it might be the way to go. Does
> anyone with more recent experience (especially with respect to templates) have any
> comments about this?
You're exactly right. I was an "early adopter" of C++ back when we had
to do our
own port of Bell Labs' "cfront" to the systems we were working on.
Then it was
basically "C with classes". It's much cleaner, from an OO sense, now.
> This (templates) also raises the issue of portability. I would prefer to take the
> approach that if gcc supports a feature (as long as it is part of the language
> standard), then we should not be afraid to use it. I have heard "Bad Things" about
> some other compilers - apparently in one instance a new version of "another
> company's" compiler was unable to successfully compile code that had been generated
> by a previous version of the same compiler! So I don't think we should worry to
> much about them - their job to fix it, not our's to pander to compiler quirks.
Agreed. The source is there, if they want to make it work with an
then go for it. I wouldn't turn down such patches, but I'd focus on
work with available free software.
> gcc should give us support without too much pain for the linux and Mac OS X
> platforms at least. As far as Windoze goes, I really don't care on way or the
> other. My day job is a Neanderthal Technologies sysadmin, and it is a constant
> source of amazement to me that such a cruddy family of operating systems has such a
> large share of the market.
Looked at what's on TV lately? :-) I don't recall who said it, but
quote to the effect of "nobody ever went broke by underestimating the
of the American public". Sigh. Probably explains AOL, too. :-)