43 ms·
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 a
by brador 1y 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.
- legacynl 1y agoWe could just use 2 integers for floats and not deal with inaccuracies. Even easier.
- aDyslecticCrow 1y agoFloats 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 1y ago> 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 https://en.wikipedia.org/wiki/Pentium_FDIV_bug
- Dylan16807 1y agoYour argument against floats is a bug from 30 years ago? That's probably the weakest possible reason you could have given.
- _9ptr 1y agoWhy not only have strings? "zero", "one", "two", ... "threepointonefourone..."
- CorrectHorseBat 1y agoCongratulations, you have invented tcl
- iberator 1y agoPerl, awk, tcl, bash - all string based langs. Especially TCL
- zero_shift 1y agoFloats 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
- mattkrause 1y agoAnd now you've invented Church (among others)!
- inkyoto 1y agoAddendum: «nevermore == -1» for «no value».
- jodrellblank 1y agoTracking the accumulated 'perhaps'ness... "Essentially, each Ball Arithmetic number carries with it an explicit Radius that describes the interval which contains the true value. Because Ball Arithmetic data propagates throughout a calculation and is never demoted to a lower datatype, its advantage is that after each operation the resulting Ball reliably includes the true answer. Across an entire algorithm, the final result is a Ball that indicates explicitly how precise it is, thus eliminating the guesswork as to the effect on the algorithm of the inexactness of the input and any other inexact constants used" - NARS2000 dialect of APL, Ball / Interval arithmetic: https://wiki.nars2000.org/index.php/Ball_Arithmetic https://wiki.nars2000.org/index.php/Ball_Arithmetic
- immibis 1y agoWe could just use strings for everything, like bash, and tcl, and the weird scripting language embedded in every mid-2000s FPS game.
- nomel 1y agoThe nice part about floats is the bit packing is usually standard, meaning you can have them hold arbitrary data, if you sacrifice a couple of bits! There's a robot controller that I work with that has a large number of calibration tables, of float32 values. This is where I store the json! :D