Picking Equatable Names

submited by
Style Pass
2025-01-24 01:30:03

Naming things is hard. It’s one of two hard problems in computer science, alongside cache invalidation and off by one errors. Humans struggle to come up with good names. Personally, I can never remember if it’s AbstractProducerFactory or AbstractFactoryProducer.

Perhaps more surprisingly, computers are also stumped by this task. Compilers often need to come up with names and find themselves at a loss just like you and me. Sure, some of the names will be given to the compiler by the user writing code:

Unfortunately, it’s rare the user gives us as many names as the compiler needs. As our function is compiled towards machine code, the compiler will introduce new local variables or even whole new function parameters. Each of which deserves a name, so the compiler knows how to find it later. Inevitably, the need for names comes knocking.

Okay, so compilers want names, but why is it hard for them to come up with them? We have to look to how compilers represent programs in memory to understand their naming dilemma. Let’s set up a simple AST with named variables:

Leave a Comment