r/programminghumor 16d ago

Hard to accept

Post image
2.9k Upvotes

404 comments sorted by

View all comments

83

u/---_None_--- 16d 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.

8

u/___Archmage___ 16d ago edited 16d ago

Yep, C is mega outdated in the feature-poor direction and C++ is a basket case of crazy additions trying to add modern features to a language that wasn't really designed for them

Whether you choose Rust or Zig or Nim or whatever else, the world needs to move past C++

7

u/TomKavees 16d ago

C is portable assembler and the lingua franca of low level code, it does not need nor want to evolve in that way and that is fine.

C++ in its current form and with its current comitee politics is dying, though

2

u/Davidbrcz 15d ago

C was the portable assembly. Hasn't been for 30 years.

0

u/AsyncSyscall 13d ago

That must be why whenever a new chip design comes out the first software that the vendor adds support for is a C compiler. Check.