DEV Community

Benjamin Calderon
Benjamin Calderon

Posted on

When you want to learn C in 2019

How many of us have those fond memories of daring to write more than 20 lines of code without compiling just to get a taunting blinking cursor of bash right below segmentation fault. Oh, the nostalgia!

But for real, C seems to work against you! It lures you with its minuscule 32 keywords and then it shoots you on the back with * and &.

I don't know if it's because I like pain or I still idolize the time of vi running on Slackware back in the day of Kernel 2.2 and ext2 constantly breaking but I finally decided to take the jump into C.

What I've been "discovering" is that the beauty of C is that it doesn't try to hide many details from the system you are running the program. It assumes you know what you are doing, and my that, you know what things can be stored on L1 or in RAM! I guess it is true that with greater power comes greater responsibility.

The reason why I'm learning C (I'm a web dev in love with JS and React, and Rust makes my heart flutter!) is because Linux. I have used Linux for years and now I want to go deeper, syscalls and kernel and such. And even in higher levels we are still C territory with gstreamer and Glib and Gtk+ and libssl, and readline and wayland and...

C is still King and Lord in many low level Linux world.

Learning it in 2019 seems kind of like a challenge since you seems to find two camps, one says "C is Punk Rock" (21st Century C) while the other camps says to not dare a keyboard before reading K&R2. One wants you to develop high-level stuff with C and a bunch of libraries, while the other tells you how to store things on L1, which is 200x to RAM.

Anyways, I'm really enjoying learning more about systems from the amazing tlpi book. Any suggestions, ideas or resources would be more than welcome!

Thanks for reading :-)

Top comments (16)

Collapse
 
codemouse92 profile image
Jason C. McDonald

"Learn C the Hard Way" by Zed Shaw

It is the best modern book on C I've ever read! It introduces the concepts, pitfalls, features, and gotchas in such a way that not only helps you write good C code, but helps you understand low-level programming as a whole.

Collapse
 
weirdmayo profile image
Daniel Mayovsky

I peeked into the book. I like to have a book independent, and I just want to ask if you know any other C book that doesn't make you watch lecture videos? Just the book and reading and practicing? I know JavaScript by heart, and script with Bash. I know what programming is, so beginner Python-level book is something I want to avoid, just for reference :)

Collapse
 
codemouse92 profile image
Jason C. McDonald

You can absolutely skip the lectures on Learn C the Hard Way. I don't know of a better resource. This one is pretty well oriented towards individuals who know other languages.

Collapse
 
benjcal profile image
Benjamin Calderon

cool! I was afraid that LCTHW was going to be sort of high level-ish. I'll take a look!

I'm going through Build Your Own Lisp because I find myself in sorely need of learn more tooling (autotools) and stdlib.

Thanks for the comment :)

Collapse
 
jabawaka profile image
Jabawaka

"Learn C the hard way" is definitely a great book for modern C. Other than that, I find that like with almost any other programming learning challenge, the best thing to do is find something you want to build and do so in C!

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

I absolutely agree. However, as a self-trained developer in several languages, I have learned there is significant value to following books and courses. When you learn via a project, you only absorb those parts of the language you needed.

Case in point, although I first started using Python in 2011, it wasn't until 2018 that I learned several tools in Python, including decorators and list comprehensions. Why? I'd never needed them, or else, never realized I could use them in place of some approaches I was more used to. Despite nearly seven years of regular Python development, I knew I had some massive gaps in my knowledge, so I started going through a comprehensive Udemy course for the language, and I'm so glad I did!

This isn't to say that projects aren't important -- you won't ever truly master a language until you build something meaningful in it -- rather, one should pair project-based learning with a good quality book or self-paced course.

Or, if all else fails, go read the documentation cover to cover. (Some of us are demented enough that we can do that.)

Collapse
 
jmlgh profile image
Javi ML

Another excellent book is "Crafting Interpreters" by Bob Nystrom. The second part of the book (still in progress) is how to create an interpreter in C
craftinginterpreters.com/contents....

Collapse
 
k2t0f12d profile image
Bryan Baldwin • Edited

John Calcote, Autotools: A Practitioner's Guide

Collapse
 
martinhaeusler profile image
Martin Häusler • Edited

C has an utterly needless amount of pitfalls. You hit the nail on the head: C is actively working against you. The compiler, the syntax, the (non-present) package system, the platform dependency... from a language perspective, C by all means and purposes should have died 15 years ago and replaced with something sane. At least a proper type system certainly wouldn't have been too much to ask!

It's not about pointer arithmetics and bitwise operations and manual memory management - there are plenty of valid use cases where you need to have that and can't do without, I get that. It's the language itself and it's tooling and "ecosystem" (or rather: the lack thereof) that somehow, some way inexplicably is still alive.

Don't get me wrong: every programmer should know the concepts of C. But the language itself (syntax, type system, compiler, tooling, package management...) is outdated and needs to be replaced, desperately. Why this hasn't occurred yet is beyond me.

Collapse
 
andrewharpin profile image
Andrew Harpin

The main issue many face when learning C is they don't understand how the computer they are programming for works.

C is powerful, but raw!

They have grown up with languages that deal with the underlying operations for them. Sometimes for simplicity, sometimes support and sometimes portability.

The ARM instruction set was created around using C to simplify the compiler.

But much of C is not simple or portable from a simplistic perspective, "int" on an 8 bit platform is not the same as it is on a 32bit platform.

But then there is understanding that an integer division operation could behave differently depending on the underlying processor ALU.

I'm not trying to dissuade people from learning C, but the learning curve is just as steep as when you learned your first language and you need a completely different set of skills to master it.

Collapse
 
twigman08 profile image
Chad Smith

One of these days I'm going to get back to doing something similar. C++ was my first language and I actually really miss it. It's still my favorite language, mostly since it was my first, it is like my baby. I'll actually get back one of these days in "mastering" (if that's even possible in such a powerful language) some of the more advanced concepts in C++ and learning Modern C++.

Have fun and enjoy!

Collapse
 
avalander profile image
Avalander • Edited

Good luck, and keep us posted about your progress!

Learning C has been in my to-do list for a couple of years now, I want to learn it for reasons similar to yours. Some day I'll get around it :D

Collapse
 
benjcal profile image
Benjamin Calderon

will do!

Collapse
 
scotchka profile image
Henry Chen
Collapse
 
ondrejs profile image
Ondrej

Geez, I want to do a ton of low lvl stuff in C, but I have very little time to learn and practice it (being full time Kotlin dev) :(
Nice article though!

Collapse
 
juancarlospaco profile image
Juan Carlos

Learn Nim lang, modern programming language that compiles to optimized C/C++, nice C FFI, CompileTime execution, Python-like syntax, also runs on Frontend, worth giving it a try.