#Systems Programming

Articles about Systems Programming — exploring patterns, best practices, and real-world implementations in production systems.

56 posts tagged with systems programming. ← All posts

#A2A (14)#ADK (8)#AG-UI (6)#AI (9)#AI Agents (311)#AI Architecture (22)#AI Cost (10)#AI Cost Optimization (8)#AI Engineering (230)#AI Evaluation (9)#AI Gateway (8)#AI Governance (29)#AI Red Teaming (9)#AI Research (9)#AI Safety (8)#AI Security (29)#AI in Production (12)#AML (3)#API Design (10)#API Security (8)#APIs (56)#AWS (17)#Accounting (9)#Agent Skills (3)#Agentic AI (24)#Agentic Commerce (12)#Agentic RAG (8)#Agents (4)#Amazon Bedrock (8)#Analytics (3)#Architecture (40)#Audit (3)#Authentication (11)#Authorization (3)#Automation (8)#Azure (11)#Azure AI Foundry (9)#Backend Engineering (310)#Benchmarks (3)#Best Practices (3)#BigQuery (6)#Business Finance (8)#Business Strategy (55)#C (8)#CI/CD (16)#Caching (11)#Capital Markets (14)#Card Payments (12)#Cards (13)#Career (25)#Checkpointing (4)#Claude Code (8)#Cloud (5)#Cloud Architecture (3)#Cloud Native (10)#Code Review (8)#Collaboration (5)#Communication (9)#Compliance (52)#Computer Networking (9)#Computer Science (32)#Computer Vision (5)#Concurrency (39)#Consulting (3)#Containers (10)#Context Engineering (10)#Conversational AI (8)#Cost Optimisation (5)#Credit (14)#Credit Risk (14)#CrewAI (8)#Crypto (12)#Cryptocurrency (12)#Cryptography (8)#Custody (9)#DSPy (8)#Data (13)#Data Engineering (12)#Data Structures (9)#Databases (38)#Deployment (4)#Design Patterns (10)#DevOps (24)#DevSecOps (21)#Developer Experience (5)#Developer Tools (5)#Distributed Systems (95)#Documentation (3)#Edge AI (8)#Embeddings (17)#Emotional Intelligence (8)#Energy (8)#Engineering (11)#Engineering Culture (3)#Engineering Practices (16)#Error Handling (4)#Evaluation (58)#Event-Driven Architecture (8)#FREE-AI (8)#FX (5)#Feedback (4)#FinOps (23)#FinTech (6)#Financial AI (14)#Financial Systems (129)#Fine-Tuning (11)#Fintech (131)#Flutter (8)#Foreign Exchange (5)#Forward Deployed Engineer (20)#Forward Deployed Engineering (8)#Fraud (10)#Function Tools (5)#Functional Programming (3)#Fundraising (8)#GCP (5)#Gemma (4)#Generative AI (3)#Git (8)#Go (220)#Go-to-Market (11)#Google ADK (36)#Governance (59)#Granite (6)#GraphQL (3)#Growth (3)#Guardrails (33)#HIPAA (3)#HTTP (3)#Harness Engineering (8)#Hiring (8)#Hugging Face (8)#Human-in-the-Loop (9)#IBM watsonx (8)#Identity (11)#Integration (3)#Intellectual Property (8)#Interfaces (3)#JavaScript (8)#KYC (11)#KYC and AML (12)#Kafka (10)#Kubernetes (17)#LLM (5)#LLM Inference (8)#LLM Infrastructure (8)#LLM-as-Judge (3)#LLMs (170)#LangChain (8)#LangGraph (11)#Leadership (27)#Ledger (12)#Legal (8)#Lending (14)#Linux (9)#LlamaIndex (8)#Load Balancing (3)#MCP (22)#MLOps (32)#Machine Learning (49)#Marketing (16)#Markets (4)#Memory (15)#Memory Management (5)#Metrics (6)#Microservices (3)#Microsoft Agent Framework (150)#Middleware (6)#Migration (9)#Mixture of Experts (5)#Monitoring (3)#Multi-Agent (10)#Multi-Agent AI (14)#Multi-Agent Systems (73)#Multimodal (3)#Multimodal AI (8)#NIM (5)#NVIDIA (8)#Networking (3)#OAuth (3)#OWASP (7)#Observability (49)#On-Device AI (8)#Open Source (7)#OpenTelemetry (5)#Operating Systems (9)#Operations (10)#Opinion (6)#Orchestration (10)#Organizational Design (8)#Payment Rails (16)#Payments (54)#People (8)#Performance (48)#Personalization (9)#Platform Engineering (9)#PreSales (8)#Privacy (5)#Privacy Engineering (3)#Process (4)#Product (30)#Product Management (8)#Production (11)#Programming (10)#Programming Languages (48)#Prompt Engineering (74)#Prompt Injection (14)#Protocol Buffers (3)#Protocols (9)#Providers (4)#Pydantic AI (8)#Python (142)#Quality (3)#RAG (59)#RBI (3)#REST (5)#Rails (16)#Reasoning Models (8)#Recommender Systems (8)#Reconciliation (3)#RegTech (8)#Regulation (9)#Reliability (52)#Resilience (4)#Responsible AI (5)#Retrieval (3)#Risk (13)#Rust (32)#SLSA (3)#SRE (22)#Sales (9)#Scalability (3)#Security (91)#Security Engineering (8)#Self-Evolving Agents (16)#Sessions (3)#Settlement (9)#Soft Skills (8)#Software (3)#Software Architecture (36)#Software Delivery (9)#Software Engineering (144)#Spanner (4)#Speech (8)#Startups (30)#Strands (8)#Strategy (4)#Streaming (31)#Structured Output (4)#Supply Chain Security (9)#Sustainability (8)#System Design (32)#Systems Programming (56)#Testing (53)#Threat Modeling (3)#Tool Use (22)#Tooling (5)#Tools (3)#Trading (8)#Treasury (6)#Type System (3)#Type Systems (11)#TypeScript (8)#Vector Databases (22)#Vector Search (11)#Venture Capital (8)#Version Control (8)#Voice AI (9)#Web Development (6)#Workflows (14)#eBPF (8)#gRPC (13)#smolagents (8)
Pratik Dhanave · ·6 min read

