user923005 said:
C collections are scattered all over the place. You have to look for
numerical code in one place and data structures code in another, etc.
Hence my suggestion for a single Well-Known Portal - so well-known that
everyone would know to try it first when looking for libs.
I think that the reason CPAN and BOOST don't exist for C is that it is
almost impossible to create them. We had this discussion before about
creating a generic data structures and algorithm library for C ["C
needs a BOOST"], and the general consensus was that it was too
difficult.
The library is easy. It's the consensus that's difficult. Getting everyone
to agree on an interface is a Sisyphean task.
But that's just it -- writing an algorithm with a generic interface in
C is a difficult task.
I can write an algorithm that works on an array of doubles. But will
the same algorithm work on a linked list of structs?
In C++, the STL gives you iterators so that diverse types of lists
work the same. And templates give the ability to make the data object
generic.
In order to accomplish the same thing in C, I think you have to write
a new version for different implementations or at least jump through a
bunch of hoops.
The reason that there has been consensus in C++ is that designing a
functional interface in that language is easy due to the fascilities
of the language.
If it were just as easy in C, someone would have done it by now.
Especially since C has been around much longer than C++.
The obstacles are not technical, but political.
I think that both kinds of obstacles exist, and the technical ones are
bigger.
Another advantage of C++ for this sort of thing is abstraction. Sure,
it's just syntactic sugar, but if syntactic sugar were not important
we would all code in assembly.
For instance,
if (a < b) {/* do stuff */}
compared to:
if (compare(a,b) < 0) {/* do stuff */}
hardly seems any simpler. But when you have a page full of this kind
of stuff, it becomes much easier to grasp in the more compact
notation. Now, in C++ we are going to have to write a whole MESS of
operator overloads to get the same functionality as a compare()
function:
operator <
operator <=
operator ==
operator >=
operator >
operator !=
but once you have done the work, the ease in notation makes
programming more natural. I realize with trivial examples the
statement sounds silly (e.g. up above, nobody will have difficulty
with either comparison). But when you have pages and pages of this
stuff (consider an extended precision number class verses an extended
precision C library) it is definitely worth it.
Now, I will grant you that *anything* you can do in C++ *could* also
be done in C {or assembly, for that matter}. But the added level of
difficulty means that it probably won't be anyway -- even though it
may be possible.
I would absolutely *love* to be proven wrong about this and wake up
some morning to find an STL and BOOST equivalent for C. But I
certainly am not going to hold my breath waiting for it.