Why every developer needs to read Algorithms to Live By
This is one of my favourite books. Written by Brian Christian and Tom Griffiths, Algorithms to Live By takes the smartest ideas from computer science and applies them to real life. And no it’s not just for computer nerds, it's for anyone who want to make the most optimal decisions in everyday life without overthinking. So whether you're a developer, a student or even a vibecoder (lol) this book has got you covered.
Balancing Comfort and Adventure
“Life is a balance between novelty and tradition, between the latest and the greatest, between taking risks and savouring what we know and love”
This book talks about the Explore/Exploit tradeoff which is basically the decision of whether to stick with what you know works or trying something new.
Picture this: you're at a restaurant, menu in hand, faced with a classic dilemma. Do you go for your go-to favourite dish or take a leap and try something new?
This is where the regret minimisation framework can help you. It's all about considering potential regrets down the line. Imagine yourself in the future and ask, "Will I regret not trying that new dish or talking to that cute girl?" By weighing the potential outcomes and aiming to minimise regrets you'll make choices that are the perfect balance of sticking with what you know and embracing new experiences.
The magic of 37
Another useful concept in the book is the "optimal stopping" problem. This is the question of when to stop looking for something and settle for what you've found.
Think of it like searching for that perfect youtube video to watch while having dinner. You see something decent but still keep scrolling in the hope that something better will turn up. But at some point you just have to accept that this is as good as it's going to get.
But fret not my friends here's the good news: you don't have to leave it to chance. Enter the 37% rule.
So you ask wtf is the 37% rule while your dinner’s still getting cold? It's a strategy that says you should spend the first 37% of your search just exploring without committing and then choose the next option that's better than anything you've seen so far.
When deciding what to watch, first set how long you’re willing to search. Spend the first 37% of that time just exploring options. After that pick the next video that’s better than anything you’ve seen so far. And if you think that video you first saw is better than the recent options you can always go back.
This simple yet powerful rule applies far beyond streaming, think job searches, apartment hunting, even dating. The world’s your oyster ;)
Optimising Your Errand Runs
Running errands can eat up your day but you can save time by understanding the "Traveling Salesman" problem.
Imagine a travelling salesman who must visit a bunch of cities exactly once before returning home. The challenge here is finding the shortest possible route. It’s a famous problem between nerds because figuring it out gets incredibly tricky as the number of stops grows but for you even a rough version of the solution can save time in the real world.
The rough version:
- Plan your route in advance
- Group errands that are in close proximity
- Avoid backtracking
- Bonus: order your list by perishability (ice cream is never stop #1. unless… you like soup).
Full disclosure: this chapter wasn’t even in the book. Your mom asked me to add it.
The Art of Scheduling
“Identify blockers, beware of context switching overheads and use heuristics to identify which tasks to complete first. Don’t stress about it - starting in the wrong order is better than not starting at all!”
Remember Tetris? Yeah so imagine your day as a game of Tetris and this is where the good part ends. Because instead of colourful blocks you’re juggling tasks, deadlines and shifting priorities. The pieces keep coming faster and faster and you have to fit them together as efficiently possible or it’s game over.
Nintendo might sue me for this but here’s the cheat code: WSPT (Weighted Shortest Processing Time). It works like this: take a task’s significance and divide it by the time it’ll take to finish. If that number beats whatever you’re working on now, drop what you’re doing and switch. So in Tetris terms we’re slotting the highest value pieces in at the right moment to clear lines faster.
Remember how you used to say it’ll be over for everyone once you get productive? With WSPT you can now speedrun your todo list.
Decluttering Your Desk
Think of your desk as a computer's cache, a place where you keep your most frequently used items for quick access. But just like a computer your desk has limited space and needs efficient management. In computer science the Least Recently Used (LRU) algorithm as the name suggests is a strategy that discards the least recently used items first when the cache is full.
Now, let's apply this to your desk. You keep the tools you often use like your laptop or your favourite pen on the desk for easy access. But what happens when your desk starts to look like a cluttered mess?
That's when you apply the LRU principle. Start by removing items that you haven't used in a while. This way, your desk remains organised, and you can work more efficiently because the tools you need most are always within reach. Just like the LRU algorithm keeps a computer running smoothly by managing its cache, you can keep your workspace tidy and efficient by applying the same principle.
Conclusion
Algorithms to Live By is a must read for everyone and their mothers. It's informative, funny and full of practical advice. And who knows, maybe you'll even discover the algorithm for finding the perfect cup of coffee. So go forth and optimise, both in your code and in your life!