The eBPF Ecosystem and Building With It

You rarely write raw eBPF bytecode by hand — a rich ecosystem of libraries, languages, and platforms sits on top, and one breakthrough (CO-RE) solved the portability problem that once made eBPF programs fragile across kernel versions. This closing post surveys how you actually build with eBPF, and where the technology is heading.

You rarely write raw eBPF bytecode by hand — a rich ecosystem of libraries, languages, and platforms sits on top, and one breakthrough (CO-RE, Compile Once Run Everywhere) solved the portability problem that once made eBPF programs fragile across kernel versions. This closing post surveys how you actually build with eBPF, and where it's heading.

Pratik Dhanave · ·6 min read

eBPF for Security

Security is eBPF's third domain, and arguably its most natural fit: the kernel sees every syscall, every process, every file access and network connection, so an eBPF program in the kernel is perfectly positioned to watch for and stop malicious behavior in real time. This is why modern runtime-security tools — detecting and blocking threats on live systems — are increasingly built on eBPF.

Security is eBPF's most natural fit: the kernel sees every syscall, process, file access, and network connection, so an eBPF program in the kernel is perfectly positioned to watch for and stop malicious behavior in real time. This is why modern runtime-security tools — detecting and blocking threats on live systems — are increasingly built on eBPF.

Pratik Dhanave · ·5 min read

eBPF for Networking

Networking is where eBPF delivers its most dramatic performance wins. By running packet-processing logic in the kernel — at the earliest possible moment a packet arrives, before the kernel even builds its usual data structures — eBPF can filter, route, and load-balance at speeds user-space networking can't touch. It's why the networking layer of modern cloud-native infrastructure is increasingly eBPF underneath.

Networking is where eBPF delivers its most dramatic performance wins. By running packet-processing logic in the kernel — at the earliest moment a packet arrives, before the kernel builds its usual data structures — eBPF can filter, route, and load-balance at speeds user-space networking can't touch. It's why modern cloud-native networking is increasingly eBPF underneath.

Pratik Dhanave · ·5 min read

eBPF for Observability

Observability is where eBPF first went mainstream, and for good reason: it lets you see almost anything the kernel sees — syscalls, function calls, network events, disk I/O — with very low overhead and, crucially, without changing the code you're observing. That combination broke a long-standing trade-off in tracing and profiling, and it's why modern observability tools are increasingly built on eBPF.

Observability is where eBPF first went mainstream: it lets you see almost anything the kernel sees — syscalls, function calls, network events, disk I/O — with very low overhead and, crucially, without changing the code you're observing. That combination broke a long-standing trade-off in tracing and profiling, and it's why modern observability tools are increasingly built on eBPF.

Pratik Dhanave · ·6 min read

The Verifier and Safety

The verifier is the reason eBPF exists in its modern form. Running arbitrary code in the kernel would be reckless; running code the kernel has proven safe is not. The verifier is the static analyzer that stands between your program and the kernel, mathematically checking that it can't crash, hang, or misbehave — and understanding it explains both eBPF's safety and its constraints.

The verifier is the reason eBPF exists in its modern form. Running arbitrary code in the kernel would be reckless; running code the kernel has proven safe is not. The verifier is the static analyzer that stands between your program and the kernel, mathematically checking it can't crash, hang, or misbehave — and it explains both eBPF's safety and its constraints.

Pratik Dhanave · ·6 min read

How eBPF Works: Programs, Hooks, Maps

An eBPF program's journey — from code you write to logic running in the kernel — has a few distinct pieces: the program itself, the hook it attaches to, the maps it uses to share data, and the load path that gets it safely into the kernel. Once you can name these four things and see how they fit together, eBPF stops being magic and becomes a system you can reason about.

An eBPF program's journey — from code you write to logic running in the kernel — has a few distinct pieces: the program, the hook it attaches to, the maps it uses to share data, and the load path that gets it safely into the kernel. Once you can name these four things and see how they fit, eBPF stops being magic. With an interactive architecture diagram.

Pratik Dhanave · ·5 min read

The Kernel/User-Space Boundary

