Coding by Hand

Course

Rust

From your first borrow check to a self-hosted cloud you wrote yourself. Data structures, algorithms, kernels, file systems, containers, distributed systems, and the AWS services they imitate — all built by hand in Rust.

95 of 231 lessons across 31 sections.

Philosophy

Foundations

Rust Primitives

Ownership and Borrowing

Errors and I/O

Data Structures

Algorithms

Traits, Generics, Paradigms

Under the Hood

Project: Poker

Low-Level Design

Crates and Libraries

  • What Is a Crate
    `Cargo.toml`, `lib.rs`. Build: a library, `cargo package`. Output: docs.rs-style surface.
  • serdeSoon
    Derive macros. Build: round-trip a struct through JSON, CBOR, postcard. Output: byte-size comparison.
  • ndarraySoon
    N-dim arrays, broadcasting, strides. Build: a small matmul + a broadcast op. Output: memory-layout diagram.
  • polarsSoon
    DataFrames, lazy frames, joins. Build: re-analyze the Python ETL dataset. Output: the same plot, in Rust.
  • plottersSoon
    Static charts. Build: render every chart this course has produced so far. Output: PNG gallery.
  • tch-rs / burnSoon
    Tensors, autograd, two-layer MLP. Build: a 2-layer MLP trained end-to-end on MNIST. Output: loss curve + a few correct/incorrect predictions.

Data and Stats

Services

AI

Cloud, Consumer Edition

Concurrency

  • Threads, Send, SyncSoon
    Build: a parallel sum the compiler accepts and one it rejects. Output: what-compiles matrix.
  • ChannelsSoon
    mpsc, crossbeam. Build: worker pool. Output: job-flow timeline.
  • Mutexes and RwLocksSoon
    Build: shared counter, race-then-fix. Output: contention plot.
  • Condition VariablesSoon
    wait/notify. Build: a bounded buffer with cv signaling. Output: producer/consumer timeline.
  • SemaphoresSoon
    Counting permits, the often-wrong-primitive lesson. Build: a connection-pool limiter. Output: permit-count timeline.
  • Atomics and the Memory ModelSoon
    Ordering made concrete. Build: lock-free counter, SPSC queue. Output: before/after reordering diagrams.
  • Locked Data StructuresSoon
    Build: coarse vs fine-grained locked HashMap. Output: throughput-vs-threads chart.
  • Concurrency BugsSoon
    Data race vs deadlock vs atomicity violation. Build: one reproducible example of each. Output: taxonomy table + trace per bug.
  • Print FooBar AlternatelySoon
    Two-thread alternation. Build: condvar version and channel version. Output: interleaving trace.
  • Print Zero Even OddSoon
    Three-way coordination. Build: three threads + two semaphores. Output: per-thread Gantt.
  • Fizz Buzz MultithreadedSoon
    Four-way work distribution. Build: one thread per output type. Output: output trace + per-thread tick count.
  • Building H₂O MoleculeSoon
    Barrier for grouped threads. Build: a 2H+1O barrier. Output: molecule-assembly timeline.
  • Thread-Safe Blocking QueueSoon
    Build: `BlockingQueue<T>` with bounded capacity. Output: blocking-then-unblocking timeline.
  • Thread-Safe Cache with TTLSoon
    Build: `TTLCache<K, V>` with `RwLock` + background expirer thread. Output: hit/miss/evict timeline.
  • Concurrent HashMapSoon
    Lock striping, dashmap-style. Build: a 16-stripe HashMap. Output: contention heatmap by stripe.
  • Concurrent Bloom FilterSoon
    Build: atomic-bitset Bloom filter. Output: false-positive rate vs load chart.

Async

  • Multi-threaded Merge SortSoon
    Divide-and-conquer parallelism. Build: parallel merge sort with `rayon::join`. Output: speedup-vs-cores chart.
  • Build a Toy Async ExecutorSoon
    Futures, wakers. Build: 300-line executor running ten tasks. Output: runtime trace.
  • Async with tokioSoon
    Tasks, `select!`, cancellation. Build: port scanner with timeouts. Output: live port-state grid.

