frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How many options fit into a boolean?

https://herecomesthemoon.net/2025/11/how-many-options-fit-into-a-boolean/
29•luu•3d ago

Comments

pavon•1h ago
Neat. Even knowing about niche optimization I would have guessed that you could fit 7 Options - one bit for each. But the developers were smart enough to take advantage of the fact that you can't have a Some nested below a None, so you only need to represent how many Somes there are before you reach None (or the data), allowing 254 possibilities.
mock-possum•1h ago
> looking at Rust … it turns out that `Option<bool>` takes up exactly one byte of memory, the same as bool! The same is true for `Option<Option<bool>>`, all the way up to 254 nested options.

Ah how many of those options fit into that boolean. Word games!

nine_k•1h ago
The scoop: a boolean can't be smaller than a byte. Full 254 level of nested Option<bool> fit into it. (C++ needs much more for even a single level.)
priowise•1h ago
This question always reminds me that we often compress far more nuance into binary decisions than reality allows. In practice most systems end up inventing “soft booleans” (flags, states, priorities) to deal with that.
RobotToaster•27m ago
>and that it takes up one byte of memory

You can make them smaller using bitfields in C.

russdill•14m ago
Um, no. Please show me how you can fit 255 possible states in something smaller than a byte by using bitfields.
RobotToaster•8m ago
I was quoting the first paragraph, where it says a single normal bool takes a byte.
AlotOfReading•9m ago
The object it's inside will still take up at least one byte.

    sizeof(struct {bool a:1;}) == sizeof(char);
shagie•17m ago
For Java developers... you can use Optional<Boolean> to store the elusive four possible booleans.
ralferoo•9m ago
True | False | FileNotFound was a meme about 2 decades ago, and even that was a reference to MSDOS from another 2 decades earlier. I guess things never change, only the language.

Even now, I still find myself using true/false/null on occasions, but I'm usually smart enough to replace it with an enum at that point. The only time I don't is when it's an optional parameter to a function to override some default/existing value, at which point it then makes sense to keep it as an optional bool.

gizmo686•4m ago
I'm surprised that trinary logic has not become a standard part of standard libraries yet. Almost every project I have worked on ends up with some form of a yes/no/maybe abstraction.
hinkley•2m ago
With privacy coming back into vogue, it’s useful to distinguish “we didn’t ask” from “they wouldn’t answer”

For some vector logic the distinction could matter.

hinkley•3m ago
I did a govt contract early on and learned that yes/no/unanswered/unasked was a common quad. I see that in disclosures when applying for jobs as well.

Tony Hoare has died

https://blog.computationalcomplexity.org/2026/03/tony-hoare-1934-2026.html
704•speckx•2h ago•72 comments

Show HN: RunAnwhere – Faster AI Inference on Apple Silicon

https://github.com/RunanywhereAI/rcli
39•sanchitmonga22•32m ago•6 comments

Debian decides not to decide on AI-generated contributions

https://lwn.net/SubscriberLink/1061544/125f911834966dd0/
140•jwilk•2h ago•102 comments

I built a programming language using Claude Code

https://ankursethi.com/blog/programming-language-claude-code/
20•GeneralMaximus•1h ago•21 comments

Intel Demos Chip to Compute with Encrypted Data

https://spectrum.ieee.org/fhe-intel
147•sohkamyung•4h ago•49 comments

I put my whole life into a single database

https://howisfelix.today/
335•lukakopajtic•7h ago•157 comments

Meta acquires Moltbook

https://www.axios.com/2026/03/10/meta-facebook-moltbook-agent-social-network
190•mmayberry•3h ago•108 comments

Show HN: How I Topped the HuggingFace Open LLM Leaderboard on Two Gaming GPUs

https://dnhkng.github.io/posts/rys/
124•dnhkng•4h ago•46 comments

Launch HN: Didit (YC W26) – Stripe for Identity Verification

30•rosasalberto•2h ago•33 comments

Online age-verification tools for child safety are surveilling adults

https://www.cnbc.com/2026/03/08/social-media-child-safety-internet-ai-surveillance.html
316•bilsbie•4h ago•186 comments

I used pulsar detection techniques to turn a phone into a watch timegrapher

https://www.chronolog.watch/timegrapher
16•tylerjaywood•2d ago•3 comments

The Gervais Principle, or the Office According to "The Office" (2009)

https://www.ribbonfarm.com/2009/10/07/the-gervais-principle-or-the-office-according-to-the-office/
223•janandonly•3d ago•95 comments

Rebasing in Magit

https://entropicthoughts.com/rebasing-in-magit
126•ibobev•4h ago•91 comments

PgAdmin 4 9.13 with AI Assistant Panel

https://www.pgadmin.org/docs/pgadmin4/9.13/query_tool.html#ai-assistant-panel
64•__natty__•5h ago•18 comments

Sending Jabber/XMPP Messages via HTTP

https://gultsch.de/posts/xmpp-via-http/
39•inputmice•4h ago•5 comments

Yann LeCun's AI startup raises $1B in Europe's largest ever seed round

https://www.ft.com/content/e5245ec3-1a58-4eff-ab58-480b6259aaf1
376•ottomengis•6h ago•200 comments

How many options fit into a boolean?

https://herecomesthemoon.net/2025/11/how-many-options-fit-into-a-boolean/
29•luu•3d ago•13 comments

Show HN: DD Photos – open-source photo album site generator (Go and SvelteKit)

https://github.com/dougdonohoe/ddphotos
41•dougdonohoe•4h ago•11 comments

Amazon is holding a mandatory meeting about AI breaking its systems

https://twitter.com/lukolejnik/status/2031257644724342957
230•lwhsiao•2h ago•149 comments

MariaDB innovation: vector index performance

http://smalldatum.blogspot.com/2026/02/mariadb-innovation-vector-index.html
4•gslin•2d ago•0 comments

We are building data breach machines and nobody cares

https://idealloc.me/posts/we-are-building-data-breach-machines-and-nobody-cares/
11•idealloc_haris•2h ago•5 comments

A New Version of Our Oracle Solaris Environment for Developers

https://blogs.oracle.com/solaris/announcing-a-new-version-of-our-oracle-solaris-environment-for-d...
33•naves•2d ago•18 comments

Caxlsx: Ruby gem for xlsx generation with charts, images, schema validation

https://github.com/caxlsx/caxlsx
57•earcar•4d ago•4 comments

Practical Guide to Bare Metal C++

https://arobenko.github.io/bare_metal_cpp/#_abstract_classes
90•ibobev•3d ago•32 comments

Two Years of Emacs Solo

https://www.rahuljuliato.com/posts/emacs-solo-two-years
329•celadevra_•17h ago•123 comments

LoGeR – 3D reconstruction from extremely long videos (DeepMind, UC Berkeley)

https://loger-project.github.io
120•helloplanets•11h ago•26 comments

$3 ChromeOS Flex stick will revive old and outdated computers

https://9to5google.com/2026/03/10/this-3-chromeos-stick-will-revive-old-and-outdated-computers/
19•pentagrama•1h ago•14 comments

Lotus 1-2-3 on the PC with DOS

https://stonetools.ghost.io/lotus123-dos/
162•TMWNN•3d ago•64 comments

Microsoft Copilot Update Hijacks Default Browser Links

https://reclaimthenet.org/microsoft-copilot-update-hijacks-default-browser-links
14•miohtama•42m ago•1 comments

TCXO Failure Analysis

https://serd.es/2026/03/06/TCXO-failure-analysis.html
89•zdw•3d ago•38 comments