To understand why eBPF is such a big deal, you have to understand the wall it lets you cross: the boundary between user space and the kernel. That boundary exists for good reasons — safety and isolation — but it also meant that extending the kernel was historically a choice between two bad options. eBPF is the third option nobody had before.

To understand why eBPF is a big deal, you have to understand the wall it lets you cross: the boundary between user space and the kernel. That boundary exists for good reasons — safety and isolation — but it meant extending the kernel was a choice between two bad options: a dangerous kernel module or a limited user-space workaround. eBPF is the third option nobody had before.

Pratik Dhanave · ·5 min read

What eBPF Is, and Why It Matters

eBPF lets you run your own sandboxed programs inside the Linux kernel, safely, without changing kernel source or loading a risky module — and that quietly unlocks a new generation of observability, networking, and security tools. It's one of the most consequential systems technologies of the last decade, and it's worth understanding from first principles. This series builds eBPF up from the problem it solves.

eBPF lets you run your own sandboxed programs inside the Linux kernel, safely, without changing kernel source or loading a risky module — quietly unlocking a new generation of observability, networking, and security tools. It's one of the most consequential systems technologies of the last decade. This series builds eBPF up from the problem it solves.

Pratik Dhanave · ·8 min read

System Calls, and Why OS Knowledge Matters

You can build software for years treating the operating system as a black box — and then one day a production mystery (a service that's slow for no reason, a memory crash, a concurrency heisenbug, a server that won't scale) has an answer that lives entirely below your framework. OS knowledge is what lets you see down there. This closing post shows how everything in the series connects, through the system-call boundary and the diagnostic power it gives you.

You can build software for years treating the OS as a black box — then a production mystery has an answer that lives entirely below your framework. OS knowledge is what lets you see down there. How everything connects, through the system-call boundary and the diagnostic power it gives.

Pratik Dhanave · ·8 min read

I/O and the I/O Models

The difference between a server that handles a hundred connections and one that handles a hundred thousand on the same hardware usually comes down to one choice: how it does I/O. Blocking, non-blocking, and asynchronous I/O aren't interchangeable styles — they're fundamentally different models with different scaling limits, and understanding them explains async/await, event loops, and why the network stack works the way it does.

The difference between a server handling a hundred connections and one handling a hundred thousand usually comes down to one choice: how it does I/O. Blocking, non-blocking, and asynchronous I/O are fundamentally different models with different scaling limits.

Pratik Dhanave · ·7 min read

Modules, Crates, and Project Structure

As a program grows past one file, you need a way to organize it — to group related code, control what's public, and pull in libraries. Rust's module system does this with a clear hierarchy and privacy-by-default, and understanding crates, modules, and paths is what lets your projects scale beyond a single main.rs. This closes Module 2.

As a program grows past one file, you need a way to organize it — to group related code, control what's public, and pull in libraries. Rust's module system does this with a clear hierarchy and privacy-by-default.

Pratik Dhanave · ·7 min read

The Memory Hierarchy and Caching

The single most counterintuitive fact in performance engineering: accessing memory is not one speed. A value in the CPU cache is hundreds of times faster to reach than one in main memory, which is thousands of times faster than disk. Your code's speed often depends less on how many operations it does than on where the data lives — and understanding the memory hierarchy is what lets you see that.

The most counterintuitive fact in performance: accessing memory is not one speed. A value in CPU cache is hundreds of times faster to reach than one in RAM. Your code's speed often depends less on how many operations it does than on where the data lives.

Pratik Dhanave · ·6 min read

Smart Pointers: Box, Rc, and RefCell

Module 1's ownership rules — one owner, borrow-checked references — cover most code. But some data structures genuinely need more: a value on the heap, shared ownership, or mutation through a shared reference. Smart pointers are Rust's escape hatches that provide these while keeping the safety, and knowing the big three is knowing how to model the shapes ownership alone can't.

Ownership's rules cover most code. But some data structures genuinely need more: a value on the heap, shared ownership, or mutation through a shared reference. Smart pointers are Rust's escape hatches that provide these while keeping the safety.

Pratik Dhanave · ·7 min read

Virtual Memory

Every process believes it has the whole machine's memory to itself, starting at address zero, contiguous and private — and none of that is literally true. Virtual memory is the elaborate illusion the OS and hardware maintain to make it true enough, and it's simultaneously what gives processes isolation, what lets you run programs bigger than RAM, and the reason a stray pointer segfaults instead of corrupting another program.

Every process believes it has the whole machine's memory to itself — and none of that is literally true. Virtual memory is the elaborate illusion the OS and hardware maintain, giving isolation, letting you run programs bigger than RAM, and making a stray pointer segfault instead of corrupting others.

Pratik Dhanave · ·7 min read

Error Handling: Result, Option, and No Exceptions

Rust has no exceptions. Errors and absent values are ordinary data — enum values you must handle — so the compiler forces you to deal with the possibility of failure instead of letting it propagate invisibly. It sounds tedious and turns out to be one of Rust's quiet strengths: you cannot forget to handle an error.

Rust has no exceptions. Errors and absent values are ordinary data — enum values you must handle — so the compiler forces you to deal with failure instead of letting it propagate invisibly. It turns out to be one of Rust's quiet strengths.

Pratik Dhanave · ·6 min read

Iterators

