I have always had a great deal of respect for C, and I would like to start writing in it. However, while I am skilled in other languages, I basically don’t know any C off the top of my head.

I find that I learn better and faster by attempting projects, rather than working through a book ir taking a class. For example, to learn Perl, I am working on a basic disk image writer that’s coming along nicely.

So, what do you think might be a good idea for my first C project?

EDIT: Zig is also something I’m interested in learning. Same question, different language.

  • Camille@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    8 hours ago

    Back when I was a student, we had to implement the following projects to validate and I think they are a really nice set of training projects for C (memory management, handling your own types, algorithms and off-by-one traps):

    • a basic implementation of diff
    • a fully functional hashmap (subproject of diff actually)

    I personally wrote the followings too:

    • a program to compress/decompress archives using only the LZ77 algorithm
    • math expression evaluator (i.e. a basic interpreter)
    • a basic garbage collector (mark&sweep, mark&copy, whatever grinds your gears)

    If you are already a competent developer in other languages, these should be reasonable projects. The difficulty lies in doing them in C. For the hashmap, the evaluator and the archiver, you have to correctly manage your data and memory. this makes them excellent projects for learning what makes C… C. For the garbage collector… well… you are the memory manager. Basic GC algorithms are easy to understand but what you want to learn here is the actual management of the memory. See it as a more advanced project if you want to really grok dirty C.

    Most importantly: have fun :)