this post was submitted on 14 Feb 2024
563 points (98.3% liked)

Programmer Humor

19821 readers
218 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] frezik@midwest.social 45 points 10 months ago* (last edited 10 months ago) (2 children)

Years ago, older C programmers told me you don't know C unless you use dynamic memory management. I ended up rarely writing any C, but when I do, it's usually on microcontrollers where dynamic memory management isn't even supported out of the box.

Jokes on you, greybeards!

[–] sping@lemmy.sdf.org 9 points 10 months ago (2 children)

Though as a non-embedded dev who has interviewed embedded candidates I like to ask them to talk about the issues around C vs C++ for embedded and the first point 8 out of 10 of them make is C++ is bad because dynamic allocation is bad. And while they could expand to almost sort of make their point make sense, they generally can't and stumble when I point out it's just as optional in each.

[–] owenfromcanada@lemmy.world 5 points 10 months ago

Yeah, I get where they're coming from--in typical use cases, C is often used with static allocation (correlated with minimal/embedded devices) while C++ is often used with dynamic allocation (correlated with enterprise/GUI applications).

Of course you can use either for either purpose, but that pattern seems more common. That being said, I'd be concerned with applicants who don't understand that.

[–] Scrath@lemmy.dbzer0.com 3 points 10 months ago

Can you give some examples of what you consider to be the issues?

My professor said that C++ embedded compilers used to be very buggy but have matured quite a lot as of ~10 years ago while C was stable a lot longer.

Another thing I could think of is the language complexity causing higher resource usage, e.g. by including large libraries though I'm not sure about that since most of the unused stuff should theoretically get optimized out.

I guess if you don't know roughly how the internals of some C++ data types work it could cause you to accidentally use dynamic memory allocation when using strings or vectors.

On the other side, C++ style casts provide more safety as compared to C style casts and allows for usage of references instead of raw pointers to make the code generally safer.

[–] itsnotits@lemmy.world 0 points 10 months ago

Joke's* on you