Iterators are how Rust does loops without writing loops — a chain of composable adapters (map, filter, collect) that reads like a description of what you want, not how to get it. And the astonishing part is that this high-level, functional style compiles to code as fast as a hand-written loop. Zero-cost abstraction, at its most delightful.

Iterators are how Rust does loops without writing loops — a chain of composable adapters (map, filter, collect) that reads like a description of what you want. And the astonishing part is that this high-level style compiles to code as fast as a hand-written loop.

Pratik Dhanave · ·6 min read

CPU Scheduling

Your machine runs hundreds of processes on a handful of CPU cores, and yet everything feels like it's running at once. That illusion is the CPU scheduler's doing — rapidly switching the cores between processes, dozens of times a second, deciding who runs and for how long. Understanding scheduling explains why your program isn't always running, why context switches cost, and why "add more threads" doesn't always mean faster.

Your machine runs hundreds of processes on a handful of cores, yet everything feels simultaneous. That illusion is the scheduler's doing — rapidly switching cores between processes. It explains why your program isn't always running and why more threads isn't always faster.

Pratik Dhanave · ·6 min read

Structs, Enums, and Pattern Matching

Rust's enums are not the feeble named-constants of other languages — they're full algebraic data types that can hold data, and combined with pattern matching they become one of Rust's most loved features. Together with structs, they're how you model your domain, and the compiler makes sure you handle every case.

Rust's enums are not the feeble named-constants of other languages — they're full algebraic data types that hold data, and combined with pattern matching they become one of Rust's most loved features. Together with structs, they're how you model your domain.

Pratik Dhanave · ·6 min read

Closures

Closures are anonymous functions that can capture variables from around them — and in Rust, the ownership model makes "capture" a precise, three-way question: does the closure borrow, mutably borrow, or take ownership of what it captures? Understanding that is what makes closures (and the iterators that depend on them) click.

Closures are anonymous functions that capture variables from around them — and in Rust the ownership model makes 'capture' a precise, three-way question: does the closure borrow, mutably borrow, or take ownership of what it captures?

Pratik Dhanave · ·7 min read

Threads and Concurrency

A thread lets one process do several things at once — and the moment you have two threads touching the same memory, you've entered the hardest territory in all of programming: concurrency. Race conditions, deadlocks, and the need for synchronization are not exotic edge cases; they're the fundamental consequences of shared mutable state, and understanding them is what separates working concurrent code from code that fails mysteriously.

A thread lets one process do several things at once — and the moment two threads touch the same memory, you're in the hardest territory in programming: concurrency. Race conditions, deadlocks, and synchronization are the fundamental consequences of shared mutable state.

Pratik Dhanave · ·7 min read

Lifetimes

Lifetimes are the part of Rust that looks most alien — those `'a` annotations scattered through function signatures — and the part most misunderstood. They don't change how your code runs; they're just the compiler making explicit a question it's always been asking: how long does this reference need to be valid? Understanding that reframes lifetimes from cryptic syntax to a natural extension of borrowing.

Lifetimes are the part of Rust that looks most alien and is most misunderstood. They don't change how your code runs — they're the compiler making explicit a question it always asks: how long does this reference need to be valid?

Pratik Dhanave · ·6 min read

Trait Objects and Dynamic Dispatch

Generics with trait bounds give you many types, resolved at compile time. But sometimes you need a collection of different types that share a trait — a list of shapes, a set of plugins — decided at runtime. Trait objects provide that, trading a little performance for runtime flexibility. Knowing when to use which is a real Rust design decision.

Generics with trait bounds give many types resolved at compile time. But sometimes you need a collection of different types that share a trait, decided at runtime. Trait objects provide that, trading a little performance for runtime flexibility.

Pratik Dhanave · ·7 min read

Processes

A process is the OS's answer to "what is a running program?" — and it's more than the code: it's the code plus its own private memory, its own resources, and its own isolated view of the machine, as if it owned the computer. That isolation is what lets many programs run at once without corrupting each other, and understanding it explains a huge amount of how systems behave.

A process is the OS's answer to 'what is a running program?' — more than the code: it's the code plus its own private memory, resources, and isolated view of the machine. That isolation is what lets many programs run at once without corrupting each other.

Pratik Dhanave · ·7 min read

Borrowing and References

If ownership were the whole story, Rust would be exhausting — you'd move values in and out of every function by hand. Borrowing is the release valve: it lets code use a value without taking ownership, governed by one elegant rule that also happens to eliminate data races. Ownership makes Rust safe; borrowing makes it usable.

If ownership were the whole story, Rust would be exhausting. Borrowing is the release valve: it lets code use a value without taking ownership, governed by one elegant rule that also happens to eliminate data races. Ownership makes Rust safe; borrowing makes it usable.

Pratik Dhanave · ·6 min read

Traits: Shared Behavior

Traits are Rust's answer to "how do I say that different types share a capability?" — its version of interfaces, but more powerful. They're the mechanism behind generics, operator overloading, iterators, and much of the standard library. If ownership is the heart of Rust's safety, traits are the heart of its abstraction.

Traits are Rust's answer to 'how do I say that different types share a capability?' — its version of interfaces, but more powerful. They power generics, operator overloading, iterators, and much of the standard library. If ownership is Rust's safety heart, traits are its abstraction heart.

