[HN Gopher] The "Build Your Own Redis" Book Is Completed
       ___________________________________________________________________
        
       The "Build Your Own Redis" Book Is Completed
        
       Author : bubblehack3r
       Score  : 118 points
       Date   : 2023-01-29 20:18 UTC (2 hours ago)
        
 (HTM) web link (build-your-own.org)
 (TXT) w3m dump (build-your-own.org)
        
       | Jolter wrote:
       | While I applaud the initiative and effort, I want to urge the
       | author to consult a good proofreader. I'm only in chapter 2 yet
       | I've already encountered enough friction in the form of poor
       | English to put me off. I think the substance looks great, so it's
       | a bit wasteful to not walk the last mile and make it genuinely
       | enjoyable to read by eliminating blatant errors like this one:
       | 
       | "The Redis is an example of the server/client system."
        
         | m00dy wrote:
         | I would ask chatgpt to refactor his text rather than waiting
         | him to do so... I think poor english as an excuse will be a
         | thing of past.
        
         | aejnsn wrote:
         | I am absolutely with you. There's a certain large company I
         | work for who has public documentation full of stuff like this.
         | It makes me insane when I find it so glaring. There's an
         | internal program to proofread and review, but quantity is
         | incentivized, not quality. I've tried to shove that program in
         | a better direction to no avail.
        
       | suncherta wrote:
       | 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 from
       | toy prototype version to the production quality one.
        
         | DylanSp wrote:
         | 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.
        
           | suncherta wrote:
           | Yes, that's the one. Thank you.
        
           | lprd wrote:
           | Curious if anyone else has checked out their content yet? If
           | so, hows the quality?
        
             | pizza234 wrote:
             | 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.
        
       | eBombzor wrote:
       | > Here are some examples that meet my criteria of the "building
       | block": NGINX, SQLite, PostgreSQL, Kafka, Linux kernel, etc.
       | 
       | Kafka?
        
         | nkozyra wrote:
         | Given there's a focus on basic data structures it seems like a
         | good fit.
        
         | ibbtown wrote:
         | Probably MQ as example for a message bus was not OSS and hip
         | enough;)
        
         | Jolter wrote:
         | Why not? I'm curious as to why it wouldn't fit among those
         | others. Not used broadly enough?
        
       | viksit wrote:
       | 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).
        
         | thebamby wrote:
         | One of the top level comments recommends a tokio.rs tutorial.
         | See here: https://news.ycombinator.com/item?id=34573028
        
       | yazzku wrote:
       | A good read for sure, thank you. '4. Protocol Parsing', hand-
       | writing protocol parsers in C looks particularly thrilling.
        
         | theideaofcoffee wrote:
         | 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.
        
           | yazzku wrote:
           | 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
           | instructive and perhaps even more fun.
        
             | blagie wrote:
             | <-- This.
             | 
             | 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.
        
               | yazzku wrote:
               | 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.
        
         | 77pt77 wrote:
         | What could go wrong?
         | 
         | It's not like there are decades of paying the price of such
         | decisions...
        
           | yazzku wrote:
           | At a cursory glance, they assert((size_t)rv <= n), but if
           | that's the assert.h assert(), it's just void when NDEBUG is
           | defined, and cmake seems to define that when building a
           | Release target. Also, gcc does not seem to define it by
           | default. So that's a bit of an overflow there.
        
           | CyberDildonics wrote:
           | I think you're mixing up parsing a binary protocol with
           | parsing strings.
        
           | swatcoder wrote:
           | 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.
        
       | messe wrote:
       | Looks neat and relatively self contained. I'm adding this to my
       | list of projects to use to learn a new language. I might give it
       | a shot in Kotlin and Zig (I know it and use it, but am not as
       | familiar with its event loop implementation as I'd like to be)
       | over the next few weeks.
        
       | rickreynoldssf wrote:
       | That's something I wish I had time for.
        
       | varispeed wrote:
       | 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.
        
         | bilekas wrote:
         | 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.
        
       | tikkabhuna wrote:
       | Sorry for being a little off topic, but the Mini Redis tutorial
       | [1] was really fun when I did it a few years ago. It has you
       | implement a server and client in Rust using the Tokio library.
       | 
       | I think Redis is a great server to "build yourself" as you don't
       | need to start with much to get it going.
       | 
       | [1] https://tokio.rs/tokio/tutorial/setup
        
       | rcarmo wrote:
       | 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).
        
         | sillysaurusx wrote:
         | RESP3 is really nice too. It should probably be required
         | reading.
         | 
         | There's a lot of interesting / subtle design choices worth
         | studying.
        
       ___________________________________________________________________
       (page generated 2023-01-29 23:00 UTC)