looking for good C source code

C

Clark

Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?
Thanks.
 
A

Aaron Walker

stau said:
The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.

I definitely had fun reading version 0.01 of the linux kernel. I
decided to read that version because I figured it'd be the easiest to
read and understand since it is a minimal kernel.

Aaron
 
A

August Derleth

31:43p:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in
particular that in your opinion has good writen C code?
Thanks.

This isn't really on-topic for this group. comp.programming would
probably be a better place for it. comp.lang.c only deals with Standard
C, not programming in general or languages other than Standard C.

In any case, the GNU Project has released some coding standards for
people to follow. I think they can be applied generally, in fact, and so
I will give you the link to the website where they are listed:

http://www.gnu.org/prep/standards_toc.html

Another thing for you to keep in mind is the difference between using a
specific language and programming in general.

Using a language is all about knowing syntax rules and taking advantage
of semantics and such like. In other words, it's not applicable to any
other language.

Programming in general deals with algorithm design and structuring of
both code and data and the theory of effective computability. In other
words, it is completely independent of any language.

Perhaps the most important lesson in programming style to take from that
distinction is to learn that structure and planning are the most
important elements of good style, and that they will show through well no
matter what language you use.
 
R

Randy Howard

The Linux Kernel.
www.kernel.org

The best free (as in free speech) C code you can get.

It's free, but it's not C.

The linux kernel uses a lot of gcc extensions that are not pure ISO
or ANSI standard C. That's not bad, it would be hard to write an OS
without doing so, but if your intent is to learn portable C, that's
probably not the place to start.

Sourceforge is a great reasource, try searching for ANSI and ISO and
reading project summaries for those claiming to be fully portable.

Also, several of the regular posters here have websites with
libraries and smaller code samples that are fully portable, try
trolling through some of the .sig lines.
 
R

Richard Heathfield

Clark said:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?


(I must disagree with August Derleth about the topicality of this question.
I can think of no better place to ask about good C source code than a good
C newsgroup!)


If you're looking for good C source code, look no further than comp.lang.c.
If you want to advance your C programming skills, you are already at the
right place. Read the group regularly, and (once you have worked out who
knows what they're talking about and who doesn't) you'll pick up a vast
number of useful tips on how to use the language correctly and skilfully.

You don't have to wait for discussions to happen, either, since Google has
archives for this newsgroup going back to - er, no, it even goes back
further than that.

A brief, non-exhaustive list of names worth looking out for (past and
present) - every one of these people is a C expert:

Martin Ambuhl
Christian Bau
Dann Corbit
Douglas Gwyn
Lawrence Kirby
Jack Klein
Ben Pfaff
P J Plauger
Dan Pop
"Noone Really"
Will Rose
Eric Sosman
Richard Stamp
Keith Thompson
Chris Torek
Stephan Wilms
Dik Winter

Like I said, it's non-exhaustive. But basically, if you focus on articles by
these people, you'll pick up a lot of good stuff. Then find out who agrees
with them (on the whole!), and you'll find your way to other clueful
articles.

It's not the best way to /learn/ C, by any means, but if you've already
"learned" C, this is a great way to find out what you got wrong and what
you missed.
 
S

Sidney Cadot

Richard said:
A brief, non-exhaustive list of names worth looking out for (past and
present) - every one of these people is a C expert:

Martin Ambuhl
Christian Bau
Dann Corbit
Douglas Gwyn
Lawrence Kirby
Jack Klein
Ben Pfaff
P J Plauger
Dan Pop
"Noone Really"
Will Rose
Eric Sosman
Richard Stamp
Keith Thompson
Chris Torek
Stephan Wilms
Dik Winter

Like I said, it's non-exhaustive. But basically, if you focus on articles by
these people, you'll pick up a lot of good stuff. Then find out who agrees
with them (on the whole!), and you'll find your way to other clueful
articles.

This list is especially non-exhaustive in that it omits Mr. Heatfield
himself, of course.

A rather funny thought just occurred to me: what would happen if people
of this caliber got together to work on a real-life project? Seems that
a mediocre outcome is out of the question... Either the result would be
quite brilliant or a total deadlock, I think :)
It's not the best way to /learn/ C, by any means, but if you've already
"learned" C, this is a great way to find out what you got wrong and what
you missed.

It certainly is.

Best regards, Sidney
 
S

stau

I definitely had fun reading version 0.01 of the linux kernel. I
decided to read that version because I figured it'd be the easiest to
read and understand since it is a minimal kernel.

Aaron

Its does have some bugs on the use of the C language, as Linus just
admited when argumenting against SCO dick corp.; like #define
someMacro(a, b) (a - b), in which the argument may be a complex
expression.
A newer version is probably better for study.
 
S

Servé Lau

Sidney Cadot said:
A rather funny thought just occurred to me: what would happen if people
of this caliber got together to work on a real-life project? Seems that
a mediocre outcome is out of the question... Either the result would be
quite brilliant or a total deadlock, I think :)

I do agree that the people mentioned know their stuff very well, but you
need more than only coding and language skills to successfully complete a
big project.
 
P

Peter Nilsson

Servé Lau said:
I do agree that the people mentioned know their stuff very well, but you
need more than only coding and language skills to successfully complete a
big project.

I'm quite sure the listed people would know quite a lot of other stuff too.
:)

But more critically, a group considering a project that would actually
_need_
more than two (say) genuine C _experts_ should probably reconsider it's
choice
of programming language! ;)