Pratik Dhanave · ·7 min read

What an Operating System Does

You write applications that run on top of an operating system every day, and mostly you can ignore it — until a performance mystery, a concurrency bug, or a resource limit forces you to understand what's underneath. The OS is doing two jobs for you constantly: managing the hardware's finite resources, and giving you clean abstractions over messy reality. Understanding those two jobs is understanding the machine your code actually runs on.

You write applications on top of an OS every day and mostly ignore it — until a performance mystery, concurrency bug, or resource limit forces you to understand it. The OS does two jobs: managing finite hardware, and abstracting messy reality. Understanding them is understanding the machine your code runs on.

Pratik Dhanave · ·7 min read

Ownership: Rust's Big Idea

Ownership is the idea that makes Rust Rust — the mechanism that delivers memory safety without a garbage collector. It's a set of three simple rules with deep consequences, and it's the one concept you must genuinely understand, because everything distinctive about the language flows from it. This is the heart of the series.

Ownership is the idea that makes Rust Rust — the mechanism that delivers memory safety without a garbage collector. Three simple rules with deep consequences, and the one concept you must genuinely understand, because everything distinctive flows from it.

Pratik Dhanave · ·6 min read

Generics

Writing the same function three times for three types is the kind of duplication that rots a codebase. Generics let you write it once, over any type — and Rust's twist is that this abstraction costs nothing at runtime, because the compiler generates the specialized versions for you. Zero-cost abstraction starts here.

Writing the same function three times for three types is duplication that rots a codebase. Generics let you write it once over any type — and Rust's twist is that this abstraction costs nothing at runtime, because the compiler generates the specialized versions.

Pratik Dhanave · ·6 min read

Variables, Types, and Immutability by Default

In most languages, variables vary — that's the default, and you opt into constancy. Rust flips it: variables are immutable unless you say otherwise. That one inverted default, plus a strong static type system with inference, quietly shapes how Rust code is written and prevents a whole class of bugs before you meet ownership.

In most languages variables vary by default; Rust flips it — variables are immutable unless you say otherwise. That one inverted default, plus a strong static type system with inference, quietly shapes how Rust is written and prevents a class of bugs.

Pratik Dhanave · ·6 min read

Collections: Vec, String, and HashMap

Module 1's arrays and tuples were fixed-size and stack-bound. Real programs need growable, heap-backed collections — and Rust's three workhorses, Vec, String, and HashMap, are where ownership and borrowing stop being abstract rules and become the everyday texture of writing Rust. This opens Module 2: the data structures and abstractions you actually build with.

Real programs need growable, heap-backed collections — and Rust's three workhorses, Vec, String, and HashMap, are where ownership and borrowing stop being abstract rules and become the everyday texture of writing Rust.

Pratik Dhanave · ·6 min read

Getting Started: Cargo and the Toolchain

Rust's tooling is one of its quiet superpowers — a single tool, Cargo, handles building, dependencies, testing, and more, and it's good enough that Rust developers rarely think about build systems at all. Before the language's hard ideas, meet the tooling that makes working in Rust pleasant.

Rust's tooling is a quiet superpower — a single tool, Cargo, handles building, dependencies, testing, and more, and it's good enough that Rust developers rarely think about build systems at all. Meet the tooling that makes working in Rust pleasant.

Pratik Dhanave · ·6 min read

Why Rust?

Rust makes a promise that sounds impossible: memory safety without a garbage collector, and fearless concurrency without data races — all checked at compile time, with no runtime cost. The price is a compiler that argues with you until your program is correct. Understanding that bargain is the key to understanding why Rust exists and why people love it.

Rust makes a promise that sounds impossible: memory safety without a garbage collector, and fearless concurrency without data races — all checked at compile time, with no runtime cost. The price is a compiler that argues with you until your program is correct.

Pratik Dhanave · ·7 min read

The Preprocessor, Undefined Behavior, and Safe C

Two things separate C programmers who ship reliable code from those who ship time bombs: understanding the preprocessor (the text-substitution pass that runs before compilation) and respecting undefined behavior (the operations C says have no defined meaning at all). This closing post covers both, plus the multi-file structure of real programs and the idioms that keep C safe — turning the whole series into a working discipline.

Two things separate C programmers who ship reliable code from those who ship time bombs: understanding the preprocessor (the text-substitution pass before compilation) and respecting undefined behavior (operations C says have no meaning at all). This closing post covers both, multi-file programs, and the idioms that keep C safe.

Pratik Dhanave · ·7 min read

Structs, Unions, and Data Structures

Structs let you bundle related data into a single named type — the closest C gets to an object. Combined with pointers and heap allocation, they're how you build every data structure C is famous for: linked lists, trees, hash tables. This post covers structs, their cousins unions and enums, the memory-layout details that bite (padding), and puts it all together to build a linked list from scratch.

Structs let you bundle related data into a single named type — the closest C gets to an object. Combined with pointers and heap allocation, they're how you build every data structure C is famous for: linked lists, trees, hash tables. This post covers structs, unions, enums, the padding that bites, and builds a linked list from scratch.

Pratik Dhanave · ·7 min read

Dynamic Memory Management

