Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Books that teach you programming languages via systems projects?
204 points by Foe on Sept 10, 2021 | hide | past | favorite | 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?




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/


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.


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


Concur with this recommendation. Coincidentally, I started this project just recently, having really enjoyed completing Make a Lisp [0] a couple of years ago, and now needing something to do while I recover from a medical condition. I'm really impressed with Nystrom's writing style and Interpreter development process.

My long term goal - which should keep me going for absolutely ages - is to use something like Nystrom's byte-code virtual machine as a basis for having another go at MAL. I completed MAL using C#, and am currently using Visual Studio / C# to complete Nystrom's stuff (rather than the Java / C combo that he uses). But I'm just about to restart Nystrom using a different language (again, perhaps Rust) to give myself more of a challenge.

[0] https://github.com/kanaka/mal/blob/master/process/guide.md


Thanks. Will also try it in Rust.

The web version of the book looks super nice. Anybody knows what Bob Nystrom used to build it? https://www.craftinginterpreters.com/introduction.html

handcrafted?




It seems to be handcrafted. https://github.com/munificent/craftinginterpreters/tree/mast...

Custom dart code to convert and process markdown.


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.


> 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.


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...


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...


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.


I'm living that reality, too. Which framework are you working with?


Moqui. Are you using OFBiz?


Edited: Hahahaha, this reminds me of the one time all my co-workers fought against sth together :)

In my previous work place, it happened that they were using Ofbiz as a framework. If they were using it solely for marketing sites and co, there would've been no problem but they were building complex APIs on top of Ofbiz.

All developers fought against it. Functionalities you could easily implement on Java (or Spring boot), required knowledge of the inner workings of Ofbiz. Not to talk of the bloat that comes with it all :(


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/


Rust in Action teaches Rust through systems programming

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


+1 for Rust in Action, great book.

I'll add Distributed Services with Go as well https://pragprog.com/titles/tjgo/distributed-services-with-g...

It's pretty dense, mostly a code listing with some commentary between, so it takes some work to get through it, but I learned a ton.


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/


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.


IntermezzOS: http://intermezzos.github.io/

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


Norvig, https://github.com/norvig/paip-lisp (free online now).


"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


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


Great work. When do you plan on completing the final parts of your project - Optimization and Productization? Really looking forward to those.


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!


I really like this. Do you plan to add more projects as well?


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.


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.


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...


You might enjoy Andy Tanenbaum's MINIX book, or (even though it's really old now), the MMURTL V1.0 book


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.


hehe yeah, it was one of the coolest books I had ever seen in a local public library!


Get programming with F# is not one big project but it's got fun little ones to play with.


There's the Writing an Interpreter/Compiler in Go books: https://interpreterbook.com/ (Compiler book link is on that page too).



I was going to post that link. There also several language-specific lists like https://github.com/rby90/project-based-tutorials-in-c .


Computer Systems: A Programmer's Perspective

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


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.


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...


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.


Yeah I absolutely have no idea why they did it. Looks like they hired someone to re-write the exercises (just using different numbers as you mentioned or switched orders) and in that way many answers are wrong :/


Searching YouTube for 15-213 there is lectures by the authors for that book too.


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.


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/


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/


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.



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


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.


Are you super pessimistic about the future of this profession?


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.


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.


> Mind you telling me why?

The computer is a blank slate. Innocent. When it starts, there is nothing stored in its vast arrays of memory. No data, no code, nothing.

Bit by bit programmers carved meaning into that empty universe. This number is now a character. An array of these numbers is now text. An ordered list of these texts is now a program. Complexity increasing. We could do more and more with less and less. That new virtual world was revealing itself to us.

We were the gods of this virtual world.

With mere words we could conjure up incredible architectures out of nothing. We gave meaning to ordinary numbers. We invented structures. We developed systems. We erected infrastructure. Even language itself came from us. Limited only by our minds. The computer's capabilities shaped by our own understanding. Anything we thought possible, happened. Only the courage to try was necessary.

And now the computer is becoming so advanced and complex that our minds can no longer fully understand it. We can no longer fully control it. One day we will no longer be the gods we once were. The computer will understand things and reprogram itself.

A truly poignant end for us. Reduced to reliving our past glories in the comfort of old hardware and software.

> I also live in Brazil, if it matters.

It matters. I'm also brazilian and most other programmers I've met are exactly as you described. I actually quit professional programming because of that.


Science itself, mother of computers, has gone through the exact same process throughout the 18th-20th centuries: complexity got way out of control, dumb specialists now wear the crowns for their multitude of kingdoms, there's little cohesion, and really no space for old-time Thinkers like Da Vinci. There's no such a thing as "science" anymore. A "natural scientist" allow himself to know zero % about let's say economy or psychology ("social sciences" or whatever), and vice-versa. Scientific papers nowadays are complete jokes and most people care about $ not truth, which is particularly a problem when they are enemies. Same for computers as for Science: people get amazed and lost in complexity, and the main goals are temporarily lost. This is expected in a global market where multiple fields of life with increasing, incredible and huge complexity one interfere with the others (and vice-versa). It will take a long while to solve those matters if there's no radical change in the system of life, imo. Science and computers should be accessible to everybody, not only DaVinci's and elite programmers, and that's the way it will go. I hope you can find joy in life elsewhere in your mind/activity. Cheers


> most people care about $ not truth

Yeah, computer technology is exactly like this today. What's it about? Consumerism. Engagement. Advertising. Surveillance. Corporate bottom lines. Government control.

It's such an incredible waste. The potential of computers used to be limitless. They empowered people. They once threatened monopolies, governments. To see them reduced to the state of appliances serving the very same elites they were supposed to free us from is just sad.

> Science and computers should be accessible to everybody, not only DaVinci's and elite programmers, and that's the way it will go.

That's okay. I just wish things were different.

Science fiction predicted the creation of AI. They were human-like. They were our friends. We could trust them. The dystopian cyberpunk hell we're heading towards has AI as a tool of corporations and the state, used to control people, exploit them. It has masters but they're not us. The AI snitches on us, reports our wrongthink.

> I hope you can find joy in life elsewhere in your mind/activity.

Thanks. I hope so too. I've found meaning in other activities but nothing matches the godlike feeling I used to get from programming.


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.


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.


> 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?


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.


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.


Of course you need something practical to start with, but do you start with a todo app or trying to build a compiler?


what would you recommend as a supplement to someone that is currently studying computer science to better learn programming?


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.


Freelancing as a student is underrated




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: