this post was submitted on 08 Jun 2024
1060 points (98.5% liked)

Programmer Humor

19623 readers
1 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] hark@lemmy.world 88 points 5 months ago (3 children)

The graph goes up for me when I find my comfortable little subset of C++ but goes back down when I encounter other people's comfortable little subset of C++ or when I find/remember another footgun I didn't know/forgot about.

[–] LANIK2000@lemmy.world 42 points 5 months ago* (last edited 5 months ago)

That's one thing that always shocks me. You can have two people writing C++ and have them both not understand what the other is writing. C++ has soo many random and contradictory design patterns, that two people can literally use it as if it were 2 separate languages.

[–] henfredemars@infosec.pub 34 points 5 months ago (1 children)

When I became a team leader at my last job, my first priority was making a list of parts of the language we must never use because of our high reliability requirement.

[–] brisk@aussie.zone 10 points 5 months ago (1 children)

Care to share any favourites?

[–] henfredemars@infosec.pub 26 points 5 months ago (2 children)

strtok is a worst offender that comes to mind. Global state. Pretty much just waiting to bite you in the ass and it did, multiple times.

[–] mormegil@programming.dev 12 points 5 months ago* (last edited 5 months ago) (1 children)

Sure, strtok is a terrible misfeature, a relic of ancient times, but it's plainly the heritage of C, not C++ (just like e.g. strcpy). The C++ problems are things like braced initialization list having different meaning depending on the set of available constructors, or the significantly non-zero cost of various abstractions, caused by strange backward-compatible limitations of the standard/ABI definitions, or the distinctness of vector<bool> etc.

[–] henfredemars@infosec.pub 3 points 5 months ago

No you are right! Honestly it was several years ago and I struggled to remember exactly what I came up with before I left.

In our application we for example never use dynamic memory allocation. It has to be done very carefully so we don’t crash. Problem is there’s lots of sneaky ways one can accidentally do it from the standard library.

[–] uis@lemm.ee 2 points 5 months ago

Faust bless those who added strtok_s to C11.

[–] ChaoticNeutralCzech@feddit.de 17 points 5 months ago (3 children)

my comfortable little subset of C++

I also have one. I call it "C"

[–] hark@lemmy.world 5 points 5 months ago (1 children)

C is almost the perfect subset for me, but then I miss templates (almost exclusively for defining generic data structures) and automatic cleanup. That's why I'm so interested in Zig with its comptime and defer features.

[–] jas0n@lemmy.world 2 points 5 months ago

You may also like Odin if you haven't already started zig. It's less of a learning curve and feels more like what c should have always been. It has defer and simple generics, but doesn't have the magic of comptime.

[–] grrgyle@slrpnk.net 4 points 5 months ago

This comment smells like unix

[–] uis@lemm.ee 3 points 5 months ago

Damm, C23 has a lot of changes. Some of them are really good, some of them I strongly dislike(keyword auto, addition of nullptr).