One Server, Three Languages
Learn C, Go and Rust from scratch by building the same Redis-compatible server three times, and understand the power and the weakness of each
- C17 · Go 1.27 · Rust 1.99
- One server, built three times
- 62 exercises with solutions
- 101-row scorecard
- Part V: Rust from first principles
You learn by building, you used C at university and Go a few years ago and forgot both, and you have heard that Rust is the systems language now. This book teaches all three from scratch by building one project three times: kv, a key-value server that speaks the Redis protocol, so that the real redis-cli and redis-benchmark can talk to it from chapter 4 on. It starts in 1969 with why C exists, then why Google made Go and why Mozilla made Rust, and builds the server one feature at a time, always in C first, then Go, then Rust: an echo server, the protocol parser, GET and SET, your own hash table, modules and packages, abstraction and generics, fifty clients at once on poll, kqueue and epoll, keys that expire, a clean shutdown on a signal, a log that survives a crash with its own fsync thread. Then it does what a working programmer must: tests, fuzzers and sanitizers, benchmarks and profilers, cross-compiling and static binaries, and calling C from the other two with the structs and unions that cross the border. Every chapter opens on a real scene at the terminal, teaches each language with an exercise whose full solution is folded underneath, recounts an incident you can reproduce, and closes with a scorecard that names a real weakness of each. The verdict gathers the 101 rows into one table and says when to choose C, Go, Rust, or none of them. Then an optional Part V takes the readers who chose Rust further, from first principles: in five chapters you build, inside kv, a reply that borrows instead of copying, a vtable, a future with its waker, executor and reactor, an Arc and a channel on atomics, a byte buffer on uninitialised memory, and a derive macro, and you check each one with miri and loom before you meet the library version. Every listing is pulled from code that is compiled and run against the same protocol tests on every change, with ThreadSanitizer on Linux. Read the three-language core in about seven and three-quarter hours and Part V in about an hour and a half, and keep the appendices: a rosetta cheat card, a glossary, and C, Go and Rust each in one chapter, every construct of the language in a sentence or two with a link to its reference. Press ⌘K to search, and 1, 2 or 3 to put your language first.
Read online