frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

I keep tripping over "true, false, true"

https://allthingssmitty.com/2026/05/11/i-keep-tripping-over-true-false-true/
11•AllThingsSmitty•1h ago

Comments

PaulKeeble•1h ago
There is something to be said for the bitmasks that are so common in C, createUser(user, ADMIN | SENDMAIL); has a lot more clarity than createUser(user, true, false, true);

I don't mind the object approach used here but its quite verbose in comparison even in Javascript. Having to name the variable and set whether its true or false is a lot more than needs to be done. Booleans in general have quite poor readibility and maintenance especially if a third possibility arrives.

uberman•44m ago
Perhaps, jsdocs might help here.
bradrn•37m ago
Also known as ‘boolean blindness‘: e.g. https://cs-syd.eu/posts/2016-07-24-overcoming-boolean-blindn...
pwdisswordfishq•13m ago
This has nothing to do with it.
trgn•35m ago
named arguments are hacking object literals to provide additional readability. it's ok, but not for all code paths, they have a true overhead. problem is that these things start to become idee fixes in teams (all funcs should have named args!). ideally, this could be fixed in the language.
tyleo•32m ago
Agree that it would be nice to fix in the language. It seems like something that even a transpiler could take care of.

Ultimately I think I’d bias towards readability vs the marginal perf increase though.

tyleo•35m ago
In the last couple of years I’ve started using named parameters a bunch more across languages. I consider objects like this close to the JS version of a named parameter. I probably would have thrown “name” in myself so it’s one arg for the whole func.

I feel like a goal with good code is localizing understanding even if it occasionally duplicates something like a parameter name.

kevsim•18m ago
This is commonly referred to as "the boolean trap". You'll find lots of articles about it.
heyitsdaad•11m ago
You answered your own question. Call with

const isAdmin = true; . . . createUser(user, isAdmin, sendWelcomeEmail)

bcjdjsndon•9m ago
Isn't this more an issue with typescript? Doesn't your ide give you the declaration if you hover over the call?

> And I’ve seen real calls like this in production code: > updateSettings(user, true, false, true, false)

Really? He wants named parameters on all function calls cos he's got a memory like a sieve? This is a long solved problem to me

rideontime•9m ago
I was nodding along with the piece in the first half, then it repeated the same point five more times and I started to smell slop.
empath75•8m ago
You can tell it was written by claude after just a few sentences, really.