Networking

  • IP — the Network LayerSoon
    Addresses, fragmentation, TTL. Build: parse and pretty-print an IP packet from hex. Output: annotated packet diagram.
  • UDPSoon
    Connectionless datagrams. Build: a UDP echo server + a packet-loss simulator. Output: loss-vs-throughput chart.
  • TCP from the BottomSoon
    Sockets, three-way handshake. Build: `TcpListener` echo server. Output: Wireshark-style capture.
  • ICMPSoon
    ping, traceroute. Build: both, by hand. Output: hop-by-hop latency table.
  • ARPSoon
    IP → MAC on the LAN. Build: raw-socket ARP query. Output: ARP cache view, before/after.
  • DHCPSoon
    Auto-config. Build: a tiny DHCP client. Output: DORA sequence diagram.
  • BGP — Inter-AS RoutingSoon
    Path vectors at internet scale. Build: a toy BGP speaker between two ASes. Output: AS-path graph.
  • HTTP/1.1 by HandSoon
    Build: 300-line HTTP server. Output: one-request sequence diagram.
  • TLS from ScratchSoon
    Handshake, cert chain, AEAD. Build: a TLS 1.3 client speaking to a real server (using ring for primitives, not building crypto from scratch). Output: handshake state machine + key-derivation trace.
  • HTTPSSoon
    HTTP over TLS, HSTS, cert pinning. Build: an axum server with rustls. Output: browser padlock + cert chain rendered.
  • WebSocketsSoon
    Upgrade, frames, pings. Build: chat server. Output: live multi-client terminal chat.
  • DNS Resolver and mio Event LoopsSoon
    UDP packets, raw event-loop. Build: a dig clone + a mio echo server. Output: parsed DNS answer + event-loop tick diagram.

Persistence

  • I/O DevicesSoon
    DMA, MMIO, polling vs interrupts. Build: simulate each model in userspace. Output: throughput chart per model.
  • Hard Disk DrivesSoon
    Geometry, rotational latency. Build: model an HDD with seek + rotation. Output: access-pattern latency chart.
  • Flash SSDsSoon
    FTL, wear leveling, GC. Build: a tiny FTL with garbage collection. Output: erase-block heatmap.
  • RAIDSoon
    0/1/5/6. Build: a software RAID-5 striper with parity. Output: read/write/rebuild speed chart.
  • Block Devices and the Page CacheSoon
    Disks pretend to be byte streams. Build: read/write a raw block device file. Output: IO-size vs latency chart.
  • Build a Write-Ahead LogSoon
    Build: 300-line WAL. Output: crash-then-recover animation.
  • A KV Store on the WALSoon
    Build: put/get/delete crash-safe. Output: throughput vs sled.
  • B-trees on DiskSoon
    Pages, splits, merges. Build: single-file B-tree. Output: page-layout viewer.
  • LSM-treesSoon
    Memtable, SSTables, compaction. Build: tiny LSM. Output: compaction animation.
  • Snapshots and MVCCSoon
    Build: MVCC on the KV store. Output: two transactions seeing different snapshots.
  • Data IntegritySoon
    Checksums, end-to-end verification, scrubbing. Build: CRC32 + a ZFS-style scrubber. Output: corruption-detection trace.
  • WAL+B-tree vs LSMSoon
    Build: same workload, both engines. Output: read/write/space three-way chart.

Filesystems

  • What a Filesystem IsSoon
    Inodes, directories. Build: parse an ext2 image from hex. Output: annotated hex viewer.
  • FUSE in RustSoon
    Build: mount a filesystem on your KV store. Output: live tree of the mounted FS.
  • JournalingSoon
    Crash safety, atomic renames. Build: a journal on top of FUSE. Output: before/after crash mid-write.
  • FFS — Fast File SystemSoon
    Cylinder groups, the historical leap. Build: a cylinder-group-aware allocator on top of FUSE. Output: allocation-locality heatmap.
  • LFS — Log-structured File SystemSoon
    Append-only segments. Build: an LFS-style allocator. Output: segment-utilization chart over time.
  • OCI-shaped Overlay FilesystemSoon
    Layered images. Build: lower + upper, render merged. Output: three-pane diff viewer.
  • NFS and AFSSoon
    Network and whole-file caching. Build: tiny NFS-shaped server + an AFS-shaped client. Output: cache-state diagram per model.

Distributed Systems

  • Replication and ConsistencySoon
    Single leader, multi-leader, leaderless. Build: a replicated KV with chosen consistency. Output: replication-lag chart + consistency-anomaly trace.
  • Consensus — RaftSoon
    Leader election, log replication. Build: a 3-node Raft. Output: election timeline + log convergence.
  • CAP, PACELC, and Vector ClocksSoon
    Build: a vector clock + a partition simulator. Output: concurrent-event graph.
  • Two-Phase Commit and SagasSoon
    Distributed transactions. Build: a 2PC coordinator + a saga compensator. Output: sequence diagram per protocol.
  • Distributed TracingSoon
    Spans, baggage, sampling. Build: propagate a trace-id across three services. Output: flame graph.

Security

  • Intro to SecuritySoon
    Threat models, trust boundaries, defense in depth. Build: a STRIDE threat-model doc for one of your earlier projects. Output: the threat-model table + a trust-boundary diagram.
  • AuthenticationSoon
    Passwords, salts, MFA, password-less. Build: Argon2 + TOTP MFA. Output: hash-derivation trace + QR code for TOTP setup.
  • Access ControlSoon
    Capabilities vs ACLs vs RBAC vs ABAC. Build: a policy engine evaluating all four models. Output: per-model permission matrix.
  • Cryptography by HandSoon
    Symmetric, asymmetric, hashes, signatures, AEAD. Build: each primitive once from a textbook recipe (slow, educational; never ship). Output: round-trip animation per primitive.
  • Distributed SecuritySoon
    Kerberos, OAuth 2, signed requests. Build: an OAuth 2 client and resource server. Output: token-flow sequence diagram.
  • Practical Security BugsSoon
    SQLi, XSS, CSRF, buffer overflow. Build: break and fix one of each in your axum/sqlx code. Output: before/after request-flow diagrams.

Bare Metal

  • `no_std` and the AllocatorSoon
    Build: `no_std` Linux binary via libc. Output: binary-size comparison.
  • Linker Scripts and the Boot PathSoon
    Build: a linker script + `_start`. Output: annotated `readelf`.
  • QEMU as a Dev LoopSoon
    Build: cargo runner → QEMU → serial. Output: serial console screenshot.
  • Hello, FramebufferSoon
    Build: draw a red square. Output: the red square in QEMU.
  • Reading Keyboard via PS/2Soon
    Build: IRQ handler that echoes. Output: live framebuffer echo.

Silicon and Instruction Sets

Virtualization — Kernel

  • Three Easy Pieces, MappedSoon
    The plan. Build: none. Output: kernel architecture diagram.
  • Direct ExecutionSoon
    How the kernel hands the CPU to user code and gets it back. Build: a trap on a software interrupt. Output: trap entry/exit register diagram.
  • Processes and the Kernel StackSoon
    Build: a `Process` struct, fork two. Output: process table.
  • Context SwitchingSoon
    Build: switch routine in inline asm. Output: register-save animation.
  • Memory API (Userspace)Soon
    brk, sbrk, mmap. Build: a userspace malloc/free on top of sbrk. Output: heap layout over time.
  • SegmentationSoon
    Base + bounds, the pre-paging world. Build: a segmented address space simulator. Output: segment-table walk.
  • Paging and the MMUSoon
    Build: identity-map first 4 MB by hand. Output: address-translation visualizer.
  • Page Tables in RustSoon
    Multi-level. Build: page-table builder. Output: live page-table tree.
  • TLB — Translation Lookaside BuffersSoon
    Hit/miss cost. Build: a TLB simulator over a memory-access trace. Output: hit-rate vs working-set chart.
  • Swapping: MechanismsSoon
    Page in, page out. Build: a swap-backed page fault handler. Output: page-fault rate over a working-set trace.
  • Swapping: PoliciesSoon
    FIFO, LRU, clock, working set. Build: all four. Output: miss-rate-vs-policy chart on the same trace.
  • Heap and Kernel AllocatorsSoon
    Bump, linked-list, slab. Build: a kernel `Box`. Output: fragmentation map.
  • Interrupts and the IDTSoon
    Build: timer interrupt that prints. Output: tick-frequency timing chart.
  • The Syscall BoundarySoon
    Build: a `write` syscall. Output: register-flow diagram across the boundary.

Scheduling

  • Round-RobinSoon
    Build: it. Output: Gantt chart of CPU per process.
  • MLFQSoon
    Build: it. Output: Gantt vs RR on mixed CPU/IO workload.
  • Lottery SchedulingSoon
    Tickets, fairness, currency. Build: it. Output: CPU-share-vs-tickets chart.
  • CFS-LiteSoon
    vruntime, red-black tree. Build: it. Output: vruntime growth per process.
  • Multi-CPU SchedulingSoon
    Per-CPU runqueues, work stealing, affinity. Build: a 4-CPU scheduler with stealing. Output: per-CPU utilization + migration count chart.
  • Benchmark All SchedulersSoon
    Build: the harness. Output: Gantts side-by-side + summary table.
  • GenAI as a SchedulerSoon
    The contrast. Build: feed the process table to an LLM. Output: latency-vs-determinism chart + discussion.

