Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Similar books to “Raytracing in one Weekend”?
150 points by augunrik on Dec 16, 2022 | hide | past | favorite | 27 comments
I really liked the "Raytracing in one Weekend" Series [0], in terms of: explaining a complicated concept by programming a toy implementation of the thing itself and afterwards one is left with more knowledge and something to "show".

Does someone know similar series on other subjects than raytracing? I know there is the Advent of Code, but that's more like solving a puzzle.

[0]: https://raytracing.github.io




I would recommend Crafting Interpreters (https://craftinginterpreters.com) or Interpreter Book (https://interpreterbook.com/). Excellent ways to learn how to build an interpreter. You have a functioning interpreter by the end of it, and it's easy enough to extend it into new concepts! I'm using some of the lessons learned from that to build a custom interpreter for a small project I'm working on. It's really fun!


I've been struggling to decide which one (of the two interpreter books you mentioned) to read. Any specific reason I should read one over the other?


I wrote "Crafting Interpreters" and read and very much enjoyed Thorsten's interpreters book. (I haven't gotten to his second one yet.)

They are surprisingly alike. Mine takes you through two complete implementations of the same language: first as a tree-walk interpreter and then as a bytecode compiler. His first book does the former and his second book does the latter.

Both are written in an informal friendly style and focus on working code. If you like one, you'll probably like the latter.

Mine uses Java for the first language and C for the second. Thorsten's books use Go for both. I think mine has more background information, theory, and historical context. His will get you to a working interpreter with less prose to wade through.

I think it's mostly a question of style and preference. I'd dip into the first chapter of each and see which resonates with you.


There seem to be many ripoffs on Amazon. Just a quick search yielded this:

https://www.amazon.de/Crafting-Interpreters-Paperback-BOB/dp...

https://www.amazon.de/Crafting-Interpreters-Tracy-Shep/dp/B0...

https://www.amazon.de/Crafting-Interpreters-Steven-Billups/d...

Have you already tried getting Amazon to remove them and failed?


These things pop up like whack-a-mole. I went ahead and reported them.

In general, customers seem to be pretty good at distinguishing garbage on Amazon from the real deal, and my actual listing has enough reviews that it clearly stannds out as the one they want.

Thanks for letting me know.


Personally I often go to Amazon to find things, google the author and check on the HP on how to buy the book with the least amount of "tax" for the author. Added benefit: you get formats outside of walled gardens!


Dubious about the value of these conceits, it may be imperfect, though autobiographies are not popular.


Nice review of Thorstens book. I read your book when I graduated college around 2018 and was unfulfilled at work. It was a lot of fun and I distinctly remember sitting in a coffee shop for hours reading through it and debugging my code.

Unsurprisingly my family asked what I wanted for Christmas and I put both your book and Thorstens on my list to reread .


There is a sense of premium quality from your books, so I bought em. You haven’t let me down!

I have been curious. Why the choice of java as introductory level?

Maybe I’ve been lucky to choose my own tools over the years. But I still get hung up on this. It’s just that Java is so longform.

I’m not sure I ever really wrote a sort in it, without cheating. Besides showing off that I could, I probably installed groovy or later scala, mostly.

So heh. I had a pleasant headfake in “Crafting Interpreters” when it was revealed that the JVM machinery wasn’t going to get anyone the full distance.

Java just feels backwards, as the low-level code is simpler and smaller. Why is Java still seen as more accessible than [anything else]?

Is OOPs curriculum still that prevalent?

Or. Pointers? Pointers took me a long time, even after I got them. Is it pointers?


> Why the choice of java as introductory level?

It was a hard choice. I wanted a language that was:

1. Fairly high level with garbage colleciton so users didn't have to worry about pointers and stuff while they were trying to learn basic concepts.

2. Object-oriented, since that's familiar territory for many programmers and because I wanted to show some techniques around working with programming languages in an object-oriented language, like the visitor pattern.

3. Widely known and not mostly confined to a single platform or domain.

4. Statically typed, since I think it makes it much easier to see what types are flowing through the code when it's on paper and you don't have a debugger to help you.

