Remix.run Logo
brador 2 days ago

Booleans are a remnant of limited RAM.

2025, we can all just use integers and carry one less variable type in our sack.

Next we replace integers with floats and we’re done. 3 birds, 1 stone.

jbreckmckye 2 days ago | parent | next [-]

Floats are an excellent choice because they encode the inevitable ambiguity of the world. Instead of true and false we can have

    true    = 1
    false   = 0
    perhaps = 0.5
inkyoto a day ago | parent | next [-]

Addendum: «nevermore == -1» for «no value».

mattkrause 2 days ago | parent | prev [-]

And now you've invented Church (among others)!

GLdRH 2 days ago | parent | prev | next [-]

Why not only have strings? "zero", "one", "two", ... "threepointonefourone..."

CorrectHorseBat 2 days ago | parent | next [-]

Congratulations, you have invented tcl

iberator 2 days ago | parent | prev [-]

Perl, awk, tcl, bash - all string based langs. Especially TCL

legacynl 2 days ago | parent | prev | next [-]

We could just use 2 integers for floats and not deal with inaccuracies. Even easier.

aDyslecticCrow 2 days ago | parent [-]

Floats can represent faaar bigger span than two integers. 2*10^-308 to 2*10^+308 is gonna require you 1024 bits or 32 integers. Now those 32 integers would represent that value exactly instead of rounding a few decimals, but some maths prefer approximate large span over exact values.

aDyslecticCrow 2 days ago | parent | prev | next [-]

> Booleans are a remnant of limited RAM.

I highly doubt that. Let's call a boolean that is represented as one bit "true boolean type" Since no instruction set (that i'm aware of) has boolean operators, a "true boolean" would require every operation on it to evaluate to multiple bit-wise operations, which take up registers and cycles. Flags in registers are "true boolean", but they're usually operated on explicitly like int with bit-wise operators.

There is also the issue of bit alignment, atomic access, and stack and heap allocations being byte based; further restricting how a language that had "true booleans" would be able to actually be able to work with them.

I know that there are some languages that allow boolean arrays to be packed tightly as "true boolean", but that is a rare exception. Even char and byte types has this issue sometimes, but are more commonly "properly packed".

> we can all just use integers

So it's all integers already. The most common implementation of boolean around is probably #define true 1

But we really should use enums more instead of boolean. "fail, success, bad_param, error_404" is equally efficient to return as a bool.

> Next we replace integers with floats.

No. (well python and JavaScript kinda does already, but no) https://en.wikipedia.org/wiki/Pentium_FDIV_bug

immibis 2 days ago | parent | prev [-]

We could just use strings for everything, like bash, and tcl, and the weird scripting language embedded in every mid-2000s FPS game.