Skip to content

01Writing

Notes & essays.

On frontend engineering, performance and leading small teams. Written when I learn something worth keeping.

02Posts

  1. Next.js

    React Server Components: what they actually are (and why most explanations get it wrong)

    Most RSC articles teach you a mental model that was accurate for Next.js 14. Ship that code in 2025 against Next.js 15 or 16, and you'll hit runtime errors on day one. The framework moved; the tutorials didn't. Let's fix that.

  2. Algorithms

    Segment trees: answer any range query in O(log n) and update just as fast

    The last two articles in this series dealt with flat, mostly static data. Binary search requires your array to be sorted and unchanged. Quickselect mutates the array and works best as a one-shot operation. Both fall apart the moment your data is dynamic, elements changing, queries arriving continuously, and correctness required after every mutation. This is the problem segment trees solve. And they solve it elegantly: O(log n) per query, O(log n) per update, and the same structure handles a surprisingly wide family of problems: range sums, range minimums, range maximums, and beyond.

  3. Algorithms

    Quickselect: find the k-th smallest element in O(n), no sorting required

    The previous article on binary search ended with a claim that probably raised an eyebrow: you can find the k-th smallest element in an unsorted array in O(n) average time, without sorting. If sorting is O(n log n), how does selection get away with O(n)? The answer is quickselect, and understanding it will permanently change how you think about the divide-and-conquer family.

  4. Algorithms

    Binary search is O(log n): but that's not the whole story

    Everyone learns binary search as the textbook example of O(log n) efficiency. Halve the search space, halve it again, find your answer in logarithmic time. Clean. Elegant. Fast. That framing isn't wrong. It's just incomplete and the parts it omits are exactly what bite you in production. The Big-O notation tells you how the algorithm scales. It says nothing about when it's the wrong tool entirely, or why a "slower" algorithm sometimes wins in practice. Let me walk through what's actually happening under the hood, where the standard mental model breaks down, and how to make the right call in real code.