Repository of C code

K

Khookie

Hi everyone

I was at an open source conference in Brisbane, Australia not so long
ago, and I can recall a few individuals discussing starting up a C
equivalent of CPAN (i.e. a large centralised repository of C code).

So I thought I might ask people on clc - whether such a thing exists
already?

Chris
 
S

santosh

Khookie said:
Hi everyone

I was at an open source conference in Brisbane, Australia not so long
ago, and I can recall a few individuals discussing starting up a C
equivalent of CPAN (i.e. a large centralised repository of C code).

So I thought I might ask people on clc - whether such a thing exists
already?

snippets.org
 
P

Paul Hsieh

Hi everyone

I was at an open source conference in Brisbane, Australia not so long
ago, and I can recall a few individuals discussing starting up a C
equivalent of CPAN (i.e. a large centralised repository of C code).

So I thought I might ask people on clc - whether such a thing exists
already?

Not really. There just isn't any culture for that sort of thing in
the C programming language. You need only look to the C library to
see how the language encourages mediocrity error, with no regard to
scalability or robustness. I mean what would such a collection be
building on top of?

I've written a few things here and there that some people have taken
up (a string library, a stdint.h replacement, some square root code, a
CSV parser and a hash function that people apparently can't get enough
of.) Ben Pfaff has written some Red-Black tree thing that apparently
gets used. But there just doesn't seem to be a critical mass of such
stuff that's enough for people to want to put it together to continue
to build/support a culture for C programming. C has really just
become a language for (embedded) systems drivers and virus writers.

You would probably be happier with C++. They started with STL, and a
lot has been added via "Boost". The way forward with C can only be
through C++. C itself is basically heading in the direction of COBOL,
and thus its hard to motivate a community to build something like CPAN
or Boost for it.
 
O

Owen Jacobson

Not really.  There just isn't any culture for that sort of thing in
the C programming language.  You need only look to the C library to
see how the language encourages mediocrity error, with no regard to
scalability or robustness.  I mean what would such a collection be
building on top of?

Not to mention the problem of coming up with even a loose standard for
packaging and build information that everyone will be happy with. Not
even 'make' is portable enough, I think. The Windows guys want
something that Visual Studio, Dev-C++, or MinGW can build (depending);
the Unix guys want make(1)files and don't like being told not to use
POSIX, and the end users just want pretty 3D effects...
I've written a few things here and there that some people have taken
up (a string library, a stdint.h replacement, some square root code, a
CSV parser and a hash function that people apparently can't get enough
of.)  Ben Pfaff has written some Red-Black tree thing that apparently
gets used.  But there  just doesn't seem to be a critical mass of such
stuff that's enough for people to want to put it together to continue
to build/support a culture for C programming.  C has really just
become a language for (embedded) systems drivers and virus writers.

But have you written an obscenely-fast blit-scale algorithm in
assembler yet that beats my Cyrix-tuned implementation by a factor of
2? ;)
You would probably be happier with C++.  They started with STL, and a
lot has been added via "Boost".  The way forward with C can only be
through C++.  C itself is basically heading in the direction of COBOL,
and thus its hard to motivate a community to build something like CPAN
or Boost for it.

There is probably room in the C community for a project like Boost,
but it would, at least initially, need very strong and motivated
leadership, for two reasons. One, to write the initial family of
libraries and set an example of the level of excellence (or lack
thereof) expected, and two, to keep the project moving. C is not
dead, but it's rather unlikely that The C Community, fragmented as it
is between vendors and platforms, will suddenly pull together without
some seed to start from.
 
S

santosh

Richard said:
Paul Hsieh said:


And Snippets doesn't count because...?

Presumably they are not "professional" enough. :)

Seriously though, there exists C code for doing just about anything, but
something like CPAN or Boost hasn't emerged, perhaps for various
reasons. Close alternatives are GLib and Apache Portable Runtime.

C culture predates Internet and the "integrated solutions" that are very
popular for the past two decades. Additionally, C is strongly
influenced by UNIX, which encourages a mix and match "toolbox"
approach, rather than comprehensive solutions.

