Hofstadter’s Law

In a previous blog post I highlighted Murphy's Law, which famously states "Everything that can go wrong, will". Today I will introduce you to Hofstadter's Law, another useful tool for programmers to keep in mind. Hofstadter's law states: It always takes longer than you expect, even when you take into account Hofstadter's Law. This law …

Header Guards

There are many basic programming practices that I take for granted and perform automatically. I want to take a moment to highlight one of my fundamental C practices: adding header guards. If you're not familiar with header guards, this is the pattern: #ifndef DISPATCH_H_ #define DISPATCH_H_ //your code goes here #endif //DISPATCH_H_ The header guard …

Neat trick: Flexible Macro Vs Function Definitions

I was looking over musl's ctype.h header while working on libc earlier today. In the header, I noticed a curious set of definitions: #define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26) #define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10) #define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26) #define isupper(a) (0 ? isupper(a) …

Murphy’s Law

There are numerous principles or axioms in the world that can aid you greatly if kept in mind. Today I'd like to focus on Murphy's Law: Everything that can go wrong, will go wrong. Think of all the assumptions we typically make about our systems: "The user will never do X with our product" "If …

Shipping Mindset

I keep a compilation of book notes and try to review them to keep the books and lessons fresh in my mind. I came across a few Steven Pressfield quotes regarding "shipping". This mindset is important when building embedded systems - if you don't ship, you have built nothing. Why does Seth Godin place so …