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

Programmer Humor

23417 readers
1699 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
[–] jenesaisquoi@feddit.org 13 points 6 days ago (1 children)

Wait until you hear about alignment

[–] bastion@feddit.nl 3 points 6 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!

[–] KindaABigDyl@programming.dev 183 points 1 week ago (4 children)
typedef struct {
    bool a: 1;
    bool b: 1;
    bool c: 1;
    bool d: 1;
    bool e: 1;
    bool f: 1;
    bool g: 1;
    bool h: 1;
} __attribute__((__packed__)) not_if_you_have_enough_booleans_t;
[–] kiri@ani.social 43 points 1 week ago

You beat me to it!

[–] xthexder@l.sw0.com 41 points 1 week ago* (last edited 1 week ago) (1 children)

Or just std::bitset<8> for C++. Bit fields are neat though, it can store weird stuff like a 3 bit integer, packed next to booleans

load more comments (1 replies)
load more comments (2 replies)
[–] Lucien@mander.xyz 140 points 1 week ago (1 children)
[–] mmddmm@lemm.ee 153 points 1 week ago (15 children)

And compiler. And hardware architecture. And optimization flags.

As usual, it's some developer that knows little enough to think the walls they see around enclose the entire world.

load more comments (15 replies)
[–] ricecake@sh.itjust.works 135 points 1 week ago (5 children)

I set all 8 bits to 1 because I want it to be really true.

[–] laranis@lemmy.zip 95 points 1 week ago* (last edited 1 week ago) (12 children)

01111111 = true

11111111 = negative true = false

[–] Jankatarch@lemmy.world 2 points 6 days ago

negative true = negative non-zero = non-zero = true.

[–] StellarSt0rm@lemmy.world 48 points 1 week ago (6 children)
[–] Venator@lemmy.nz 1 points 6 days ago

Is this quantum computing? 😜

load more comments (5 replies)
load more comments (10 replies)
load more comments (4 replies)
[–] WanderingThoughts@europe.pub 95 points 1 week ago (2 children)

string boolEnable = "True";

load more comments (2 replies)
[–] 30p87@feddit.org 90 points 1 week ago (10 children)

Then you need to ask yourself: Performance or memory efficiency? Is it worth the extra cycles and instructions to put 8 bools in one byte and & 0x bitmask the relevant one?

load more comments (10 replies)
[–] catnip@lemmy.zip 56 points 1 week ago (1 children)

Wait till you find out about alignment and padding

[–] JiminaMann@lemmy.world 2 points 6 days ago

Tell me the truth, i can handle it

[–] skisnow@lemmy.ca 52 points 1 week ago (6 children)

Back in the day when it mattered, we did it like

#define BV00		(1 <<  0)
#define BV01		(1 <<  1)
#define BV02		(1 <<  2)
#define BV03		(1 <<  3)
...etc

#define IS_SET(flag, bit)	((flag) & (bit))
#define SET_BIT(var, bit)	((var) |= (bit))
#define REMOVE_BIT(var, bit)	((var) &= ~(bit))
#define TOGGLE_BIT(var, bit)	((var) ^= (bit))

....then...
#define MY_FIRST_BOOLEAN BV00
SET_BIT(myFlags, MY_FIRST_BOOLEAN)

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