"A type of primitive thought"

submitted by lliuratni

· · mastodon-node · 8 · 13 · 23
@Centurionapollo @DeveloperMemes a byte is typically the smallest unit that can be addressed by a computer. This can be solved by pooling multiple bools together (i.e. 8 different bools stored in the same byte), but then it stops being a primitive and starts being a managed object with extra code (and thus overhead) associated with it
@Binkle @Centurionapollo @DeveloperMemes You could probably find the old school 80's coders using bytes like that, but like you said, it takes extra code in modern high level languages for little benefit.
@Inginsub @Binkle @Centurionapollo @DeveloperMemes Yeah there's bitwise operators and functions like that in a lot of languages. The "extra code" would just mean messing around with stuff other than boolean primitives in the language.
@Binkle @Inginsub @Centurionapollo @DeveloperMemes I can get it to work with the < and > characters, within the Code tag, with content set to BBCode.


@Binkle @Centurionapollo @DeveloperMemes is a boolean value in javascript much more than a byte?

@Centurionapollo @DeveloperMemes This is the reason why on system with low memory people doesn't use bool variables but use other variables where each bit represents another bool. since this is easy to mess up it is only a good idea where you really need to save some space even tow this can also have performance advances if done intelligently.

@pizza_pal @DeveloperMemes It can only do so much. C++ makes an attempt at this with it's std::vector container. It's an unmitigated disaster trying to use it and it's the one part of the toolset that everyone universally condemns.

Honestly though, in practice the 7 bits wasted just don't make much difference to anything, even back in the olden days. We just don't worry about it.
@pizza_pal @DeveloperMemes std::vector(bool) why did it autocorrect that, why can I not type chevrons
@DeveloperMemes nooooo!! you can't just waste memory by encoding booleans as functions!
haha alonzo go λλλλλλλλ
true = \a b -> a
false = \a b -> b

@DeveloperMemes @goosey It's worse than you think. Many systems will keep individual (non-struct) values word-aligned, so it may be 64 bits.



gaa dont tell me that! 😂
it was bad enough when i was taking the compliers course, (writing assembly runtime stuff for a python subset compiler on 486 linux) and every byte the C code threw at me was 32 bits on the stack. drove me crazy!

OTOH if bools are 64bit, then ints had damn well better ALSO be 64bit!


Many architectures also run all ALU instructions, and then MUX for the one asked for.

@DeveloperMemes I always assumed it was a byte to allow for error checking and parity corrections as a single bit can be flipped for many reasons which would be non-optimal to say the least.

@pswilde It's typically a byte for other reason - CPU simply work with bytes better than with individual bits. Alignment is a big concern with this as well. I discovered that in VBA, boolean is actually stored in two bits. Two.

Sign in to participate in the conversation
Mastodon is an instance of Masterdon, a decentrialized and open source social media plattform. This instance is especially about tech/cyber stuff and is also available inside the tor network. - The name is inspired by