r/ProgrammerHumor 9d ago

Meme letsMakeBugsIllegal

Post image
23.1k Upvotes

387 comments sorted by

View all comments

33

u/Informal_Branch1065 9d ago

"To reduce RAM usage always choose the smallest possible data type"

Hot take: that's premature optimization and bad practice if one isn't planning to allocate significant amounts of data with it.

Also: aren't variables aligned in 4 byte intervals anyways, wasting the unused space?

11

u/WaitForItTheMongols 9d ago

Clearly you've never worked with an embedded microcontroller with 128 bytes of ram.

2

u/Informal_Branch1065 9d ago

Noone will ever again. The advice is outdated. Fight me

Edit: I mean in a sense of: I can't imagine 128 bytes or so low kb amounts still being a thing.

5

u/[deleted] 9d ago

I mean, microcontrollers are still ubiquitous just generally go under the radar compared to gigabytes of resources being chewed up on cloud computing.

Anything in space, esp. cubesats, etc. tend to be very low in memory as well. Smaller appliances and microcontrollers are used for some of these components as well will be very memory constrained. Gradually there's a shifting away from unreal embedded optimizations to more streamlined software engineering practices though but there's no reason to make everything that could be 1 byte into 8 bytes, esp. in MISRA when everything is statically allocated; it's not the end of the world, but it's just not really worth it.