Close to
the Metal.
Systems Programming · Programming Languages
Zero-Overhead Abstractions
The Why
Why systems. Why PL. Why the machine is worth understanding.
Speed Is a Feature
Latency is not a metric—it is the user experience. A 1 ms response and a 100 ms response are not the same product. Understanding cache lines, branch predictors, and NUMA topology is how you build the former.
Know Your Machine
The abstraction is not the truth. CPUs are out-of-order, speculative, and pipelined. Memory is not flat. I/O is not free. The programmer who ignores the hardware pays the cost anyway—just invisibly, and with no idea why.
Types Are Theorems
A great type system is not bureaucracy—it is a proof assistant. RAII, ownership semantics, [[nodiscard]]: these are not constraints. They are invariants the compiler checks so the runtime never has to.
Zero Is the Goal
Zero overhead. Zero copies. Zero allocations in the hot path. Zero undefined behavior. The best abstraction costs nothing at runtime. C++'s zero-cost abstractions are not a slogan—they are a design commitment.
Numbers to Live By
Latency numbers every systems programmer should know. Log scale—orders of magnitude matter.
Based on Jeff Dean's “Numbers Everyone Should Know”, updated for modern hardware.
The Stack
Languages and tools of the trade.
Where I live. Modern C++ (20/23): concepts, ranges, coroutines. RAII everywhere. Templates when they earn their keep. constexpr all the things that can be. The language that trusts you—sometimes too much.
For glue, build scripts, data wrangling, and quick prototypes. Not for the hot path. NumPy when fast array math is needed without ceremony. The right tool for the job that isn't the job.
Not for production—for understanding. Reading compiler output on Godbolt is a superpower. Knowing what SIMD looks like makes you write far better C++ intrinsics and understand what's really happening.
Tools I Reach For
The Craft
What separates good systems code from great systems code.
Things That Feel Right
- ✓ Cache-friendly SoA data layouts
- ✓ Lock-free algorithms, verified with TSan
- ✓
-Wall -Wextra -Werror— no exceptions - ✓ RAII destructors cleaning up perfectly
- ✓ A tight inner loop with no branches
- ✓ Compile-time computation with
constexpr - ✓ Memory-mapped I/O bypassing the kernel
- ✓
[[nodiscard]]catching a real bug in review - ✓ A flamegraph that is flat and boring
- ✓ p99 latency equal to p50
Concepts I Find Beautiful
RAII
Resource lifetime tied to object lifetime. Deterministic cleanup without a GC tax.
Zero-Cost Abstractions
The abstraction compiles away. You pay only for what you use. No runtime overhead.
Algebraic Types
Sum types make illegal states unrepresentable. std::variant, std::expected.
Cache Locality
The memory hierarchy is the bottleneck. Data that lives together runs together.
template <typename F>
struct ScopeGuard {
F fn;
bool active{true};
~ScopeGuard() noexcept { if (active) fn(); }
void dismiss() noexcept { active = false; }
};
// Deduction guide: compiler infers F from the lambda
template <typename F>
auto defer(F&& fn) {
return ScopeGuard<std::decay_t<F>>{std::forward<F>(fn)};
}
// Guaranteed cleanup regardless of early returns or exceptions
FILE* fp = fopen("data.bin", "rb");
auto _ = defer([fp] { fclose(fp); });
// ^ destructor fires here, or at any early return
Words Worth Keeping
“The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.”
— Donald E. Knuth
“C++ is a zero-overhead language: whatever you use, you pay for. And further: what you don't use, you don't pay for.”
— Bjarne Stroustrup
“The purpose of abstracting is not to be vague, but to create a new semantic level in which one can be absolutely precise.”
— Edsger W. Dijkstra
“Every program has (at least) two purposes: the one for which it was written, and another for which it was not.”
— Alan Perlis
“Make it work. Make it right. Make it fast. In that order.”
— Kent Beck
“Rule 1: Don't optimize. Rule 2 (for experts only): Don't optimize yet. Measure first.”
— Michael A. Jackson