Ask HN: Books that teach you programming languages via systems projects?

204 points by Foe 3 years ago | 66 comments
Looking for a book/textbook that teaches you a programming language through systems (or vice versa). For example, a book that teaches modern C++ by showing you how to program a compiler; a book that teaches operating systems and the language of choice in the book is Rust; a book that teaches database internals through Golang; etc. Basically, looking for a fun project-based book that I can walk through and spend my free time working through.

Any recommendations?

  • mprovost 3 years ago
    I'm publishing a book doing exactly this, rewriting one Unix utility per chapter from the BSD C version into Rust. The first two chapters for true/false and yes are published, with head, wc, cat, cut, rev, and uniq coming soon as I finish editing and typesetting each.

    https://rftgu.rs/

    • b3morales 3 years ago
      Added to my to-check-out list! Thank you for providing such a robust sample to download (it looks like a whole chapter); that's a really nice touch.
    • tompark 3 years ago
      It's possible to work through Bob Nystrom's Crafting Interpreters[1] using any language you want. On GitHub just search for "crafting interpreters"[2] and add a filter for the programming language you're interested in, and you'll find at least a couple repos for the entire book. There are over a dozen complete repos in Rust. Since everyone breaks out each chapter in a separate folder, it's easy to follow along with the book, even though the book's first interpreter is written in Java and the second compiler was written in C. I did this, it's basically how I learned Rust.

      [1] https://www.craftinginterpreters.com [2] https://github.com/search?q=crafting+interpreters

    • RapperWhoMadeIt 3 years ago
      I am obsessed with "The Linux Programming Interface" by Michael Kerrisk. I highly recommend this book if you want to level up your C programming skills and knowledge of Unix operating systems (specially portability and Linux). It might not exactly fit your description, but I still would recommend it. I feel like my C skills have gone from medium to pro, since reading most of the book. One really gets a good grasp of what syscalls exist, what they do and how to properly use them to produce secure and portable code. It is not written following a single project, but there are many different "applications" in the different chapters, for example, at the end you will be able to program a stand-alone back end TCP server with the examples from the book.
      • matheusmoreira 3 years ago
        > One really gets a good grasp of what syscalls exist, what they do and how to properly use them to produce secure and portable code.

        Yes! The book really exposes all that hidden fun stuff that the system libraries abstract away from us. When I was a beginner I hated not understanding how they worked.

        On Linux it's also theoretically possible to make system calls from any language. The binary interface is stable and really simple. Wish more languages had compiler support for this calling convention.

      • adamgordonbell 3 years ago
        The Ray Tracer Challenge[0] is super fun and language agnostic. It might be a good second project when learning a language. He also has a book about mazes that is great but ruby specific. Though you could adapt it to another language.

        The thing I like about the books is the emphasis on having fun. My understanding is Jamis used these projects to overcome career burnout. They are also good for exploring the basics of a new language though.

        I interviewed Jamis about this subject and burn out[1].

        [0]: http://raytracerchallenge.com/

        [1]: https://corecursive.com/025-burn-out-and-recreational-progra...

        • thrower123 3 years ago
          The Maze book is really good. Definitely recommend.

          One thing that I've found helpful often when learning a new language is taking some code written in a language I know already and porting it over into the new language. That's more fun with a project that actually does something interesting, and if you've got the original-language version running, you can compare output.

          Peter Shirley's Ray Tracing in One Weekend book (and sequels) are also fun little projects

          https://raytracing.github.io/books/RayTracingInOneWeekend.ht...

          • destring 3 years ago
            Thanks for this. I'm seriously burntout due to using a very niche ERP framework that leaves no room for personal growth, this is exactly what I needed.
            • crftr 3 years ago
              I'm living that reality, too. Which framework are you working with?
              • destring 3 years ago
                Moqui. Are you using OFBiz?
          • westurner 3 years ago
            From "Ask HN: What are some books where the reader learns by building projects?" https://news.ycombinator.com/item?id=26042447 :

            > "Agile Web Development with Rails [6]" (2020) teaches TDD and agile in conjunction with a DRY, CoC, RAD web application framework: https://g.co/kgs/GNqnWV

            And:

            > "ugit – Learn Git Internals by Building Git in Python" https://www.leshenko.net/p/ugit/

            • yarinr 3 years ago
              Rust in Action teaches Rust through systems programming

              https://www.manning.com/books/rust-in-action

            • eru 3 years ago
              See "Write Yourself a Scheme in 48 Hours" https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_... and "Write You A Haskell" http://dev.stephendiehl.com/fun/
              • jodersky 3 years ago
                Hands-on Scala Programming (https://www.handsonscala.com/) is a great way to learn Scala. It's down-to-earth, project-based and focuses on the practical side of the language.
                • faraaz98 3 years ago
                  IntermezzOS: http://intermezzos.github.io/

                  Phillip Opperman's Blog OS: https://os.phil-opp.com/

                  • abecedarius 3 years ago
                    Norvig, https://github.com/norvig/paip-lisp (free online now).
                    • rkangel 3 years ago
                      "Designing Elixir Systems with OTP" is a great book.

                      It's not intending to teach you the basics of the language, it is instead teaching you how to architect real world programs, using a particular case study that they work through (a quiz game). It's basically about the 'functional core, OTP boundaries' model that is an excellent approach for building real systems.

                      If you don't know Elixir at all the Getting Started guide is good for teaching the language constructs: https://elixir-lang.org/getting-started/introduction.html

                      • cppwithprojects 3 years ago
                        For C++, we've built Learn C++ Through Projects [0], which is a project-based C++ course.

                        We currently offer only one project to build a transport network monitor. It starts with some low-level topics (we use WebSockets to handle tens of thousands of network events) but a lot of code is also higher-level (we use the network events to create a routing engine) - so it may not be exactly a "systems programming" resource!

                        [0] https://learncppthroughprojects.com

                        • jaguar86 3 years ago
                          Great work. When do you plan on completing the final parts of your project - Optimization and Productization? Really looking forward to those.
                          • cppwithprojects 3 years ago
                            Thank you! We are going to release the Optimization section this week and the Productization one soon afterwards. In the meantime, we had to update a lot of the content around WebSockets based on user feedback - you'll receive an email soon!
                          • bogomipz 3 years ago
                            I really like this. Do you plan to add more projects as well?
                            • cppwithprojects 3 years ago
                              We do! We have been working on new content more slowly than we hoped, though... Our fist project received a lot of attention and we want to make sure we can support all existing developers first.
                          • e19293001 3 years ago
                            Books by Anthony J. Dos Reis

                            Those are so much underrated books that thought me how to become a software engineer. I hightly recommend especially these books.

                            Assembly Language and Computer Architecture Using C++ and Java

                            Compiler Construction Using Java, JavaCC, and Yacc

                            I promise! You'll obtain tons of skills from his books. I'm very debted to this man. I enjoyed a lot reading his books and made me who I am today.

                            • kaycebasques 3 years ago
                              I never worked through this, and it may be outdated now, but Let's build a browser engine! seems to fit the bill: https://limpet.net/mbrubeck/2014/08/08/toy-layout-engine-1.h...
                              • alfiedotwtf 3 years ago
                                You might enjoy Andy Tanenbaum's MINIX book, or (even though it's really old now), the MMURTL V1.0 book
                                • blahdeblah123 3 years ago
                                  MMURTL - now there's a blast from the past!! I learned a lot from that book (by Richard Burgess IIRC) and playing around with the code was fun. Mostly 386 assembler and some C from what I remember. Yes, the Minix book is also good.
                                  • alfiedotwtf 3 years ago
                                    hehe yeah, it was one of the coolest books I had ever seen in a local public library!
                                • xupybd 3 years ago
                                  Get programming with F# is not one big project but it's got fun little ones to play with.
                                  • wishinghand 3 years ago
                                    There's the Writing an Interpreter/Compiler in Go books: https://interpreterbook.com/ (Compiler book link is on that page too).
                                    • fybs 3 years ago
                                    • easytiger 3 years ago
                                      Computer Systems: A Programmer's Perspective

                                      by Randal E. Bryant (Author), David R. O'Hallaron (Author)

                                      • mathieubordere 3 years ago
                                        I can highly recommend this, on the following site you can find the labs accompanying the book http://csapp.cs.cmu.edu/3e/labs.html

                                        remark: DON'T buy the Global Edition of the book, it contains different exercises than the original book and is riddled with errors, it's basically unreadable/unusable.

                                        • markus_zhang 3 years ago
                                          Second this, don't buy global edition. The authors explicitly mentioned that they are NOT going to release an errata for it. Probably because it would be a book of itself...
                                          • vymague 3 years ago
                                            I always find the whole thing ridiculous. They literally just needed to copy-paste the original book. In their effort to discourage people from buying the international edition, they scrambled the exercises and their numbers. And introduced errors that way.
                                          • hackermailman 3 years ago
                                            Searching YouTube for 15-213 there is lectures by the authors for that book too.
                                        • simonebrunozzi 3 years ago
                                          Great thread so far.

                                          Anything specific for Python, and recent enough to be based on the latest Python (3.9.5, or at least 3.x)?

                                          I remember (but can't find it, sorry) a great "learn by example" web tutorial, but based on Python 2.x, and possibly at least 6-7 years old by now.

                                          • cameron_b 3 years ago
                                            Learn Python the Hard Way, [0]

                                            It isn't the most grand systems approach, but does build a text dungeon crawler and then makes it a web application.

                                            [0] https://learnpythonthehardway.org/python3/

                                            • ctippett 3 years ago
                                              I can highly recommend Test-Driven Development with Python[0]. The book has you build and deploy a web application, with emphasis on writing tests at each stage of development. The author has a great sense of humour and the whole book is a fun read-through.

                                              [0] https://www.obeythetestinggoat.com/

                                              • markus_zhang 3 years ago
                                                There is a book called "Black Hat Python". The second edition targets Python 3 and because of the nature of the topic is mostly lower level programming.
                                              • croh 3 years ago
                                                • neophyt3 3 years ago
                                                  my 2 cents... A single book wont teach everything, there will be missing holes, its better to have 2 monitors, open some small libraries in one monitor and go to first commit and start typing that and also understand it and gradually move to next commit... do it for 3-4 prjects and then u r set
                                                  • shomyo 3 years ago
                                                    Understanding Unix/Linux Programming by Bruce Molay. Not cpp though
                                                    • qualudeheart 3 years ago
                                                      Just ask openAI codex or github copilot.

                                                      It’ll all be natural language interfaces based on neural networks like that.

                                                      I wish things were otherwise but I can’t in good faith recommend someone learn “to code” or learn any programming language anymore.

                                                      • methusala8 3 years ago
                                                        Are you super pessimistic about the future of this profession?
                                                        • qualudeheart 3 years ago
                                                          Yeah. It’ll probably morph into something between a trade and a secretary tier position, where you receive orders from a business analyst, expand on then and feed them into a language model which does the actual programming. Right after that the business analyst does that too and finally their job is also automated.

                                                          I expect this to destroy the “gig economy” of freelancers too, but only after existing programmers are forced out of normal employment and into “freelancing” with drastically reduced negotation power and workplace protections.

                                                          All the technical depth and fun is going to be removed unless you’re one of the very few most elite human programmers.

                                                          It breaks my heart seeing this happen but I can’t do anything about it. My advice to everyone is to grift their way into a startup, get as much equity as you can, sell it and retire early. With UBI coming in 10 or 20 years it shouldn’t be too hard.

                                                          • gverrilla 3 years ago
                                                            I'm a business guy, but I have also coded a few mvp's including a deep and complicated algorithm in Python. In my social and professional surrounding I'm considered a tech expert, but I'm very well aware I'm not even near that, and consider myself an amateur - particularly here on HN. What you are describing seems like a dream to me, a good one, but it's obvious you think otherwise. Mind you telling me why? In my experience I have never worked with passionate programmers, they all see it as a job to get done and if you want intelligence and depth that's on you. I don't have such a vast experience hiring or working with professional programmers, but I have some and it has been consistent in what I'm telling you. Most of them were assembly-line style programmers, specializing in one or two things (meaning they learn how to replicate the work needed). And I would have a really hard time if I needed elite programmers for these tasks, and also no money to pay for it. The way I see it, making all the programming easy should be a net benefit for (almost) everybody, particularly in a stage when it gets so complicated to do simple stuff like making a website. To be honest, I've been around a lot and I have never really met an elite programmer irl. I have met a lot of dedicated and smart people, yes, and also good hackers, but not really passionate experts. I also live in Brazil, if it matters.
                                                            • qualudeheart 3 years ago
                                                              Added context: this is a very pessimistic projection, and when it comes true will depend how long the trend in neural network scaling continues.

                                                              Most leading ML researchers expect it to continue for a few more orders of magnitude of model size, which I think is enough for my prediction to come true.

                                                        • eurasiantiger 3 years ago
                                                          This seems like a terrible idea unless you specifically want to learn how to program specific kinds of things on specific languages.

                                                          That said, I can see how this could be useful to someone who is already well versed in programming and computer science, and has other types of project experience—they have a solid foundation to build and reflect on.

                                                          • eru 3 years ago
                                                            > This seems like a terrible idea unless you specifically want to learn how to program specific kinds of things on specific languages.

                                                            Many people learn from specifics and generalise later.

                                                            Do you think there's anything wrong with that?

                                                            • eurasiantiger 3 years ago
                                                              I think there is a high chance that once they learn to use a middle-handed hammer, too many things look like middle-handed nails.
                                                              • convolvatron 3 years ago
                                                                is there another option? I personally would probably never have taken up programming at all if I had to sit through a year of high level concepts before I tried to apply a compiler to some source code.
                                                            • HeJAnQuer 3 years ago
                                                              what would you recommend as a supplement to someone that is currently studying computer science to better learn programming?
                                                              • eurasiantiger 3 years ago
                                                                Actual project work solving actual clients’ problems in an area that matches your probable future employment. Consider doing something for free (without deadlines) just for experience.

                                                                Client problems are typically very different from exercises in compiler or rendering architecture, or whatever, unless you happen to be striving for those exact niches, which just might be a pipe dream unless you’re spectacularly talented in abstract problem solving in low-level languages on multiple hardware platforms and capable of furthering those technical niches in some way that someone benefits from enough to keep employing you.

                                                                • sayonaraman 3 years ago
                                                                  Freelancing as a student is underrated