Why I rewrote my side project in Go
I had a small URL shortener that started life as a Node script. It worked. It also woke me up at 2am twice because the process had quietly fallen over and nothing was watching it.
The rewrite wasn’t about speed. It was about wanting a single binary I could drop on a box and forget. Go gives you that almost for free, and the boredom of the language turned out to be the feature.
The part that surprised me
I expected to miss the npm ecosystem. I didn’t. What I actually missed was nothing — the standard library covered routing, templating, and the HTTP server without a single dependency, and the whole thing compiles in under a second.
The debounce I’d written three times in JavaScript became this, once:
// debounce returns fn wrapped so it only fires after d of quiet
func Debounce(d time.Duration, fn func()) func() {
var t *time.Timer
return func() {
if t != nil { t.Stop() }
t = time.AfterFunc(d, fn)
}
}Is it elegant? Not especially. But I will never have to think about it again, and that is the only metric I care about for a side project.
Boring code is code you get to stop thinking about.