L
Laurent Deniau
I had wanted to take a stab at it, but:
1. COS is not actually available on SourceForce except through CVS.
Not very convenient.
Right (sorry for this), I am working on the tarball for next week. I
still need to improve install/uninstall targets of makefiles and some
minor things.
2. The COS Makefiles do not build. It appears you used something like
autoconf but did not actually include a configure script in CVS.
It's only makefiles, but it requires gmake (tested with gmake 3.81).
There is no configure or so to run.
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.
COS is actually tested on MacOSX and Linux since I don't have access
to other architectures. Makefiles are not portable to Windows unless
you install cygwin or equivalent. The config file are not yet done for
it. Maybe you tried on a yet unsupported architecture? The structure
of the makefile is similar to the makefiles of POCO++.
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.
Like? AFAIK, the COS features are unique in a single "language". The
closest would be a mix between Objective-C, CLOS and Dylan.
Why did you fail to do it in C++? What specific problems are you
referring to?
- COS needs a C99 preprocessor. Maybe the next release of C++ will get
the equivalent.
- the object model is completely different from the C++ one and it's
rather difficult to combine the two.
- multi-method would have to deal with lookup, overloading and
templates. This is far beyond the capabilities of my macros.
Issues with... type checking or something?
no, it's not an issue. C and C++ are close enough on that point. In
particular, all COS objects are structures, which make the objects
system strongly statically typed in both languages except that C++
would provide subtyping while C doesn't.
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++".
This paper is about C89. Nevertheless, I do not use C++ keyword (eg.
self and not this for my receivers).
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.
Probably not. In C++ you must stay compliant with the existing. Issues
are those already mentioned, but also management of multi and virtual
inheritance, portability of "generic" pointers to (member) functions
and template functions, support for meta-classes with the unicity of
the ids (not ensured by C++), etc...
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++...
Yes. But the "normal way" in C++ would be double (or more) dispatch on
top of the C++ object model. This is not easy to automatize nor
efficient (this is the way multijava works). The dispatcher of COS is
as fast as C++ virtual member functions on Linux 64bits with gcc4.
Same deal with messaging systems, which are just as trivial to
implement in C++ as they are in C.
Not exactly. Dispatch is not the all story and it's far beyond this
thread to explain the all story. In order to get an idea, you can
still read the slides
http://cos.cvs.sourceforge.net/viewvc/cos/CosBase/share/doc/cos/slides-cos.pdf.gz
or the paper (longer, obsolete, but gives an idea)
http://cos.cvs.sourceforge.net/viewvc/cos/CosBase/share/doc/cos/cos-overview.pdf.gz
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.
Neither me ;-) I am just looking for the right tool for my need
(numerical computation & simulation).
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.
This is more related to C++. In fact you can also have a look at the
second half of the presentation once you have read the COS
presentation. This is a kind of "motivation for COS".
http://cos.cvs.sourceforge.net/viewvc/cos/CosBase/share/doc/cos/slides-design.pdf.gz
You can also google about "strong typing vs strong checking" to get an
idea why I changed my mind and introduce more dynamics in my code.
a+, ld.