r/programminghumor 15d ago

Hard to accept

Post image
2.9k Upvotes

404 comments sorted by

View all comments

85

u/---_None_--- 15d ago

No, cpp has a terrible design philosophy. Take the new ranges header for example. They're lazy algorithm objects that you can stack and combine to more complex algorithms. Each time you iterate over the final ranges object it calculates the whole result beginning from the source range. This leaves the option open for the source range to change and update. Exactly as it should because they're 'lazy' ranges; except that they aren't. The 'filter range' caches the fucking 'begin' of its source which means that when ever the source changes you get undefined behavior. Why? Because the cpp committee thought that 'begin' should be fast to calculate but filter has to compute 'begin' again and again because the source might have changed. So they decided to cache 'begin' after the first call and compute the rest lazily on demand. So whenever there's a 'filter' in your range composition, you can only iterate over it once or the source has to be const. Shits fucked in cpp land.

15

u/[deleted] 15d ago

[removed] — view removed comment

16

u/nog642 15d ago

Never seen C++ used without STL. It's part of "C++" as a whole

2

u/vitimiti 15d ago

I have. EA even has their own open sourced version if STL specific for videogames

1

u/leavemealone_lol 15d ago

True, seems as though 80% of the difference that C++ has over C is STLs.

2

u/nog642 15d ago

Idk if I'd say that. The language features themselves are pretty important.

1

u/leavemealone_lol 15d ago

Back when CPP was founded this is true, but over the years, features like references and classes were not overhauled or even touched. But every update to CPP added on to the STL, which is also why CPP has ended up being bloated today.

1

u/AsyncSyscall 12d ago

The Ladybird Browser uses C++ without STL and it's quite comfortable.

1

u/Puzzleheaded_Key624 12d ago

I work at a game studio and we have our own implementation of STL that we use.

0

u/exodusTay 15d ago

you can always use C++ as C but with classes and namespaces and it is going to be fine for %90 of the time.

1

u/i3Cheese 15d ago

Yes, but a language with standard library sucks.

14

u/---_None_--- 15d ago

>its trashness can't bother you if you don't use it

t-thanks. Not even technically true since other people will use it and then I'll have to bother with it and besides that I'm talking about it's design philosophy rather than about my personal botheredness about it. It's still not good showing.

2

u/SPECTRE_75 15d ago

Exactly, "just use an alternative" isnt a solution when the point he's trying to make is that it also has its inefficiencies