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/
17•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•1h ago
Perhaps, jsdocs might help here.
bradrn•59m ago
Also known as ‘boolean blindness‘: e.g. https://cs-syd.eu/posts/2016-07-24-overcoming-boolean-blindn...
pwdisswordfishq•36m ago
This has nothing to do with it.
trgn•57m 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•55m 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•57m 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•41m ago
This is commonly referred to as "the boolean trap". You'll find lots of articles about it.
heyitsdaad•34m ago
You answered your own question. Call with

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

rcxdude•13m ago
If you swap the order of isAdmin and sendWelcomeEmail you'll get no error from the compiler but now the names will be masking the actual behaviour.
bcjdjsndon•32m 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•32m 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•30m ago
You can tell it was written by claude after just a few sentences, really.
readthenotes1•23m ago
Someone want to recreate Smalltalk...
edwcross•21m ago
OCaml has had labeled arguments for decades, so I assumed other languages would have added something similar by now. In C-style, it would be like:

  createUser(user, ~isAdmin:true, ~sendWelcomeEmail:false)
Even though in OCaml's functional style it is actually like this:

  createUser user ~isAdmin:true ~sendWelcomeEmail:false
Using the fact that a variable named exactly like a labeled argument is automatically assigned to it, we can make the call more concise (especially if reusing existing variables):

  let isAdmin = true in
  let sendWelcomeEmail = false in
  createUser user ~isAdmin ~sendWelcomeEmail
lostmsu•17m ago
C# has that
MathMonkeyMan•8m ago
You can do this as a convention in javascript since 2015, but I haven't seen a library that does it:

    > function foo({a, b, c}) {
    ... return {x: a, y: b, z: c};
    ... }
    undefined
    > foo({a: 1, b: 2, c: 3})
    { x: 1, y: 2, z: 3 }
    > const a = 'A', b = 'B', c = 'C';
    undefined
    > foo({a, b, c})
    { x: 'A', y: 'B', z: 'C' }
    >
esafak•20m ago
Usable languages let you use named arguments foo(bar=zaz), and linters let you enforce their use for booleans.

https://kotlinlang.org/docs/functions.html#named-arguments

tantalor•14m ago
This one is a classic,

Avoid the Long Parameter List

https://testing.googleblog.com/2024/05/avoid-long-parameter-...

dematz•12m ago
First, sentences like "Not because it’s complicated. Just because I have no idea what I’m looking at." and "Tiny interruption. Still annoying every time." fatigue me, it's like you have an editor who, no matter what the content is, tries to spice up your writing with lots of little punchy exclamations, not everything needs such emphasis

Second, this may differ a bit from language to language, but maybe those booleans should not be a boolean: https://gleam.run/documentation/conventions-patterns-and-ant... for example isAdmin boolean could instead be a UserRole custom type, with variants Normal and Admin, which is easier to understand in the function call, and extendable with another Moderator (or whatever) variant

megiddo•8m ago
Exactly my thought. I know languages differ in support ... but enum is right there.
NooneAtAll3•10m ago
> toggleMenu(true); That’s clear enough. the meaning is obvious

so... it does toggle the menu? and toggleMenu(false) doesn't toggle it and keeps it as it is?

or is it toggle extended menu vs toggle basic menu?

disillusionist•8m ago
I've been using this pattern for the past couple years for the benefits the author mentions. In addition to that, it can help with overly complicated functions (which, ok, could probably be refactored) that have multiple optional arguments.

Ratty – A terminal emulator with inline 3D graphics

https://ratty-term.org/
263•orhunp_•4h ago•76 comments

Hardware Attestation as Monopoly Enabler

https://grapheneos.social/@GrapheneOS/116550899908879585
1830•ChuckMcM•20h ago•604 comments

Local AI needs to be the norm

https://unix.foo/posts/local-ai-needs-to-be-norm/
1447•cylo•20h ago•567 comments

Driver accused of DUI tracks missing laptop to Illinois State trooper's house

https://abc7chicago.com/post/top-cop-driver-accused-dui-tracks-missing-laptop-illinois-state-poli...
113•bryan0•2d ago•66 comments

Venom and Hot Peppers Offer a Key to Killing Resistant Bacteria

https://www.wired.com/story/mexican-science-transforms-scorpion-venom-and-habanero-chile-into-ant...
56•littlexsparkee•2d ago•9 comments

