Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Don’t Use Booleans (luu.io)
2 points by luuio on Dec 17, 2019 | hide | past | favorite | 2 comments


Surprisingly sensible. I wonder if compiler magic could, in theory, reduce enums that have only two options down to a single bit, but still provide all the type safety guarantees. Or maybe provide another primitive just for that purpose.

Particularly with a new primitive, you could literally have a language that just doesn't allow you to define generic booleans.


At the bare metal layer, most booleans are actually transported around as `int` (or WORD size), so there's no real performance benefit to compressing things down to one bit, other than if you really need to save 7 bits in physical storage.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: