Day 223: 43 lines in 7 hours

Today, I worked for 6 hours, 52 minutes, and 39 seconds and over that time, wrote 43 lines of code.

In another situation, taking 10 minutes on average to produce a single line of code might have been frustrating, but I’m quite pleased with how my work went today.

Yesterday, I mentioned how some of my housemates encountered mysterious performance issues while using Browserflow. Jules let me borrow his computer this morning, and after about an hour, I found the root cause: When Browserflow’s state gets too large (e.g. it takes a screenshot and is holding an image in memory), it slows everything down because it needs to pass the state back and forth between the popup and the background script in order to keep the state in sync.

When I migrated Browserflow over to Redux, I wrote my own library to synchronize state between the different contexts instead of using a popular library aimed at solving this problem. At the time, I wasn’t sure if the time invested in writing all of that plumbing code was worth it, but today, it paid off because I knew exactly how everything worked under the hood. This is one of my favorite parts about being able to work on projects without being forced to take shortcuts or write half-baked solutions due to artificial time constraints: I can take the time to understand what I’m doing, spend the time to do it right, and then reap the rewards when I need to make changes in the future. I spent most of today’s working time thinking through what changes were required and writing monster comments to document my thought process to help out future me (it’s not going to make much sense if you’re not me because there’s a lot of other context that’s not spelled out here):

I was surprised that I was able to make the optimizations needed in only 43 lines — it was much easier to do than I thought it’d be once I knew exactly what was required. At this point, my custom library to sync Redux state between different contexts has everything I need (optimistic updates, throttling, custom filters when forwarding state to clients, structural sharing so components don’t rerender unless they need to), and it all happens in under 200 lines of code!

Even though for me programming is first and foremost a means to build cool things rather than an end in itself, there’s such a deep satisfaction in writing beautiful code.