On Dec 27, 6:58*pm, Laurent Deniau <Laurent.Den...@gmail.com> wrote:
> On 27 déc, 20:24, Rolf Magnus <ramag...@t-online.de> wrote:
>
>
>
> > Laurent Deniau wrote:
> > >> Now, are you saying that, as a conclusion, C++ is better than C
> > >> (because there's no difference in performance, yet C++ has more
> > >> features), but programmers still use C just because they're used to?
>
> > >> And in that case, all newbies should be advised to learn C++, right?
>
> > > C++ is not a super set of C
>
> > It can be used as one.
>
> > > and is much more complex which means that "average" C++ programmers may
> > > have some difficulty to predict the behavior of their code. There is also
> > > things which are "easy" to do in C and nearly impossible in C++.
>
> > Which would that be? Most C code can be put through a C++ compiler with only
> > a few minor changes.
>
> I would be very interested (honestly) by the "few minor changes" to
> apply to COS (C Object System) to be able to compile it with a C++
> compiler. It compiles with a C99 compiler or even with a C99
> (standalone) preprocessor and a C89 compiler.
I had wanted to take a stab at it, but:
1. COS is not actually available on SourceForce except through CVS.
Not very convenient.
2. The COS Makefiles do not build. It appears you used something like
autoconf but did not actually include a configure script in CVS. The
compilation instructions in your README are incorrect. After looking
for the source of the problem and seeing the number of environment
variables that were not defined (e.g. everything checked for by the
'prologue' include file), I gave up.
3. While it's certainly an interesting project, you seem to have
reinvented a serious wheel. If a developer used COS in an application,
then more likely there were better tools for that developer's job than
C in the first place.
> > > I have been using C++ from 1989 to 2006 and switch back to C for this
> > > reason once I found the programming techniques that fit my needs. Before
> > > doing the switch, I used (and abused) templates and I studied in depth the
> > > C++ object model to understand what I could(n't) do. As already said, the
> > > best is to use the language that fits your needs.
>
> > I can see uses of templates even down to the smallest microcontroller
> > devices (and have actually used them there).
>
> I didn't say that you can't or it's useless. I just say that I tried
> to implement some features (e.g. multi-methods, messages) which I
> consider today to be very important in a language and failed to do it
> in C++ while it was relatively easy to do in C.
Why did you fail to do it in C++? What specific problems are you
referring to? Issues with... type checking or something? It's fairly
straightforward to compile C with a C++ compiler; most of the changes
involve adding explicit casts and changing names that are now C++
keywords (e.g. "class").
Most issues are described here:
http://docs.hp.com/en/92501-90029/ch01s03.html
, search the page for "changing your C programs to C++".
C does not have support for multi-methods, nor does C++, in both
languages you have to emulate them some other way. I can certainly
imagine various schemes for implementing them in C++; they are
probably similar to what you did in C. What is it about C++ that you
found to be a barrier to implementing these? There are plenty of ways
to do runtime type checking in C++...
Same deal with messaging systems, which are just as trivial to
implement in C++ as they are in C.
Jason
P.S. Just to set the tone, I don't have a problem with C at all, and
still use it for some applications. Mostly I'm wondering if you've
actually been having issues with C++, or if the issues are because
your implementation attempts failed for other reasons.