this post was submitted on 15 May 2025
1157 points (98.6% liked)

Programmer Humor

23402 readers
1586 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 15 points 6 days ago (1 children)

Wait until you hear about alignment

[–] [email protected] 3 points 5 days ago

The alignment of the language and the alignment of the coder must be similar on at least one metric, or the coder suffers a penalty to develop for each degree of difference from the language's alignment. This is penalty stacks for each phase of the project.

So, let's say that the developer is a lawful good Rust ~~zealot~~ Paladin, but she's developing in Python, a language she's moderately familiar with. Since Python is neutral/good, she suffers a -1 penalty for the first phase, -2 for the second, -3 for the third, etc. This is because Rust (the Paladin's native language) is lawful, and Python is neutral (one degree of difference from lawful), so she operates at a slight disadvantage. However, they are both "good", so there's no further penalty.

The same penalty would occur if using C, which is lawful neutral - but the axis of order and chaos matches, and there is one degree of difference on the axis of good and evil.

However, if that same developer were to code in Javascript (chaotic neutral), it would be at a -3 (-6, -9...) disadvantage, due to 2 and 1 degree of difference in alignment, respectively.

Malbolge (chaotic evil), however, would be a -4 (-8, -12) plus an inherent -2 for poor toolchain availability.

..hope this helps. have fun out there!

[–] [email protected] 12 points 6 days ago

This reminds me that I actually once made a class to store bools packed in uint8 array to save bytes.

Had forgotten that. I think i have to update the list of top 10 dumbest things i ever did.

[–] [email protected] 10 points 6 days ago (1 children)

Wait till you here about every ascii letter. . .

[–] [email protected] 4 points 6 days ago (2 children)
[–] [email protected] 7 points 6 days ago* (last edited 4 days ago) (1 children)

ASCII was originally a 7-bit standard. If you type in ASCII on an 8-bit system, every leading bit is always 0.

(Edited to specify context)

At least ASCII is forward compatible with UTF-8

load more comments (1 replies)
[–] [email protected] 4 points 6 days ago (2 children)

Ascii needs seven bits, but is almost always encoded as bytes, so every ascii letter has a throwaway bit.

[–] [email protected] 10 points 6 days ago (1 children)

Let's store the boolean there then!!

[–] [email protected] 1 points 3 days ago

That boolean can indicate if it's a fancy character, that way all ASCII characters are themselves but if the boolean is set it's something else. We could take the other symbol from a page of codes to fit the users language.
Or we could let true mean that the character is larger, allowing us to transform all of unicode to a format consisting of 8 bits parts.

load more comments (1 replies)
[–] [email protected] 8 points 6 days ago

We need to be able to express 0 and 1 as integers so that functionality is just being overloaded to express another concept.

Wait until the person who made this meme finds out about how many bits are being wasted on modern CPU architectures. 7 is the minimum possible wasted bits but it would be 31 on every modern computer (even 64b machines since they default to 32b ints).

[–] [email protected] 5 points 6 days ago* (last edited 6 days ago) (2 children)

I mean is it really a waste? What's minimum amount of bits most CPUs read in one cycle.

[–] [email protected] 11 points 6 days ago

In terms of memory usage it's a waste. But in terms of performance you're absolutely correct. It's generally far more efficient to check is a word is 0 than to check if a single bit is zero.

load more comments (1 replies)
[–] [email protected] 4 points 6 days ago (2 children)

Could a kind soul ELI5 this? Well, maybe ELI8. I did quite a bit of programming in the 90-00s as part of my job, although nowadays I'm more of a script kiddie.

[–] [email protected] 9 points 6 days ago (1 children)

A Boolean is a true/false value. It can only be those two values and there be represented by a single bit (1 or 0).

In most languages a Boolean variable occupies the space of a full byte (8 bit) even though only a single of those bits is needed for representing the Boolean.

That's mostly because computers can't load a bit. They can only load bytes. Your memory is a single space where each byte has a numeric address. Starting from 0 and going to whatever amount of memory you have available. This is not really true because on most operating systems each process gets a virtual memory space but its true for many microcontrollers. You can load and address each f these bytes but it will always be a byte. That's why booleans are stored as bytes because youd have to pack them with other data on the same address other wise and that's getting complicated.

Talking about getting complicated, in C++ a std::vector is specialized as a bit field. Each of the values in that vector only occupy a single bit and you can get a vector of size 8 in a single byte. This becomes problematic when you want to store references or pointers to one of the elements or when you're working with them in a loop because the elements are not of type bool but some bool-reference type.

[–] [email protected] 2 points 6 days ago

And performance optimisation of a compiler for a 64 bit CPU will realign everything and each boolean will occupy 8 bytes instead.

[–] [email protected] 4 points 6 days ago

A boolean value only needs 1 bit (on or off) for true or false. However the smallest bit of addressable memory is a byte (8 bits) hence 7 are technically wasted.

For low memory devices you could instead store 8 different Boolean values in one single byte by using bit masking instead

[–] [email protected] 5 points 6 days ago (1 children)

I swore I read that mysql dbs will store multiple bools in a row as bit maps in one byte. I can't prove it though

load more comments (1 replies)
load more comments
view more: next ›