One of the best ways for people to learn how to code, or to do just about anything really, is by doing projects. I’ll often direct people to tutorials & books that walk through a project for a specific domain, and doing that is exactly how I did & still do learn new things.

The problem with this method is it’s pretty easy to fall into the trap of just copy-pasting code from the book into your editor and forgetting to actually think about just what the hell is going on.

Forbidding yourself from pressing Ctrl+C does help a bit, but not that much.

Thankfully, there’s a simple solution for this: follow a tutorial that isn’t complete.

This is how I learnt enough about interpreters to make ocrlang, and it’s something I’ve been trying to do as much as possible since. When the tutorial doesn’t quite cover every little step, it’s essentially impossible to go into autopilot & start Ctrl+C-Ctrl+Ving everything you need.

When following this tutorial to make ocrlang, I had no choice but to understand what was going on and why because I always had to implement something extra that wasn’t literally covered in the tutorial. It gave me all of the background knowledge & examples I needed in order to put it into action to build something myself. In practice, I would complete a section (e.g. the lexer) and then think

What else will I need here for my specific case?

…and then I would implement it! I added extra keywords to the lexer, parsed them properly myself in the parser, added representations to the AST, and wrote proper interpreter code for everything extra I had to do. And it worked.

The specific tutorial I used is actually properly incomplete, in that it doesn’t contain an interpreter, so I also had to now find my own way of implementing that part. I could have just hopped to a different tutorial, but by that point I felt confident enough that I could wing the rest and have it all work out fine - and I was right! Because I had been following along consciously I actually understood how the program I had written worked, so I was able to extend it correctly!

This is also why I think you should always at least try the exercises in a book. That’s the author explicitly handing over control and saying

Ok, so you read this far. If you really understand it, then this should be doable for you.

Of course, it doesn’t have to literally be an unfinished tutorial. It just has to not cover absolutely everything in your project - so try to either come up with ways you can extend it, or (even better) go in with a concrete idea already in mind that the tutorial will help you lay the foundations for.

Another strategy that can be helpful is to follow the tutorial in a different language to the one it uses. If you have to translate the code you’re given, then it’ll almost certainly force you to think about what you’re actually learning. Bonus points if you attempt to write it idiomatically in your target language rather than simply porting it (almost) word-for-word - you’ll probably end up learning even more this way about both languages whenever your implementation diverges & you have to figure out what you did wrong.

To put it more succinctly: if you want to learn anything, use your brain and think about what you’re doing

And for the love of god, don’t just rely on an LLM. If you want a conversation, then talk to someone. Someone real.