Beautiful code
Tuesday, September 2nd 2025Zeke Gabrielse, Founder of Keygen
One of my favorite questions to ask candidates is "what makes code 'beautiful' to you?" I preface the question with the understanding that they don't need to think code is "beautiful." Not everybody does, and that's fine. I'm always surprised by the variety of answers.
To me, just because code "works" doesn't mean it's "good."
I very often (re)write code so that it "looks good." It's probably entirely subjective, but I want to enjoy writing the code, and I want to be proud of it. Later on, I don't want to think about how the code could've been written better, or clearer, or "prettier."
I want to look at the code — how it's formatted, how it's abstracted, how it flows — and feel like I've written prose. I want to see its beauty before even reading the symbols and words.
This is one of the reasons I love Ruby so much. I can make the code work, and then I can make the code beautiful.
For example, we can take this ordinary code that "works":
schema = Parameter.new(type: :hash)schema[:age] = Parameter.new(type: :integer, optional: true)schema[:name] = Parameter.new(type: :string) schema.valid?({ age: 34, name: 'Zeke' }) # => true
And turn it into something beautiful and a joy to write:
schema = Parameter.hash do |s| s.integer :age, optional: true s.string :nameend schema.valid?({ age: 34, name: 'Zeke' }) # => true
And making code beautiful is not just something that can be done in dynamic meta-programmable languages like Ruby. You can do the same thing in strongly-typed languages like Go as well:
func (s *Store) GetUsers(orgId string, teamId string, includeDeleted bool, filters map[string]any) ([]User, error) { // ...} // find users for a team with a given domainusers, err := store.GetUsers( "", "team2", true, map[string]any{ "domain": "team2.example", },)
We can make this code not just "work," but make it feel like prose:
func (s *Store) GetUsers(predicates ...PredicateFunc) ([]User, error) { // ...} // find users for a team with a given domainusers, err := store.GetUsers( store.WithTeam("team2"), store.WithDomain("team2.example"), store.WithDeleted(),)
Writing code like this makes me happy. It makes work my art. And it makes me feel like I'm tending to my garden well.