Stack memory is automatic but rigid — sized at compile time and gone when a function returns. For data whose size you only know at runtime, or that must outlive the function that created it, C gives you the heap and four functions to manage it: `malloc`, `calloc`, `realloc`, and `free`. With that power comes C's heaviest responsibility: every allocation you make, you must free — exactly once, and never use again.

Stack memory is automatic but rigid. For data whose size you only know at runtime, or that must outlive its function, C gives you the heap and four functions: malloc, calloc, realloc, and free. With that power comes C's heaviest responsibility: every allocation you make, you must free — exactly once, and never use again.

Pratik Dhanave · ·6 min read

Arrays, Strings, and Memory Layout

Arrays and strings in C are where the pointer model from the last post becomes concrete — and where C's most infamous security bugs live. An array is a contiguous block of memory whose name decays to a pointer; a string is just an array of characters with a null terminator and no length field. Understanding both, and the buffer overflows they invite, is essential C literacy.

Arrays and strings are where the pointer model becomes concrete — and where C's most infamous security bugs live. An array is a contiguous block whose name decays to a pointer; a string is just a char array with a null terminator and no length field. Understanding both, and the buffer overflows they invite, is essential C literacy.

Pratik Dhanave · ·6 min read

Pointers

Pointers are the heart of C, the feature that makes it powerful and the one that makes it dangerous. A pointer is just a variable that holds a memory address — but that simple idea is how C functions modify their callers, how arrays and strings work, how dynamic memory is managed, and how data structures are built. Everything hard and everything essential in C runs through pointers.

Pointers are the heart of C — the feature that makes it powerful and the one that makes it dangerous. A pointer is just a variable holding a memory address, but that simple idea is how C functions modify their callers, how arrays and strings work, how dynamic memory is managed, and how data structures are built. Everything essential runs through pointers.

Pratik Dhanave · ·6 min read

Control Flow, Functions, and the Stack

C's control flow is the ancestor of the syntax you already know — `if`, `while`, `for`, `switch`. Its functions look familiar too, but they hide a defining C fact: arguments are passed by value, always copied. Understanding pass-by-value, and the call stack that makes function calls work, is the bridge to the hardest and most important topic in C — pointers.

C's control flow is the ancestor of the syntax you already know, and its functions look familiar too — but they hide a defining C fact: arguments are passed by value, always copied. Understanding pass-by-value, and the call stack that makes function calls work, is the bridge to the hardest and most important topic in C: pointers.

Pratik Dhanave · ·6 min read

Types, Variables, and Operators

In C, a type is a promise about how many bytes a value occupies and how to interpret them. There's no hidden bignum, no automatic string, no safety rail — just fixed-width integers, floating-point, and the bit patterns underneath. Understanding C's types means understanding sizes, signedness, and the surprising rules of integer promotion, because in C the difference between `int` and `unsigned` can be the difference between correct and catastrophically wrong.

In C, a type is a promise about how many bytes a value occupies and how to interpret them — no hidden bignum, no safety rail, just fixed-width integers and the bits underneath. Understanding C's types means understanding sizes, signedness, and the surprising rules of integer promotion, where the difference between int and unsigned can be catastrophic.

Pratik Dhanave · ·6 min read

Why C, and How It Compiles

C is fifty years old and still runs the world — operating systems, databases, language runtimes, embedded devices, and the standard libraries under almost everything else. Learning C is learning how computers actually work: memory, pointers, and the thin layer between your code and the machine. This series builds C from the ground up, and it starts with what C is and what really happens when you compile it.

C is fifty years old and still runs the world — operating systems, databases, language runtimes, embedded devices. Learning C is learning how computers actually work: memory, pointers, and the thin layer between your code and the machine. This series builds C from the ground up, starting with what C is and what really happens when you compile it.

Pratik Dhanave · ·8 min read

Macros

You've been using macros since your very first Rust program — `println!` is one, and so are `vec!`, `assert_eq!`, and `#[derive(...)]`. That telltale exclamation mark, and those `#[...]` attributes, mark code that isn't a normal function call but metaprogramming: code that writes code at compile time. Macros are how Rust does the powerful, boilerplate-eliminating tricks that would need runtime reflection or code generators in other languages — all checked at compile time. This closing post of the series demystifies them.

You've been using macros since your first Rust program — println! is one, and so are vec!, assert_eq!, and #[derive(...)]. That exclamation mark marks metaprogramming: code that writes code at compile time. This closing post of the series demystifies Rust's powerful, boilerplate-eliminating macro system.

Pratik Dhanave · ·8 min read

Error Handling with anyhow and thiserror

Module 1 covered Rust's error-handling foundation — `Result`, `Option`, and the `?` operator. It works, but as programs grow, two friction points appear: defining custom error types by hand is tedious boilerplate, and propagating many different error types through `?` gets awkward. The Rust ecosystem answers with two small, near-universal crates — `thiserror` and `anyhow` — that make error handling ergonomic. Knowing which to use where is a piece of practical Rust fluency every real project needs.

Module 1 covered Rust's error-handling foundation — Result, Option, and ?. As programs grow, two frictions appear: defining custom error types is tedious boilerplate, and propagating many error types through ? gets awkward. The ecosystem answers with two near-universal crates — thiserror and anyhow — and knowing which to use where is essential Rust fluency.

