01. Introduction

Network Programming and Data Structures

Explore the 2 topics in a learn-by-doing way by coding a Redis clone step-by-step.

Many software components reply on computer networks. Think of HTTP servers, RPCs, databases, and etc. Network programming is essential to building these system-y software.

Data structure is overlooked in application development. Due to the lack of practical examples, many don’t know more than what a hashtable is. Code a Redis is the perfect exercise to fills this gap.

Why Start From Scratch?

To quote Feynman: “What I cannot create, I do not understand”. There are different levels of “create” and “understand”. Welding libraries and frameworks together is the most common way to create software, but it requires the least understanding. You don’t have to stay at this level.

Learning from scratch means starting with the fundamentals, not the minor details – a wise use of time.

Why C?

The first version of Redis was written using the TCL scripting language. But Redis the product is written in C, and Redis in TCL is a toy. Why is so many serious software written in C? Can I follow this exercise in a high-level language like Python or JS?

  • Many system software is very low-level. C is the best way to get started with low-level projects; you need to master it anyway.
  • Using a high-level language is not “from scratch”; some important lessons are skipped because you got data structures for free.

Why Should I Code A Redis?

  • It prepares you for more technical, system-y works. Not every job is about CRUD apps, and generic software development is devalued by AI tools.
  • Knowing how things work makes you stand out because you become good at debugging and making technical decisions.
  • It reinforces your knowledge with practice, especially if you are a student without real projects.
  • It’s a quick review of the basics, which is helpful for job interviews. Although what you’ll learn is overkill for interviews.
  • It’s fun and intellectually stimulating. You’ll discover what you don’t know you don’t know.

About The Book

Each chapter is an incremental step with complete source code which can be downloaded, but you’ll expected to do it yourself.

The final product is only 1200 lines of code. The code is small, but it includes many important lessons while skipping uninteresting details. Many things are simplified or done differently to better illustrate the topics. For this reason, the result is not compatible with the real Redis.

The code is plain C with minimal C++ features. Don’t worry if you don’t know C. C is small enough to get started quickly with Beej’s Guide to C.

Book Series

This is part of the “Build Your Own X” book series, where X includes database, web server and compiler. Read the web version on the website.

https://build-your-own.org