Redis in Rust: The Beginning
Redis in Rust: The Beginning
I've always liked reading programming stories where the author describes what they've learned implementing something difficult. The struggle, the dead ends they hit, and of course the original—and thought-to-be-original—ideas that came to life during development.
One such difficult project is implementing a subset of Redis, the in-memory database. That's what I'm doing. See the GitHub repo.
Why would you do that?
Insanity, naturally. Redis already exists and mine isn't going to be better than that. However, it's an excellent opportunity for me to learn about:
- Rust
- systems programming concepts
- networking
- caching
- concurrency
- advanced data structures & algorithms
- performance-aware programming
- distributed systems (if I ever reach that far into the project)
I love computers. It's just fun to work on them in my spare time. This project is closer to the operating system than what I normally do in my day-to-day job.
I do a lot of agentic coding at work. If you aren't writing code, your ability to think in code diminishes. Thinking in code doesn't mean you're losing the big picture, the architecture, the vision for the product. It grounds you in what's possible, so that you can make your product better. It'll give you the ability to spot something obviously wrong, like using React for your TUI.1
By only reviewing programs and not writing them, you are slowly losing the ability to do both.
Approach, strategy
CodeCrafters2 provides the base framework I'm starting from. They provide the milestones and inform me about the unknown unknowns I should research. They aren't a tutorial site, there's no hand-holding.
Use of AI
I will not use AI to write the code parts that actually matter. Not for the first time at least. I'm going to struggle for a while on a problem, come up with a solution, likely rewrite it once, then do an AI code-review. Since I don't have deep Rust experience, feedback from it is welcome. I will also use AI to write tests for me after I've established a pattern.
The ordering is really important. It's easy to prompt for a solution and then think "Oh yeah, I would have done it like this", confusing familiarity with knowledge. It comes up most during school years. You open your notebook, scan the page, recognize every sentence and concept, so you think you know the subject. Then when you have to talk about it, or do an exam on it, your mind seems blank. What happened? You didn't exercise your mind, took the easy route and the results followed suit.
...rewriting an essay using AI tools (after prior AI-free writing) engaged more extensive brain network interactions. In contrast, the LLM-to-Brain group, being exposed to LLM use prior, demonstrated less coordinated neural effort in most bands...
Goal
I allow myself to wander. I'm here to learn. Being too strict would pressure me to produce visible progress in favor of complete understanding. This too is a learning experience in itself, deciding when to focus up and do the work, and when to let loose.
I will implement the basic commands, like PING, ECHO, SET, GET, RPUSH, LPUSH, RPOP, LPOP, in a way that wouldn't be insane to use in production.
That's the goal. When I reach it, I'll figure out the next one.
I have some thoughts on hosting it publicly, but first I'll have to make something before I let the internet ruin it.
Thanks!
It's incredible that you've reached this far. Hope you liked it and I sincerely thank you for taking the time.