US education non-profit the Khan Academy has completed 500,000 lines of code in Google's Go programming language to replace its backend server previously written on Python 2.
Kevin Dangoor, a principal software architect at Khan Academy, details the organization's big shift from Python 2 under a project called Goliath.
Python 2 reached end of life in 2020, so the organization was preparing for a large migration – possibly to Python 3 or another language. Eventually, it settled on Go, a language designed to be fast and used at Google on cloud-scale systems.
"Moving from Python 2 to 3 is not an easy task," Dangoor remarked in 2019. His team considered Kotlin an "appealing alternative" but ultimately settled on Go, which its engineers believed offered a major performance edge over Python 3.
"As individuals writing code, we can iterate faster due to Go's lightning quick compile times. Also, members of our team have years of experience and muscle memory built around many different editors. Go is better supported than Kotlin by a broad range of editors," he noted at the time.
With half a million lines of Go code now in production, Dangoor has given an update on the Khan Academy's Go migration for its backend services.
"In general, Go tooling is fantastic," writes Dangoor. "The compiler is quick, and having formatting being a part of the standard toolchain helps eliminate most conversations about formatting. Though I still see grumbles on the internet about Go modules, they work better than previous package management approaches in Go and, at this point, nicely overall in our experience."
Google began using Go internally in 2007 and released Go version 1.0 in 2012. While it is one of the top 20 most popular languages, year after year Go developer surveys have revealed the top complaint is its lack of generics or generic types.
Dangoor's team is also demanding generics in Go.
"Most of the time, writing Go code without generic types is fine. Most of the time, but there are plenty of times when we've been writing internal library code or even just working with slices when we felt their absence," he writes.
The Go team earlier this year released a proposal to enable generic programing, which would allow developers to write functions and data structures where some types aren't specified until later. It may arrive by the end of 2021 in a future release of Go.
Go isn't perfect, but some engineers on Dangoor's team believed Go's fewer language features than Python made Go code more consistent and quicker to read. That could be helpful for future programmers who are maintaining the Go codebase.
"We're looking to write a bit less code, and the options we get with generics will help with that," he notes.
Highlighting Go's speed advantage over Python, Dangoor points to a class containing 1,000 students that could take 28 seconds to load in Python, but only takes four seconds to load in Go. He said that while Go is "more verbose in general" than Python, it's fast, the tooling is solid, and it runs well in production.