r/programming • u/AllThingsSmitty • 1d ago
Hot take: Sometimes three boring statements beats one clever expression
https://allthingssmitty.com/2026/11/16/sometimes-three-boring-statements-beat-one-clever-expression/Sometimes the simplest code is the best code. It's tempting to squeeze everything into one clever expression, but three straightforward statements can be easier to understand and maintain. Here's a look at why.
0
Upvotes
92
u/Ok-Rule8061 1d ago
Not a hot take. Literally the core of collaborative production software engineering.
23
u/YeetCompleet 1d ago
Gotta be the coldest take yet
11
u/SmokyMetal060 1d ago
Nah not a hot take. Anybody who's worked an entry level SWE job has gotten told by their senior to not get cute.
6
u/AnkerSOLIX-Support 1d ago
Three boring statements beat a clever one-liner when you're on call and the person who wrote it left two years ago. Doesn't seem like a hot take.
6
u/trialbaloon 1d ago
Ice cold take. I would like to read someone claiming the opposite, that would be more fun.
6
u/curiouslyjake 1d ago
It's a really cold take. The paramount purpose of code is to be readable by others. This means your team members and it means you in six months. The moment someone reads a line of code and goes "huh?", it means the code not as readable as it could have been.
4
u/MyNameIsRichardCS54 1d ago edited 1d ago
Not sometimes, no. I would say nearly always.
4
u/yawaramin 1d ago
And sometimes a single expression beats three different statements because it's just a single logical code phrase where everything is in your head (working memory), whereas the three different statements are separate and each introduces a separate possibility for bugs to creep in.
2
u/EntroperZero 1d ago
I've recently seen this pattern a lot in C# with the new pattern matching syntax:
This is a really odd way of combining local variable declaration with simple null checks.
1
u/jippiex2k 1d ago
What's the difference between a fallback theme and a default theme o.O
1
u/commenterzero 1d ago
Idk can you split that up for me
1
u/rs98101 1d ago
Yeah, it’s not sometimes. It is almost every time.
1
u/Plastic_Koala2044 1d ago
Agreed for code people review, less so for generated code. My framework writes the app's entry file for me, and I never care how dense that is because nobody reads it in a diff. The controllers get read on every change, and there a named intermediate beats a chained one-liner every time.
0
u/TTachyon 1d ago
Always, not sometimes.