Recently I embarked on a journey of starting to learn C. To me C always felt like this mythical old language that most of our Software is written in but learning it seemed difficult and complicated.

So Why did I do it?

C is the backbone of so many technologies that I interact with on a daily basis. Zsh, Nginx, Linux, Vim, and most of the Shell utilities to name just a few things. I was curious to get an understanding of this important language.

So where to start?

A fantastic first place to start is Beej’s Guide to C Programming. This well written guide gives a good Overview of the language and serves as a good introduction.

Starting with Projects

Afterwards I was keen to get my hands dirty on some practical projects.

A Bank Management System

I started with a little Bank Management System. The point of this project was mainly to get familiar with the Syntax.

Minimal Coreutils

Another great resource is the OpenBSD Coreutils Source Code.

Why OpenBSD?

Their implementation of the Coreutils like ls, cat, mv are simple, readable and minimal. For example their implementation of cat comes in at 219 lines while the GNU implementation is a whole 631 lines of code.

Using the source code as a reference I went on to create my own small version of utilities like ls, cat, echo and a few more.

A simple Shell

Next I decided to write my own shell. For this there’s a very nice guide out there on brennan.io

A simple webserver

After finishing this in a surprisingly fast time I went on to write my own webserver in C. For this I sadly did not find any amazing guides. I ended up using this Blog as a starting point.

A simple text editor

There is this great guide out there called kilo on writing your own text editor. I learned quite a bit following along but in the end found it too daunting to actually finish this project. Writing a simple text editor can get surprisingly complex.

Next steps

Something I think would be very cool would be to start my own small C ecosystem. Using my own webserver, shell, coreutils, text editor. Possibly even things like a Terminal, WindowManager or Webbrowser. For now I don’t have any time to actually do this and would rather focus on other projects. But I think this is something I can revisit in the future.

Conclusions

This project turned out to be a fantastic way to get a look behind the scenes of some of the technologies I use every single day. It also felt very rewarding since progress with these projects was usually quite fast. I expected this to be more about the language C but in the end the even more interesting parts were learning how my Shell actually works, how webservers work on a basic level and how some of the shell tools I use work. I can recommend doing this to everyone who is curious about this and has a little bit of time on their hands.