Pratik Dhanave · ·8 min read

Testing in Rust

Most languages treat testing as an afterthought — a separate framework you bolt on, a separate directory, a separate mental mode. Rust treats it as a first-class, built-in feature: testing is part of the language and its tooling, you write tests right next to the code they test, and `cargo test` just works. This tight integration, combined with Rust's culture of correctness, makes testing in Rust unusually pleasant and encourages a habit that pairs perfectly with the compiler's guarantees.

Most languages treat testing as an afterthought. Rust treats it as first-class and built-in: testing is part of the language and tooling, you write tests right next to the code, and cargo test just works. This tight integration makes testing in Rust unusually pleasant.

Pratik Dhanave · ·8 min read

Async and Await

Threads are great for CPU-bound parallelism, but for handling thousands of network connections — each mostly waiting — spawning a thread per connection doesn't scale (recall the C10K problem from the OS series). Async/await is Rust's answer: write code that looks sequential but doesn't block a thread while waiting, letting a handful of threads handle enormous concurrency. Rust's async is powerful and zero-cost, with one distinctive twist — you bring your own runtime to actually run the async code.

For handling thousands of connections each mostly waiting, spawning a thread per connection doesn't scale. Async/await is Rust's answer: write code that looks sequential but doesn't block a thread while waiting. Rust's async is powerful and zero-cost, with one distinctive twist — you bring your own runtime.

Pratik Dhanave · ·8 min read

Message Passing with Channels

There are two great philosophies of concurrency: share memory (with locks, as the previous posts covered) or share nothing and communicate by passing messages. The message-passing school has a famous slogan — "do not communicate by sharing memory; instead, share memory by communicating" — and Rust supports it fully with channels. Instead of multiple threads carefully locking shared state, ownership of data is transferred from one thread to another through a channel, and Rust's ownership system makes that transfer clean and safe.

There are two great philosophies of concurrency: share memory (with locks) or share nothing and communicate by passing messages. Rust supports channels fully — and its ownership system makes message passing especially natural, because sending data through a channel is transferring ownership.

Pratik Dhanave · ·8 min read

Send and Sync: The Traits Behind Fearless Concurrency

How does the Rust compiler actually know that an `Arc<Mutex<T>>` is safe to share across threads but an `Rc<T>` isn't? The answer is two of the most elegant ideas in Rust: a pair of marker traits, `Send` and `Sync`, that encode thread-safety directly into the type system. They're rarely written by hand and often invisible, yet they're the machinery that makes fearless concurrency work — the compiler reasons about thread-safety by checking these traits, automatically, at compile time.

How does the compiler know an Arc<Mutex<T>> is safe to share across threads but an Rc<T> isn't? The answer is two elegant marker traits — Send and Sync — that encode thread-safety directly into the type system. Rarely written by hand and often invisible, they're the machinery that makes fearless concurrency work.

Pratik Dhanave · ·8 min read

Shared State: Arc and Mutex

Moving data into a single thread is safe but limiting — sometimes multiple threads genuinely need to share and mutate the same data. This is exactly where data races live in other languages, and where Rust's guarantees shine brightest. The answer is a pair of types, `Arc` and `Mutex`, that let you share mutable state across threads — and the compiler will refuse to compile code that shares it unsafely. You literally cannot forget the lock, because the data lives inside it.

Sometimes multiple threads genuinely need to share and mutate the same data — exactly where data races live in other languages, and where Rust's guarantees shine brightest. The answer is Arc and Mutex, which let you share mutable state across threads while the compiler refuses to compile unsafe sharing. You literally cannot forget the lock.

Pratik Dhanave · ·6 min read

Threads and Fearless Concurrency

Rust's boldest promise is "fearless concurrency" — the claim that you can write multithreaded code and have the compiler guarantee, at compile time, that you have no data races. Coming from languages where concurrency bugs are a dark art of subtle, intermittent horror, this sounds too good to be true. It isn't: the same ownership and borrowing rules that give Rust memory safety extend naturally to threads. This module explores concurrency, starting with the basics — spawning threads and moving data into them.

Rust's boldest promise is fearless concurrency — write multithreaded code and have the compiler guarantee, at compile time, that you have no data races. It isn't too good to be true: the same ownership and borrowing rules that give memory safety extend naturally to threads. Module 3 begins with the basics — spawning threads and moving data into them.

Pratik Dhanave · ·7 min read

Performance, Idioms, and Where to Go Next

Rust's central promise — the one that runs through this entire curriculum — is that you don't have to choose between safety and speed. The abstractions that make Rust pleasant to write (iterators, closures, traits, generics) compile down to code as fast as hand-written low-level equivalents. This closing post steps back to that promise, to what "idiomatic Rust" really means, and to where you go after the fundamentals. It's the capstone of Rust from the Ground Up — a look at the whole, and the road ahead.

Rust's central promise — the one that runs through this whole curriculum — is that you don't have to choose between safety and speed. This closing post steps back to that promise, to what 'idiomatic Rust' really means, and to where you go after the fundamentals. The capstone of Rust from the Ground Up.

Pratik Dhanave · ·7 min read