There isn't much in the intersection of that set. Functional languages like SML and Haskell are great for writing compilers and interpreters, but now readers have to learn two things at the same time. C++ is a reasonable widely known typed OOP language, but is a nightmare of complexity. JavaScript is a good OOP linqua franca but the lack of types is a drag. TypeScript is maybe a good choice, but it's type system is so complex and JavaScript has so much weird baggage that I didn't want to go there. C#, Swift, and Kotlin are all nice languages but hew mostly to specific platforms.

Java was the least bad lingua franca I could find. I also don't mind it as a language.

> It’s just that Java is so longform.

My experience is that Java isn't particularly verbose as long as you don't program in a 90's Enterprise Java style.

> as the low-level code is simpler and smaller.

The C bytecode VM is quite compact, but it is so because it deliberately discards a bunch of things like an AST, simple environment representation, or separate resolution pass. It is designed to be implemented in C.

But I also want to teach users those other concepts. If I'd written the tree-walk interpreter that you do first also in C, it would end up a huge sprawling C program. Just dealing with allocating and freeing the AST nodes at the right time would have been miserable.

Not to mention, it means you would have to implement a garbage collector very early on since Lox relies on it but C doesn't have it.


Well! My curiosity is satisfied. I’m not ivory-towered enough to think of Haskell for this, but may be somewhat biased in a snake case direction.

I like it, you called my cohort out on being jaded by the developer experience of J2EE. I will revisit that outdated bias.


I've bought and read both, but the one I used for my interpreter was Interpreter Book by Thorsten Ball, because it's written in Go and Go is currently my favorite language. They both work well, though!


This is a fantastic list of projects. From 3D renderers, blockchain protocols, frameworks to emulators.

"Build your own X" - "This repository is a compilation of well-written, step-by-step guides for re-creating our favorite technologies from scratch." [0]

[0] https://github.com/codecrafters-io/build-your-own-x


Game Physics in One Weekend [0], Ten Minute Physics [1]

[0]: https://gamephysicsweekend.github.io/

[1]: https://matthias-research.github.io/pages/tenMinutePhysics/


The "From Nand to Tetris" course or in book form "The Elements of Computing Systems". This steps through building a computer from scratch. Starting with building logic gates from transistors, through to building a CPU and then writing assembly.


FWIW this book is great. It took me a couple months of immense dedication to finish everything from the first course.


Fluid Simulation for Computer Graphics by Robert Bridson [0] is one of my favorites. It’s a very approachable introduction to fluid mechanics pdes, and how to code wonderful fluid simulations like this HN favorite [1].

[0]: https://www.cs.ubc.ca/~rbridson/fluidsimulation/

[1]: https://paveldogreat.github.io/WebGL-Fluid-Simulation/


Common Lisp: A Gentle Introduction has you code a bunch of neat little projects, I'm especially fond of the substitution cypher solving program. It reminds me of Covert Action.


ty for the recommendation; for those interested in reading it here's a PDF version of it (via the author's website).

https://www.cs.cmu.edu/~dst/LispBook/book.pdf


My curated and update list of Computer Graphics resources you can read online for free [0] with every item having a small description.

[0]: https://legends2k.github.io/note/cg_resources/


Check out Crafting Interpreters[0]. You learn about Chomsky formal language hierarchy, constructing context-free grammars, lexing, parsing, error reporting, etc by building your own programming language.

[0]: https://craftinginterpreters.com/


self plug: I wanted to learn how databases work internally, like how they store and retrieve data, build indexes, etc.

I built an educational KV store to teach someone to write a database from scratch. I have set up this project in TDD fashion with the tests. So, you start with simple functions, pass the tests, and the difficulty level goes up. There are hints if you get stuck. When all the tests pass, you would have written a persistent key-value store in the end.

link: https://github.com/avinassh/py-caskdb


500 lines or less and the rest of Architecture of Open Source Applications series http://www.aosabook.org/en/


Generative Design by Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni

It's about 2D programmatic raster graphics.


Thanks for all your links! I haven't decided on what to next :D


What about now?


The Sam's Teach Yourself in 24 hours is a series of computing-related books:

https://www.pearson.com/us/higher-education/series/Sams-Teac...




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

Search: