How I program C
Eskil Steenberg8 HN recommenders · recommended in 9 months, 2017-2025
1M views · 9 years ago · talk · evergreen
Eskil Steenberg's two-hour talk on his personal approach to writing C, covering code style, structure, naming, pointers and large-project organization. He warns it contains a fair bit of programming religion.
HN recommends it as the one long programming video worth watching, a provocative and influential take on C.
1:10:42Elements of Programming Style - Brian Kernighan
Institute for Advanced Study
138K views • 9 years ago
1:05:59Modern C and What We Can Learn From It - Luca Sas [ ACCU 2021 ]
ACCU Conference
130K views • 5 years ago
1:11:59Intro to C on Windows - Day 1
Molly Rocket
370K views • 11 years ago
1:14:52Effective Programs - 10 Years of Clojure - Rich Hickey
ClojureTV
176K views • 9 years ago
1:36:27CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++”
CppCon
175K views • 10 years ago
1:03:31Brian Goetz - Stewardship: the Sobering Parts
ClojureTV
39K views • 11 years ago
1:40:27CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"
CppCon
323K views • 12 years ago
1:29:27The Forgotten Art of Structured Programming - Kevlin Henney [C++ on Sea 2019]
cpponsea
245K views • 7 years ago
1:07:22Invited Talk - Guy Steele
ClojureTV
39K views • 9 years ago
53:56Expert to Expert: Rich Hickey and Brian Beckman - Inside Clojure
jasonofthel33t
119K views • 13 years ago
1:04:00CppCon 2015: Sean Parent "Better Code: Data Structures"
CppCon
106K views • 11 years ago
54:55Dconf 2014 Day 2 Keynote: The Last Thing D Needs -- Scott Meyers
The D Language Foundation
19K views • 8 years ago
17:26Lecture 1 | Programming Paradigms (Stanford)
Stanford
1.2M views • 18 years ago
1:29:49Going Native 2012 Keynote Stroustrup
savage309
33K views • 14 years ago
40:56"Liberating the Smalltalk lurking in C and Unix" by Stephen Kell
Strange Loop Conference
25K views • 12 years ago
1:02:49Hacking with Andrew and Brad: tip.golang.org
The Go Programming Language
99K views • 11 years ago
1:54:00Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022
CppCon
277K views • 3 years ago
1:00:11CppCon 2015: Kate Gregory “Stop Teaching C"
CppCon
181K views • 11 years ago
1:00:29Google I/O 2012 - Meet the Go Team
Google for Developers
108K views • 14 years ago
38:26"Code is the Easy Part" by Evan Czaplicki
elm-conf
43K views • 10 years ago
19 comments from Hacker News
The author of this website couldn't be further from any notion of vibe coding: link ▶ this video Vibe coders follow the herd (Python, JS, Rust), they don't write any C.
Other resources I like: - Eskil Steenberg’s “How I program C” ( ▶ this video ). Long and definitely a bit controversial in parts, but I find myself agreeing with most of it. - CoreFoundation’s create rule ( link ). I’m definitely biased but I strongly prefer this to OP’s “you declare it you free it” rule.
The author's defense of C reminds me of this classic youtube video: ▶ this video ... I am sure the video above will cause immediate disagreement (I think it goes too far on some topics), but I urge people to consider the ideas contained within. (I seem to have mis-posted this to another thread?)
> Modern PL features are more or less wrappers around comparatively complex C code. Object inheritance is actually one that isn't too difficult or complex to implement: ▶ this video True, and if you implement it as a preprocessor, that's exactly how C++ started in 1979 (Stroustrup's "C with classes" Cfront pre-processor: link ).
>You don’t have inheritance [..] Modern PL features are more or less wrappers around comparatively complex C code. Object inheritance is actually one that isn't too difficult or complex to implement: ▶ this video
Boy, I feel this. I am also a 0.5x programmer. I write dead-simple C; I don't even touch web development, which I consider more complex than C development with Valgrind. In fact, I've spent nearly 3 years writing a build system. That's how slow I am, and it's made some acquaintances laugh at how long I've worked without result. But in reality, I'm not just building a build system. I'm also building my own stack, a la [1], including replacing as much of libc as I can and changing the OS API's I use. I think that soon enough, this stack and this simplicity will become my superpowers and make me a 10x programmer. Being a stupid programmer means you won't be clever. And if you're not clever, you will be able to debug it, even though it is twice as hard to debug than to write. [2] Good debugging is a superpower in itself. [1]: ▶ this video [2]: link
Once I have an actual working piece of software, I will announce it on HN. This framework is not meant to be shared really; it's more building my own software stack from scratch, kind of like [1]. [1]: ▶ this video
For what it's worth I think this is an excellent choice. Back in 2019 I was deciding whether I wanted to pursue Zig full-time and one of the upsides that I determined was that once you reach critical mass writing all of your code for tools and things in Zig you end up with things that are really exactly what you need and with a very high baseline for speed, flexibility, and so on. Right now I'm considering the same thing but with Odin and for many of the same reasons that I had for Zig; it's an excellent language to write foundational code in and once you do, you end up being able to build significantly more understandable, reliable, stable and consistent things. This, but on a company level, is a real multiplier. Once you adopt a couple of Python scripts and that's OK, you give up the possibility of wielding this sharp spear. Edit: I think "How I program C" by Eskil Steenberg is an interesting window into what you can get if you laser focus on a language and environment and allow yourself to build up a mountain of code that you dogfood: ▶ this video At some point I will likely soft-retire and at that point it's exceedingly unlikely that I'll bother with using other people's libraries except a few key ones that I think are decent, and at that point there really is no reason I'd sit down and write these fundamentals in anything but a lower-level language. Odin, Zig or something like it would pretty much be the only thing on the table.
> Once you have syntax and basic algorithms down well, watch this, the only 2 hour YouTube video I'll ever recommend: > ▶ this video Hard +1 on this! I think Eskil Steenberg work in C is really top notch - the video is heavily recommended, as is an overview of his work in general, he does some awesome stuff with C.
link If you have lots of time: link If you can't be bothered reading a whole book: link Exercises: link and link Once you have syntax and basic algorithms down well, watch this, the only 2 hour YouTube video I'll ever recommend: ▶ this video Both r/cprogramming and r/C_programming are active, also full of lazy students trying to get people to do their homework. If you come by, describe your problem well with code. Say you're learning for yourself, not for school. Together C & C++ is a good Discord if you prefer live chat: link
> It's generally a good thing to write code which takes up more space if it's clearer to understand what's going on. Eskil Steenberg has talked about *width* of code as a more likely quality indicator. Consider the difference between: func(int i, void* p) And: modulename_objectname_operation(int count, void *ptr) Reference: ▶ this video
Try watching this: ▶ this video Its long and is filled with other stuff about C programming but it goes in to dept about how to think about pointers. Good Luck!
As a C programmer i have two ways I go about selecting names. For anything uniqe, I use long post fix names. I think of them as a directory path to the functionality. So instead of: create_object(); delete_object(); I do: project_module_object_create(); project_module_object_delete(); I then do the same with files, so the above would probably reside in a file called: project_module_object.c This makes everything easy to find, you know where things belong and you can search for partial names to find instances of interfaces. For local variables, I have a small set of variable names that all have specific meninges like i, j, k, f, sum, found, best, length, count, that I always use in the same way. They therefore become very easy to read since I know their use. If something doesn't fit the limited set of common variables, I revert to long post fix names. A much longer explanation of how is use C that goes in to more depth about naming can be found here: ▶ this video
Hi Eskil from Australia :-) I remember you posted that on the page from 40 days ago also hehe. I have too many ideas myself already, so that one wasn't so useful to me, but was interesting. However, I really liked Drama in games [0] and I seriously loved How I Program C [1]. It's been a big influence. Thank you! [0] link [1] ▶ this video
All code written in C89 Written from scratch, without any dependencies. All operating system interaction is warped and ported. FreeBSD License. -Forge: stdlib with math, text, A*, geometry math, memory debugger and much more. -Imagine: Threads, timing, setting, lib loading. -Betray: Platform layer, with plugin support, VR, Multi-touch, controllers and more. Win32 , Linux and limited MacOS support. -Relinquish: Rendering library, wrapping OpenGL supports and hides a wide range of extensions. -Seduce: 3D UI toolkit, text rendering and editing, fonts, 3D manipulators, cameras. Mouse / multi-touch / multi-user / controller support. -Testify: Networking and serialization. TCP, UDP, Files, NAT Holepunching, local/global service discovery. -Hxa: asset file format, FBX and PNG implementation. Graphics processing. -Json parser. These libraries have been used extensively in software production for all my applications including LOVE, Exo, Stellar, MoF, and Loq Airou (source included). You can find out more about these at: link . For more on my programing style, and philosophy watch this: ▶ this video
The fundamental tradeoff is between control and abstraction. Better control typically means going closer to machine/operational semantics, better abstraction typically means going to denotational semantics. Compilers are what mediate between these two domains, but tend to become more bloated as they have to accommodate both more diverse hardware and more numerous languages. This helps the working programmer ignore the problem of writing good code but only for so long. It only delays the inevitable as the returns from clever compilation can't go on forever, and in fact these returns become more volatile as hardware architectures become more complex (typically through more cores or extra caches, incurring synchronization costs). Thus for maximum performance through binaries one would have to practice tweaking compiler settings which just creates another layer of abstraction and defeats the point of having this step automated for you. Programmer training in particular needs to become both more comprehensive and more specialized. More comprehensive means knowing how each layer of abstraction gets built up from the most common machines (like x86). More specialized means filtering out a lot of people who were trained-for-the-tool and facilitating more cross collaboration between those that can program in a domain but not program for performance. This might mean better methodologies for prototyping across domains or experimentation with organizational structures to complement such m
This is the wrong way to go about it. The syntax is great, what is needed is updates to reflect modern hardware: -Vector types. (With arbitrary sizes not just up to vec4 for like on GPUs) -New operators like clamp, and other intrinsic. (See GLSL and modern instruction sets) -Min/max: |< >| -Dot: -Cross product: >< -Swizzle: a.3.2.1.0 -Qualifiers for warping behavior. -Standard library with cash management hints. -Define qualifiers for padding of structs to be defined. I would also argue you could change some things in the spec to make it easier for compilers to optimize, like making the calling a switch without a catching case undefined behavior. As for the syntax itself, I could find being able to type multiple break commands in a row to get out of more then one loop useful, but its not a big thing. I would probably drastically restrict the power of the pre-processor too. (If you have too much time on your hands: ▶ this video )
A comment I find myself returning to whenever this conversation comes around is from Eskill Steenberg: "In the beginning you always want Results. In the end all you want is control" [0]. [0]: ▶ this video
this video: ▶ this video , from a talk by eskil-steenberg titled 'how i program in c' is, imho, pretty good as well.