The Crate Ecosystem and Tooling

A language is more than its syntax — it's the ecosystem and tooling around it, and this is one of Rust's quiet triumphs. The same Cargo you met on day one is the gateway to a vast registry of reusable libraries, a linter that teaches you idiomatic Rust, a formatter that ends style debates, and first-class documentation tooling. Rust's tooling is famously good, and knowing it turns you from someone who writes Rust into someone who's productive and idiomatic in the Rust ecosystem.

A language is more than its syntax — it's the ecosystem and tooling around it, and this is one of Rust's quiet triumphs. The same Cargo you met on day one is the gateway to a vast registry of libraries, a linter that teaches idiomatic Rust, a formatter that ends style debates, and first-class documentation tooling.

Pratik Dhanave · ·8 min read

Building a Command-Line Application

Everything so far has been pieces — ownership, traits, error handling, modules. Now we put them together into the kind of thing you'd actually ship: a small command-line application. Building a real program reveals how Rust's features combine in practice — structuring the code, parsing arguments, handling errors gracefully with `Result` and `?`, separating logic from `main` for testability, and returning proper exit codes. It's where the language stops being a set of concepts and becomes a tool for building software.

Everything so far has been pieces — ownership, traits, error handling, modules. Now we put them together into the kind of thing you'd actually ship: a small command-line application. Building a real program reveals how Rust's features combine in practice, where the language becomes a tool for building software.

Pratik Dhanave · ·8 min read

Closures and Function Pointers, Revisited

Module 2 introduced closures as anonymous functions that capture their environment. But once you start passing functions around as values — storing callbacks, building higher-order APIs, returning behavior from functions — a few subtleties surface: functions and closures aren't quite the same type, returning a closure requires a boxing trick, and the `Fn` trait family has a precise structure worth knowing. These details show up constantly in real Rust APIs, and mastering them makes you fluent in Rust's functional side.

Module 2 introduced closures. But once you start passing functions around as values — callbacks, higher-order APIs, returning behavior — subtleties surface: functions and closures aren't quite the same type, returning a closure requires a boxing trick, and the Fn trait family has a precise structure worth knowing.

Pratik Dhanave · ·8 min read

Foreign Function Interface (FFI)

No language is an island. Decades of critical software — operating systems, libraries, codecs, crypto — is written in C, and any systems language that couldn't talk to it would be dead on arrival. Rust's foreign function interface lets it call C code (and be called from C), which is essential for interoperating with the existing world and for adopting Rust incrementally into C/C++ codebases. Crossing that boundary means leaving Rust's safety guarantees behind, so FFI is inherently unsafe — but it's a controlled, well-defined kind of unsafe.

No language is an island. Decades of critical software is written in C, and any systems language that couldn't talk to it would be dead on arrival. Rust's foreign function interface lets it call C (and be called from C) — essential for interoperating with the existing world and adopting Rust incrementally.

Pratik Dhanave · ·8 min read

Unsafe Rust

There is a keyword in Rust that feels almost heretical given everything the language stands for: `unsafe`. It exists because Rust's safety guarantees, powerful as they are, are necessarily conservative — the compiler rejects some things that are actually fine, and some low-level operations (talking to hardware, calling C, building certain data structures) genuinely require capabilities the safe subset forbids. `unsafe` is the escape hatch, and understanding it — what it does, what it doesn't, and how to use it responsibly — completes the picture of how Rust achieves safety.

There is a keyword in Rust that feels almost heretical: `unsafe`. It exists because Rust's safety guarantees are necessarily conservative, and some low-level operations genuinely require capabilities the safe subset forbids. Understanding it — what it does and doesn't do — completes the picture of how Rust achieves safety.

Pratik Dhanave · ·7 min read

Advanced Types

Rust's type system has a few corners that don't come up in beginner code but explain things you've quietly wondered about — why some functions "return" a type that isn't really a type, why `str` behaves differently from other types, and how to give a complicated type a readable name. These advanced type features are small individually but together deepen your understanding of how Rust's type system actually works, which pays off when reading real code and library internals.

Rust's type system has a few corners that don't come up in beginner code but explain things you've quietly wondered about — why some functions 'return' a type that isn't really a type, why `str` behaves differently, and how to give a complicated type a readable name.

Pratik Dhanave · ·8 min read

Advanced Traits

Traits are Rust's core abstraction mechanism, and Module 2 covered the essentials — but the trait system has more depth that shows up constantly in real code and library APIs: associated types that make traits cleaner than generics, operator overloading, traits that build on other traits, and a pattern that lets you work around Rust's coherence rules. This module goes beyond the foundations into the advanced features you'll meet in serious Rust, starting with the corners of the trait system.

Traits are Rust's core abstraction, and Module 2 covered the essentials — but the trait system has more depth that shows up constantly in real code: associated types that make traits cleaner than generics, operator overloading, traits that build on other traits, and a pattern for working around Rust's coherence rules.

All posts on this site are written by Pratik Dhanave, an Agentic AI Architect with 7+ years building production distributed systems, multi-agent AI platforms, and cloud-native infrastructure. About the author → Each article includes working code, architecture diagrams, and references to the specific frameworks and standards discussed. Browse all posts or explore related topics using the tag cloud above.