this post was submitted on 22 Jul 2025
3 points (100.0% liked)

Programmer Humor

27778 readers
1312 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
 

I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

That's why I love C++

top 6 comments
sorted by: hot top controversial new old
[–] deegeese@sopuli.xyz 1 points 4 months ago

C lets you shoot yourself in the foot.

C++ lets you reuse the bullet.

[–] Contramuffin@lemmy.world 1 points 4 months ago

What do you mean I'm not supposed to add 0x5f3759df to a float casted as a long, bitshifted right by 1?

[–] panda_abyss@lemmy.ca 0 points 4 months ago (1 children)

I actually do like that C/C++ let you do this stuff.

Sometimes it's nice to acknowledge that I'm writing software for a computer and it's all just bytes. Sometimes I don't really want to wrestle with the ivory tower of abstract type theory mixed with vague compiler errors, I just want to allocate a block of memory and apply a minimal set rules on top.

[–] jkercher@programming.dev 2 points 4 months ago* (last edited 3 months ago)

100%. In my opinion, the whole "build your program around your model of the world" mantra has caused more harm than good. Lots of "best practices" seem to be accepted without any quantitative measurement to prove it's actually better. I want to think it's just the growing pains of a young field.

[–] magic_lobster_party@fedia.io 0 points 4 months ago (1 children)

There are no medals waiting for you by writing overly clever code. Trust me, I’ve tried. There’s no pride. Only pain.

[–] Chrobin@discuss.tchncs.de 1 points 4 months ago

It really depends on your field. I'm doing my master's thesis in HPC, and there, clever programming is really worth it.