Despite this, something like Boost or CPAN would be very useful, but
it's unlikely to happen.
 
R

Richard Heathfield

santosh said:

Seriously though, there exists C code for doing just about anything

Right. So perhaps all that is needed is a Well-Known Portal.

<snip>
 
P

Paul Hsieh

Paul Hsieh said:



And Snippets doesn't count because...?

Because I've never seen a snippet of code on that site that I didn't
think was either totally trivial, or which I preferred to rewrite
myself? Plus there's no structure or common idioms or direction that
that codebase represents. I don't know much about CPAN, but STL and
Boost are unified under a single source base, and present algorithms
and templates that can work well together in a sensible and scalable
way.

If all you want is code snippets in C, then koders.com or www.google.com/codesearch
is your answer. But I hardly see how those are useful in the same way
that STL or Boost or CPAN is.
 
C

Chris Hills

Hi everyone

I was at an open source conference in Brisbane, Australia not so long
ago, and I can recall a few individuals discussing starting up a C
equivalent of CPAN (i.e. a large centralised repository of C code).

So I thought I might ask people on clc - whether such a thing exists
already?

Chris

No it doesn't.

C has been around for so long and is used for so many different things
that there are many repositories for C code. Many run their own
libraries and examples most of the MCU vendors, compiler makers, dev kit
makers, various web sites for specific things like CAN or 8051.com

The C community is far to big and diverse to centralise and many would
not want to do it anyway.
 
U

user923005

santosh said:



Right. So perhaps all that is needed is a Well-Known Portal.

<snip>

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.
I usually start with Sourceforge when I want to find something and
then switch to google for some more hunting. When those fail, I have
a few dozen other places to look.

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. With Perl and C++ there are generic fascilities for
creation of algorithms and data structures that make this sort of
thing much more feasible. That is why you will *never* see a CPAN
sort of repository for C. It can't be done.
 
R

Richard Heathfield

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.
With Perl and C++ there are generic fascilities for
creation of algorithms and data structures that make this sort of
thing much more feasible. That is why you will *never* see a CPAN
sort of repository for C. It can't be done.

The obstacles are not technical, but political.
 
M

Malcolm McLean

Richard Heathfield said:
The library is easy. It's the consensus that's difficult. Getting everyone
to agree on an interface is a Sisyphean task.
There's oodles of code on my site.
Recently someone ported the BASIC interpreter to an embedded platform. I've
had a couple of thanks for the options parser and csv file loader, and
someone else asked for the source to suicide chess, which I hadn't posted.

However the number of hits on the source files is never very high, and it is
hard to know what is actually useful.
 
U

user923005

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.
 
C

CBFalconer

Chris said:
No it doesn't.

C has been around for so long and is used for so many different
things that there are many repositories for C code. Many run
their own libraries and examples most of the MCU vendors, compiler
makers, dev kit makers, various web sites for specific things like
CAN or 8051.com

The C community is far to big and diverse to centralise and many
would not want to do it anyway.

Many people maintain some portion of their own code in a public
place. You can look, evaluate the accuracy and clarity, not to
mention usefulness, and grab what you want. In my case you want
the download section of my page.
 
R

Richard Bos

user923005 said:
user923005 said:
C collections are scattered all over the place. =A0You 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. =A0We 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'd put the emphasis differently: C is used for tasks for which writing
a generic interface which is both useful for enough applications _and_
efficient enough is difficult. C++ apps can often afford to spend
microseconds deciding which container handler to use. C programs can't.

Richard
 
D

David Thompson

On Fri, 21 Dec 2007 14:43:43 -0800 (PST), user923005
Another advantage of C++ for this sort of thing is ... syntactic sugar ...
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 < [ and <= and == and >= and > and != ]
but once you have done the work, the ease in notation makes
programming more natural [at least in the large.]

<OT C++> Nit: Actually for well-behaved cases you only need to write
operator== and operator< and <utility> fills in the others.

This doesn't damage your point, obviously.

- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top