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

Programmer Humor

19817 readers
56 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
[–] [email protected] 11 points 6 months ago (1 children)

Care to share any favourites?

[–] [email protected] 27 points 6 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 13 points 6 months ago* (last edited 6 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.

[–] [email protected] 4 points 6 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.

[–] [email protected] 2 points 6 months ago

Faust bless those who added strtok_s to C11.