That Moody Guy!

Mandlebrot set.

Learning a new computer language? Build something.

Last year, I was tasked with designing an engagement tracking system for the project my team was working on at Klaviyo. It would need to be performant at scale and highly reliable. My boss suggested that I look at building it in Go.

There was just one problem. I had never used Go. I needed to get up to speed quickly.

So I reached for a trick I’ve used many times when learning new computer languages. I decided to build something interesting but hard. It needed to be something that would require me to use the language’s features. Go has a very robust concurrency model, so my project needed to use concurrency so I could learn the ins and outs of the language’s features.

So I decided to build a Mandelbrot set generator.

For those of you not familiar with Mandelbrot sets: The set is a mathematical process that, when plotted on the complex plane (think an x-y axis from algebra, but with the y-axis being imaginary numbers), produces a beautiful fractal image that repeats (or nearly so) as you zoom in.

So my program would need to:

  • Perform lots of calculations with complex numbers
  • Convert the results of those calculations into an image
  • Quickly display that image in a window
  • Recalculate the image at various zoom levels

This was a great way to learn Go. I learned how to use goroutines and channels, and became reacquainted with pointers (which I haven’t used in programming in years!). I learned that debugging concurrency problems is particularly tricky. And l learned about how to structure programs in Go – so much so that I’ve rewritten the entire app three times now!

This side project enabled me to get up to speed on Go, so when we built the engagement tracking project in Go, I knew the pitfalls to avoid. I’m still not an expert in the language, but I’m proficient enough to be productive.

Need to learn a new technology or language? Come up with a challenging project and dive in!

Along these lines, I highly recommend Jamis Buck’s The Ray Tracer Challenge: A Test-Driven Guide to Your First 3D Renderer. Buck takes you step by step through the process of writing a ray tracer from scratch, and the exercise is meant to be doable in any computer language. I’m planning to learn Rust soon, and I’m going to try my hand at building a ray tracer in it. (Because who doesn’t love chrome spheres on a checkerboard background?)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top