Live data from Hacker News

The “Build Your Own Redis” Book Is Completed

build-your-own.org

21–30 of 131 posts

Re: The “Build Your Own Redis” Book Is Completed

#21
One of my pet peeves when I was learning programming is that I couldn't find any books that would teach how to write tests in real world.

There was that chicken and egg problem then, when potential employers would skip my CV because I didn't have any TDD experience and I couldn't find anywhere how to learn this.

Before I even learned that something like testing exist, I was so confident like "oh I could write something like that over the weekend, how come they needed months to do that?". Then my software would crash the first time someone other than me used it.

Anyway - what I want to say that while this book sounds like a great idea, without showing TDD and how to write code so that it can be proven it works the way intended and that it can handle unhappy paths and edge cases, it won't teach someone trying to learn programming much and it doesn't actually stand over about million other books about programming that really just scratch the surface and don't show how to write production ready code.

That's what is still missing on the market. It's almost like a well kept secret that only developers working at large corporations know.

That skill was very very difficult to acquire.

Re: The “Build Your Own Redis” Book Is Completed

#22
post #17

Earlier quoted context omitted.

The redis wire protocol is simple enough where it's not very difficult. It's instructive to write it in C because there's a lot of translatable knowledge to other languages: read in a buffer, cast that buffer to the protocol-specific struct, read the various fields from memory, etc. Basic operations for a systems-level project like this.

It's simple enough, and yet: https://nvd.nist.gov/vuln/detail/CVE-2021-32675 https://nvd.nist.gov/vuln/detail/CVE-2021-41099 https://nvd.nist.gov/vuln/detail/CVE-2021-32761 I agree it's instructive, but on the other hand, the time might be right to start teaching why not to do this stuff. Modeling a protocol parser in a high-level language that can spit up correct and highly-optimized C code would be just as instruct…

Yes, "read in a buffer, cast that buffer to the protocol-specific struct, read the various fields from memory, etc" are all operations one should generally NOT do. This was instructive maybe three decades ago, when the internet was relatively safe.

Knowing how to do this RIGHT is important.

The place this is still helpful is low-level programming, and embedded is a far better place to learn. If one part of your microwave is talking to a sensor, security isn't really an issue, since you control both ends.

Re: The “Build Your Own Redis” Book Is Completed

#23
post #11
post #8

A good read for sure, thank you. '4. Protocol Parsing', hand-writing protocol parsers in C looks particularly thrilling.

What could go wrong? It's not like there are decades of paying the price of such decisions...

I think you're mixing up parsing a binary protocol with parsing strings.

Re: The “Build Your Own Redis” Book Is Completed

#24
post #22
post #17

Earlier quoted context omitted.

It's simple enough, and yet: https://nvd.nist.gov/vuln/detail/CVE-2021-32675 https://nvd.nist.gov/vuln/detail/CVE-2021-41099 https://nvd.nist.gov/vuln/detail/CVE-2021-32761 I agree it's instructive, but on the other hand, the time might be right to start teaching why not to do this stuff. Modeling a protocol parser in a high-level language that can spit up correct and highly-optimized C code would be just as instruct…

Yes, "read in a buffer, cast that buffer to the protocol-specific struct, read the various fields from memory, etc" are all operations one should generally NOT do. This was instructive maybe three decades ago, when the internet was relatively safe. Knowing how to do this RIGHT is important. The place this is still helpful is low-level programming, and embedded is a far better place to learn. If one part of your micro…

Yeah, and I said the above being myself a big fan of C. I write C in my hobby projects. Yet if I were doing anything non-trivial that talks over the network, that protocol parsing would for sure not be hand-written.

Re: The “Build Your Own Redis” Book Is Completed

#25
post #11
post #8

A good read for sure, thank you. '4. Protocol Parsing', hand-writing protocol parsers in C looks particularly thrilling.

What could go wrong? It's not like there are decades of paying the price of such decisions...

You don't have to learn raw systems coding yourself, but if nobody bothers, the code of 2050 is going to be built on a lot of stale, brittle magic that nobody can reproduce or understand.

This is exactly the sort of playground effort where those who do want to learn can get their hands dirty. If this is their first time doing this kind of project, they shouldn't use any of this code in production. There will be all sorts of cheated corners and vulnerabilities, and not just in obvious high-risk places like this. That's how hands-on learning goes.

Re: The “Build Your Own Redis” Book Is Completed

#26
I actually build minimal Redis clones in every new language or runtime, or when I want to explore threading models.

It all started with https://github.com/rcarmo/miniredis (which I forked to add and experiment with pub/sub), and I just found myself doing it again and again because Redis is the quintessential network service:

By implementing it, you learn about socket handling, event loop for a specific runtime, threading models, data representation, concurrency (if you want to do a multi-threaded version), etc. None of my "ports" are fully functional, but they all helped me sort out some of the above plus build tools, packaging, dependencies, etc.

It's "hello world" for core cloud native microservices, if you will (and without having to do REST or JSON stuff).

Re: The “Build Your Own Redis” Book Is Completed

#27
post #7

i love this! is there a book like this to learn rust with? it would be amazing to have a working system at the end. (not looking for a beginner, but say, intermediate level book).

One of the top level comments recommends a tokio.rs tutorial. See here: https://news.ycombinator.com/item?id=34573028

Re: The “Build Your Own Redis” Book Is Completed

#28

One of my pet peeves when I was learning programming is that I couldn't find any books that would teach how to write tests in real world. There was that chicken and egg problem then, when potential employers would skip my CV because I didn't have any TDD experience and I couldn't find anywhere how to learn this. Before I even learned that something like testing exist, I was so confident like "oh I could write somethi…

While i have so many things i could say about your idea of what development means and the "only path" you seem to subscribe to. I think you're missing the point of the book.

> it won't teach someone trying to learn programming much and it doesn't actually stand over about million other books about programming that really just scratch the surface and don't show how to write production ready code.

It's not a book to teach people how to program, infact the author goes out of their way to mention only C and minor c++ has been used and that it may be beneficial for learning how to build out such a POC of redis, to DIY your own.

This is not a book to hand over to an outsourcing company and expect production ready work. Nor was it described as such.

Re: The “Build Your Own Redis” Book Is Completed

#29
post #20
post #15

Earlier quoted context omitted.

You're probably thinking of https://codecrafters.io/ . I've been meaning to check them out with my education stipend from work, just haven't had the time to devote to it.

Curious if anyone else has checked out their content yet? If so, hows the quality?

The idea is very good - the tests approach is effective and stimulating; they also provide a range of products to study/experiment with. However, I think that the approach to the learning material is "love it or hate it".

By design, the service doesn't provide any documentation; it provides references to existing technical documentation (of any kind, including blog posts).

Those who expect a focused introduction to each topic will find it very tedious or hard to proceed (for example, the SQLite exercise has important details buried in a very large and confusing webpage), and likely hate it; those who like the challenge of understanding loads of raw documentation will love it.

Re: The “Build Your Own Redis” Book Is Completed

#30
post #15

I am very happy to see more content like this (attempting to teach how to create a real system) becoming available. Few month ago there was a launch announcement of YC backed startup that sell you walk-through labs guiding you to build Redis, Docker, Git and others. (Can't find link to it now.) What is still missing, in my opinion, and is badly needed, is content or even an idea on how to teach taking such projects f…

You're probably thinking of https://codecrafters.io/ . I've been meaning to check them out with my education stipend from work, just haven't had the time to devote to it.

Yes, that's the one. Thank you.
Post reply on HN