Performance

The best of both worlds: The type safety of a wrapper class with the zero-overhead performance of a primitive.
Snippets

Type-Safe Zero-Cost Wrappers with Kotlin Value Classes

The Problem: Primitive Obsession You’ve probably seen this pattern in production code: database IDs represented as Long, user emails as String, currency amounts as Double. On the surface, it’s simple and pragmatic. But it introduces a subtle bug vector—primitive obsession. Imagine you have a function that accepts a user ID and a post ID, both […]

, , , ,
Tutorials

Android Choreographer API: Frame Timing, VSYNC, and Smooth 60fps Rendering

What Is the Choreographer API? The Choreographer API is Android’s internal frame timing system — the heartbeat of smooth animation. Every frame your app draws, the Choreographer orchestrates the timing. It synchronizes with the device’s VSYNC signal (the vertical refresh of your screen), and it exposes a callback mechanism so you can hook into that

, , , , , , , ,
Laptop with Kotlin code open
Tutorials

Lazy Computation in Kotlin: The sequence Builder and How It Can Save Your Memory

The Hidden Cost of Eager Collections Kotlin’s collection functions — map, filter, flatMap — are a joy to use. But they share one characteristic that can quietly hurt your app: they’re eager. Each call processes the entire source and allocates a brand new intermediate list. Chain three or four of them on a list of

, , , , ,
Tutorials

Stop Using System.currentTimeMillis() for Benchmarking: Kotlin’s measureTimedValue and Duration API

The Old Way: Manual Time Measurement If you’ve ever benchmarked a function in Kotlin or Android, you’ve probably written something like this: val start = System.currentTimeMillis() val result = doExpensiveWork() val elapsed = System.currentTimeMillis() – start Log.d(“Perf”, “doExpensiveWork took ${elapsed}ms, result=$result”) It works, but it’s noisy. You need three lines just to time one call,

, , , , ,
Scroll to Top