Kernel Capstone

  • Inter-Process CommunicationSoon
    Pipes, shared memory, message passing. Build: a pipe between two processes. Output: message-flow diagram.
  • Loading an ELF BinarySoon
    Build: the ELF loader. Output: loaded address space visualized.
  • The User-Mode JumpSoon
    Build: drop privilege, set stack, jump. Output: userspace "hello" running on your kernel.
  • A Userspace Shell on Your KernelSoon
    Build: read, parse, exec. Output: ls/echo running on your OS.

Containers

  • chroot — The OriginalSoon
    Build: a chrooted shell. Output: truncated FS view.
  • NamespacesSoon
    mount, PID, net, user, IPC, UTS. Build: clone with each flag. Output: six side-by-side terminals showing isolation.
  • cgroupsSoon
    CPU, memory, IO. Build: limit a CPU-burner to one core. Output: CPU-percent chart before/after.
  • Overlay Filesystem in RustSoon
    Build: mount lower + upper. Output: three-pane diff viewer.
  • The OCI Image FormatSoon
    Build: construct a valid image. Output: layer-tree with sha256 hashes.
  • A Container RuntimeSoon
    Build: runc-shaped, ~800 lines. Output: lifecycle state diagram.
  • A Container RegistrySoon
    Build: axum + your KV. Output: push/pull sequence diagram.
  • Networking Between ContainersSoon
    Bridges, veth, NAT. Build: two containers over a bridge. Output: topology + packet flow.

Cloud, Builder Edition

  • S3-Lite — Object StoreSoon
    Build: on your KV, with presigned URLs. Output: browser uploading via your URL.
  • DynamoDB-Lite — Sharded KVSoon
    Partition keys, GSIs. Build: it. Output: request distribution heatmap.
  • SQS-Lite — Durable QueueSoon
    Visibility timeouts, DLQ. Build: on your WAL. Output: message lifecycle with retry + DLQ.
  • SNS-Lite — Pub/SubSoon
    Fanout to multiple queues. Build: on top of SQS-lite. Output: fanout diagram.
  • ElastiCache-Lite — In-Memory CacheSoon
    Build: a Redis-shaped server speaking RESP. Output: hit-rate + p99 chart.
  • VPC-Lite — Cloud NetworkingSoon
    Software bridges + routing tables. Build: multi-subnet virtual network. Output: topology diagram.
  • ELB-Lite — Load BalancerSoon
    L7 round-robin + health checks. Build: it, on top of axum. Output: per-backend traffic chart.
  • CloudFront-Lite — Edge CDNSoon
    Edge nodes + signed URLs. Build: a 3-edge CDN. Output: origin-vs-edge latency chart.
  • Lambda-Lite — Functions as a ServiceSoon
    Build: on your container runtime. Output: invocation timeline.
  • ECS-Lite — OrchestrationSoon
    Bin-packing placement. Build: it. Output: live placement diagram.
  • GenAI as a Pod SchedulerSoon
    Where the slow oracle finally helps. Build: LLM picks placement, compare to bin-packing. Output: placement-quality chart.
  • CloudWatch-Lite + X-Ray-Lite — Metrics and TracesSoon
    Build: a Prometheus-shaped scraper + a Jaeger-shaped trace collector. Output: live dashboard + flame graph.
  • CloudFormation-Lite + IAM-LiteSoon
    Declarative resource trees + signed requests. Build: a YAML applier driving your S3/Dynamo/SQS/Lambda/ECS + sigv4-style signing. Output: dependency graph of a stack being applied + signed-request walkthrough.

Final Capstone — Your Cloud

  • Deploy a Real App on Your CloudSoon
    A Rust photo-blog: web service in your Lambda, photos in your S3, posts in your DynamoDB, image-resize jobs through your SQS, scheduled by your ECS, in containers on your kernel, on your filesystem, behind your ELB, cached at your CDN edges, observed by your CloudWatch and X-Ray. Build: every glue piece. Output: browser screenshot of the running app.
  • Trace One Request Through the Whole StackSoon
    Build: a tracing-id propagated end-to-end. Output: flame graph from HTTP request through kernel syscall.
  • Where to Go NextSoon
    The map of adjacent territory. Build: none — a curated reading list. Output: graph of next stops (compilers, distributed databases, formal methods, GPU programming, embedded).