In any case, many of the listed people _have_ colaborated on a real-life
project: "C Unleashed". Although, Francis Glassborow wasn't entirely
convinced of the merits of that project, even if he was satisfied with
the quality of production.
 
R

Richard Heathfield

Peter said:
But more critically, a group considering a project that would actually
_need_ more than two (say) genuine C _experts_ should probably
reconsider it's choice of programming language! ;)

Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.
In any case, many of the listed people _have_ colaborated on a real-life
project: "C Unleashed". Although, Francis Glassborow wasn't entirely
convinced of the merits of that project, even if he was satisfied with
the quality of production.

I hold the opposite position to Francis. I think the project was worth
doing, but I think the timescales involved made it more or less impossible
to provide the kind of quality we'd have been happy with. On the other
hand, perfectionists are /never/ happy with the quality, are they? And if
there's one thing (other than C) that unites clc regs, it's perfectionism.
 
P

Peter Pichler

Richard Heathfield said:
And if
there's one thing (other than C) that unites clc regs, it's perfectionism.

s/rfectionism/dantry ;-)

Seriously, I think CU is a good book. It may have been knocked up in limited
time, but that only shows more about the quality of its authors. It's not a
beginners' book after all, and the others care more about the content than
anything else.
 
M

Michael B Allen

Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in
particular that in your opinion has good writen C code? Thanks.

Here's my open source "toolbelt" of code:

http://www.ioplex.com/~miallen/libmba/dl/src/

Regarding it's quality; most of the modules are ANSI C so other than that
quality is a matter of opinion. Or it depends on what you're using the
code for. Condsider the stack.c module for example. It was developed with
the assistance of people on this newsgroup several years ago and helped
define my style. However it is a general purpose ADT that automatically
grows and shrinks as memory requirements change. It also checks parameters
and sets errno. These are things that would not be appropriate in some
cases. Some simple PUSH/POP macros would certainly be more efficient.

Mike
 
C

CBFalconer

Sidney said:
Richard said:

A rather funny thought just occurred to me: what would happen if
people of this caliber got together to work on a real-life project?
Seems that a mediocre outcome is out of the question... Either the
result would be quite brilliant or a total deadlock, I think :)

The book "C Unleashed", by Heathfield et al, is a fairly recent
example.
 
E

Ed Morton

Richard said:
Peter Nilsson wrote:




Or perhaps a group that thinks it can get away with using non-experts should
be designing street-signs instead of software.

In at least some applications, and I'd suspect most, the benefits of C
expertise are a drop in ocean compared to expertise in the domain that's
using C.

Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.

Ed.
 
R

Richard Heathfield

Ed said:
In at least some applications, and I'd suspect most, the benefits of C
expertise are a drop in ocean compared to expertise in the domain that's
using C.

Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.

Frankly, given the same choice, so would I - and I might even consider
switching the project language to that favoured by the domain expert.

Interestingly, in most of /my/ programming career, the critical domain has
been C itself.
 
M

Mark McIntyre

Given the choice of a domain expert with limitted C knowledge and a C
expert with limitted domain knowledge, I'd certainly choose the domain
expert.

Hmm. Sounds like a microsoftian saying, or do you work in Dilbert's
office? :)

Lets face it, if you had a choice of either one or the other, your
project is already doomed. You don't know enough C to write hte
programme well, or you don't know enough about your requirements
domain to design it in the first place... argh.
 
R

Richard Heathfield

Mark said:
Hmm. Sounds like a microsoftian saying, or do you work in Dilbert's
office? :)

Lets face it, if you had a choice of either one or the other, your
project is already doomed. You don't know enough C to write hte
programme well, or you don't know enough about your requirements
domain to design it in the first place... argh.

It doesn't have to be that stark a choice. Expertise is not a Boolean
concept. It is possible to know enough about a domain to do useful work in
it without necessarily being an expert in that domain, as long as real
expertise is somehow available to you when required (co-worker, good book,
whatever). Similarly, it is possible to know enough about C to do useful
work in it without necessarily being a C expert.

If you're good at picking your team, you'll have C experts AND domain
experts, who will learn from each other as the project progresses.
 
S

Servé Lau

Peter Nilsson said:
But more critically, a group considering a project that would actually
_need_
more than two (say) genuine C _experts_ should probably reconsider it's
choice
of programming language! ;)

Something just occurred to me. Suppose a group of C experts clc style would
start out to create a windows program with Win32 and C. I think they would
be stressed out in a matter of weeks :)
Threads, writing to the registry, shoving windows around, dll's, that's not
portable!
_stdcall, _cdecl, casting longs to function pointers, WPARAM to CREATESTRUCT
* and a second time to int, oh my!
 
J

John L

Servé Lau said:
Something just occurred to me. Suppose a group of C experts clc style would
start out to create a windows program with Win32 and C. I think they would
be stressed out in a matter of weeks :)
Threads, writing to the registry, shoving windows around, dll's, that's not
portable!
_stdcall, _cdecl, casting longs to function pointers, WPARAM to CREATESTRUCT
* and a second time to int, oh my!

More likely they would keep separate the platform-specific and
non-portable code from "official clc-approved ISO Standard C" code.

That way, when they, or their successors in eighteen months time,
come to port the program to a different platform or simply just
a different compiler or graphics library, it would be obvious
which parts need to be changed and which do not.

And after the port, they'd still have the portable, standard bit,
but now there would be two different (non-portable) modules
interfacing to two different platforms or databases or window
systems or whatever.

But, not being an expert, I'm just guessing. :)

John.
 

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,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top