brian_hassinger

software developer

One Week With C

May 05, 2020

It’s been a week now since I’ve decided to learn C, which means it’s time for an update.

My most significant finding is a misunderstanding of my own goals. It’s not C the language that I want to learn, but instead, the entire ecosystem built around it. Learning the syntax of C isn’t a challenge; it’s a small language with a handful of features, most of which are borrowed in other programming languages. What I’m not used to is how confusing the environment is.

I’m struggling with:

  • Which version of the language do I learn?
  • What functions are available from the standard library?
  • How does compilation work?
  • What exactly is a binary file?

Language version

C is an older programming language, and roughly every 10 years or so, a new standard appears. In comparison to other languages the changes seem quite small, and they usually address a pain point. My read on the situation, many programmers are slow to adopt any new standard unless they have to. Standard CX (where x is whatever year you like) works perfectly fine for them, and whatever pain points it solves, they’ve become comfortable with like a mollusk polishing a grain of sand into a pearl.

The hardest part is finding resources about which version of C is worth learning, and after one week of searching, I think the answer is: it depends.

I think a reasonable expectation is to learn one well, and then learn about the differences introduced in all of them. From what I can tell, it looks like most of the world is using C99. In contrast, the suggested books I’ve found for learning C are for C89/C90.

I wish when I started I found a suggested book for C99, but I’ve already purchased a copy of K&R, and that’s what I’ve been digging through, so I’ll keep going this route for now. If for nothing else, the rite of passage.

Standard Library

There are many implementations of the standard library available, and which one to use I still don’t understand. Each one has different goals, implementation details, and architecture support. I’m sticking with glibc because it’s everywhere, but I see there’s a lot of interest in using musl. I think my understanding of their differences is very surface level.

Another issue I have is with finding information about the functions in the standard library. It’s all available in man pages, which is great to have something so important right at your fingertips. My trouble is in navigating this system. Section 3 listing shows every command. And I guess I’m looking for what headers are available, and under each header which functions exist with a brief description. I think this must exist, but it’s not immediately obvious to me where it is.

Compilation

My limited understanding of how compilation works comes from small exposures here and there. I would love to solidify this knowledge. More specifically, what object files are and how linking works. I’m not focusing on lexical or syntactical analysis.

Binary Executable

The last point is connected to this one, but I want to better understand the ELF file format. In the end, compilation for a Linux target creates this file, and I think a better understanding of this will help answer my questions above. I’ve found a great book on this called Practical Binary Analysis, and I have been enjoying reading through the explanations so far.

So that’s where I’m at with one-week learning C. It’s not so much about C as it is about the Sea surrounding C.