EmbeddedSystems
Post #7108 · source on Telegram
Embedded Engineers Judge You for Wasting an Entire Int on a Counter
Description
A Simpsons meme using Principal Skinner's 'Pathetic' scene. The top text reads: 'EMBEDDED ENGINEERS WHEN I STORE A 1-10 COUNTER IN AN INT RATHER THAN PACKING IT INTO 4 LEFTOVER BITS IN OTHER VARIABLES'. Skinner looks down dismissively with the caption 'Pathetic.' at the bottom. The meme captures the extreme memory optimization mindset of embedded systems engineers who would never waste 32 bits on a value that only needs 4 bits, preferring to pack data into spare bits of existing variables. The imgflip.com watermark is visible
Use J and K for navigation
Comments
23Comment deleted
An embedded engineer doesn't see unused bits -- they see wasted real estate in a silicon apartment where every bit pays rent
Most developers see a 32-bit integer as a number. An embedded engineer sees it as a block of 8 potential four-bit counters for eight different state machines
On a 32 KB AVR, those 28 wasted bits are like leaving the company jet idling on the tarmac
The real pathetic part is when you realize the compiler was already packing those bits efficiently, but you spent 3 hours hand-optimizing it anyway, only to discover the MCU has 256KB of RAM you'll never use because management insisted on 'future-proofing' the hardware selection
Ah yes, the eternal divide between embedded engineers who treat every byte like it's 1975 and the rest of us living in the post-scarcity era of 64GB RAM. While we're casually throwing around 64-bit integers for boolean flags, they're over there playing Tetris with bits, squeezing four counters into a single byte and using the sign bit for error flags. But let's be honest - when your entire program needs to fit in 32KB of flash and you're running on a coin cell battery for five years, suddenly that 'wasteful' int allocation looks less like engineering and more like a war crime. They're not wrong; they're just operating in a parallel universe where malloc() is a four-letter word and the stack overflow isn't a website, it's an actual Tuesday afternoon disaster
Embedded devs packing bits like it's 1985: 'Why allocate 32 when 4 tortured ones suffice?' Until feature creep demands an actual int - and your flash overflows
Only in firmware does saving one byte by nibble-packing turn a ++ into a read-modify-write with masks, ISR races, and three lost weekends
Saving four bytes is noble until the next firmware rev changes the register map and your 4-bit counter straddles two volatile fields - enjoy mask/shift archaeology at 3am
embedded devs seeing how powerful new embedded chips are Comment deleted
Noooo Comment deleted
Bold if you to assume we dare use all. You know maybe we will need those resources later in the future in 10 years. /s Comment deleted
Yeah imagine using a single static var for 3 different things instead of a 8 bit register you have for free Comment deleted
The time spent on extracting it from other variable will be more valuable than using extra 16 bits of memory. Btw you can use uint8_t🤓🤓🤓 Comment deleted
Packing bits is easy with bitfields: struct mydata { int counterA : 4 = 0; counterB:3 =0; stateFlag :1 = 0; errCounter : 5 = 0; .... } Comment deleted
It is still an abstraction, compiler will make it usual bitwise operation code. Though it is really convenient for storing registers of some module Comment deleted
wow, how have I never heard about this Comment deleted
Yea this is absolutely true. We will judge you for using references for single use values too Comment deleted
Ага, и потом дебажить это до трёх ночи. Comment deleted
We dont make mistakes so you wont need to touch it until hardware fails Comment deleted
Please, stick to English around devmeme 🙏 Comment deleted
yawn Comment deleted
best I can do is using u8 Comment deleted
std::vector<bool> Comment deleted