tags:

views:

1560

answers:

7

I've been learning C, and I'm looking for a (preferably very) simple open source project to get into. It will most likely involve more playing around and learning on my part than actual contribution, but it seems a great way to gain some experience and see how C is really used. Any ideas?

+12  A: 

There are any number of open source projects which are coded in C. If you're only looking to tinker, rather than contribute, just pick a tool that you use regularly (so that you're familiar with what it does, and where it might be altered/improved).

If you're looking for real suggestions then the pager "less" is a good start. It is written in a cleanish way, is short, and it does a surprising amount

Of course this mostly depends on what you'd regard as simple! I've hacked around with the mutt mail client - that is written in a neat fashion, which makes it easy to extend, but I'd not even pretend to understand how it works.

You don't mention your environment, so I'm free to assume GNU/Linux. I'll assume further that you're running Debian, and if so you can download the source to applications very easily. Just run this:

apt-get source less
Steve Kemp
+5  A: 

It sounds strange but I think the very best way to learn C is writing C extensions for Python. There are many simple extensions that somehow use the Python C API and it's fun to work with that. (Probably it's less interesting if you don't know Python ^^)

That's basically the way I learned C. For small modules just look at the Cheeseshop^Wpypi, there are many libraries that are written in C.

Otherwise check out some simple GNOME GUI applications. Many of them are written in C.

Armin Ronacher
Two thumbs up. I was going to suggest the same, if the OP knows Python. The Python API is extremely well-designed. It will teach you about memory management and you'll get something useful to play around with interactively.A useful Python extension I've written: pypi.python.org/pypi/py_sg
Dan
+2  A: 

You may find that projects interesting enough to have a non-trivial open-source community all involve a bit of complexity. Nature of the beast: if it really isn't complex (or isn't really complex), it is either already well solved and standard or isn't interesting enough to attract much attention.

The advent of new problem domains break this condition, of course, so you just need to build something so clever that it is obvious after the fact...

That say, consider dillo, which despite the frontpage is quietly working on version 2 (fltk based).

dmckee
A: 

Thanks guys. I already know python, so writing some extensions for it seems cool. And yeah, I know most open source projects are probably rather on the complex end, I just thought it was worth a shot. And yes, I'm running Linux (sidux, to be specific).

Jarek
+1  A: 

As Steve mentioned, some standard UNIX utility such as "less" is probably a great idea.

I was also thinking maybe a lightweight text editor might be cool to try hacking on. "Joe" for instance is written in C, and is GPL licensed. Along the same lines, if you're on Windows the "WinVi" editor is GPL licensed and is written in C.

Or maybe a simple console-based game of some sort? Preferably textual, like an adventure/RP type game?

Jerry
+2  A: 

If you want some good code to look through, check out the sqlite source.
Whether or not you can contribute to or tinker with it I don't know, but it's worth at least a glance to see good, clean C style.

sqlite

+3  A: 

What languages do you know already? Do you know a dynamic language like Perl/Python/Ruby/Groovy?

What C is best at (in my opinion) is low-level programming that involves hardware access, hefty math, and highly efficient algorithms.

You'll gain more satisfaction if you don't try to use C to do the same things you do in a dynamic language, but try to use it for what it's good at. So try some hardware hacking! Do you have a digital camera, router, cell-phone, or another gadget with open-source firmware or utilities? Try hacking on those! Try writing some code to look at binary files! If you are interested in math and science, find some numerical package related to your favorite science, and poke around in the code.

Lastly, try taking a look at the Linux kernel. Sure, it's a huge codebase, millions of lines of code, but it's also extremely modular and well-documented. There are at least two very good books all about the code: Understanding the Linux Kernel and Linux Device Drivers (the latter is freely available online).

Dan