I'm going back to writing code by hand

https://blog.k10s.dev/im-going-back-to-writing-code-by-hand/
616•dropbox_miner•12h ago•329 comments

Gmail registration now requires scanning a QR code and sending a text message

https://discuss.privacyguides.net/t/google-account-registration-now-requires-sending-an-sms-via-p...
110•negura•6h ago•53 comments

The greatest shot in television: James Burke had one chance to nail this scene (2024)

https://www.openculture.com/2024/10/the-greatest-shot-in-television.html
247•susam•11h ago•120 comments

Running local models on an M4 with 24GB memory

https://jola.dev/posts/running-local-models-on-m4
424•shintoist•15h ago•129 comments

Guitar tuner that uses phone accelerometer

https://tautme.github.io/phone-sensors/accel-tuner.html
84•adm4•3d ago•42 comments

Classification of Amino Acids

https://www.khanacademy.org/test-prep/mcat/chemical-processes/amino-acids-peptides-proteins-5d/v/...
27•kamaraju•2d ago•0 comments

An AI coding agent, used to write code, needs to reduce your maintenance costs

https://www.jamesshore.com/v2/blog/2026/you-need-ai-that-reduces-your-maintenance-costs
245•cratermoon•14h ago•67 comments

Obsidian plugin was abused to deploy a remote access trojan

https://cyber.netsecops.io/articles/obsidian-plugin-abused-in-campaign-to-deploy-phantom-pulse-rat/
279•cmbailey•16h ago•157 comments

Training an LLM in Swift, Part 1: Taking matrix mult from Gflop/s to Tflop/s

https://www.cocoawithlove.com/blog/matrix-multiplications-swift.html
6•zdw•21h ago•0 comments

Incident Report: CVE-2024-YIKES

https://nesbitt.io/2026/02/03/incident-report-cve-2024-yikes.html
621•miniBill•20h ago•152 comments

Mythos Finds a Curl Vulnerability

https://daniel.haxx.se/blog/2026/05/11/mythos-finds-a-curl-vulnerability/
351•TangerineDream•7h ago•144 comments

I keep tripping over "true, false, true"

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

The Adventure Family Tree

https://mipmip.org/advfamily/advfamily.html
28•exvi•5h ago•3 comments

7 lines of code, 3 minutes: Implement a programming language (2010)

https://matt.might.net/articles/implementing-a-programming-language/
78•azhenley•9h ago•27 comments

All Those A.I. Note Takers? They're Making Lawyers Nervous

https://www.nytimes.com/2026/05/09/business/dealbook/ai-notetakers-legal-risk.html
86•JumpCrisscross•4h ago•58 comments

European Money Pours into Palantir

https://english.elpais.com/economy-and-business/branded/2026-04-11/european-money-pours-into-pala...
40•robtherobber•2h ago•3 comments

How Fast Does Claude, Acting as a User Space IP Stack, Respond to Pings?

https://dunkels.com/adam/claude-user-space-ip-stack-ping/
122•adunk•15h ago•42 comments

First tunnel element of the Fehmarnbelt Tunnel immersed

https://www.arup.com/en-us/news/first-fehmarnbelt-tunnel-element-lowered/
126•robin_reala•3d ago•68 comments

Ask HN: What are you working on? (May 2026)

213•david927•20h ago•782 comments

Guy Goma's Accidental BBC Interview Lives on After 20 Years

https://www.nytimes.com/2026/05/06/business/media/bbc-guy-goma-interview.html
148•nxobject•2d ago•34 comments

Show HN: adamsreview – better multi-agent PR reviews for Claude Code

https://github.com/adamjgmiller/adamsreview
54•adamthegoalie•12h ago•19 comments

Bliss (Photograph)

https://en.wikipedia.org/wiki/Bliss_(photograph)
48•cainxinth•3d ago•22 comments

Phel v0.36.0 – Lisp on PHP, now with numeric tower and first-class Vars

https://github.com/phel-lang/phel-lang/releases/tag/v0.36.0
45•Chemaclass•3d ago•12 comments

dBase: 1979-2026

https://delphinightmares.substack.com/p/dbase-1979-2026
98•deeaceofbase•3d ago•43 comments

I returned to AWS and was reminded why I left

http://fourlightyears.blogspot.com/2026/05/i-returned-to-aws-and-was-reminded-hard.html
808•andrewstuart•2d ago•575 comments