Phillip Luther’s Frontend Developer Experience Blog

There Is No Code You Can Write That I Won't Understand

Published on

As your dev skills level-up, your code dumbs down. Clarity feuds with cleverness. 20 lines of code that could be a baffling one line regex? Opt for verbosity.

Tamanna Rumee via Unsplash![Alt text](code-for-humans.jpg)

Once upon a time, as I was leaving a small company and frantically brain-dumping years and years of everything on a junior developer, he glibly told me, “There’s nothing you can write that I can’t understand.”

He said it with a wry grin, smirking and full of hubristic barbs. “Your code is childish and simple,” he insinuated. I took it as the greatest compliment he could have paid. I blushed.

At that moment, I knew I was really a senior engineer.

Your Code Isn’t For You

Code is for humans.

A Million Devs Smarter Than Me

It’s been said a million times by devs much smarter than I am. Google it. Better yet, DuckDuckGo it. Code is for humans.

Code should be readable. The machine knows what you mean, regardless of how clever or concise or golfy your code is. The dev sitting next to you doesn’t know what you mean. Write your code for the dev sitting next to you.

If you’re unavailable, that dev sitting next to you will get the call at 3:27am when stuff melts. Make it easy for ‘em to grok what your code meant.

Take this classic example:

i^5 ? doSomethingElse() : doSomething();

VS.

if (i === 5) {
  doSomething();
} else {
  doSomethingElse();
}

Anybody out there use XOR operators in their JavaScript? Me, either. I’d git blame the hell out of that line at 3:27am.

Code is language. It’s communication. Sure, with the computer, but more so with other software devs. Professionally, being the only person working in a codebase is rare. You might know that vih is an array of vegetables you hate. What about your colleague thinking it’s vehicles in Hawaii? Imagine their puzzlement when they pop beets from that array.

Code is communication. Communicate clearly.

Take It From a Human: Code is For Humans

I know, I know.

We’ve all heard it before. We get it.

Code should be self-documenting. Code should be readable. Code is for humans; we don’t need to flex in every PR.

Sometimes we forget, though. This is a friendly reminder. Code is for humans. Write code for humans.