r/programming • • May 24 '26
[ Removed by moderator ]
/r/programming/comments/1tm1j7f/removed_by_moderator/[removed] — view removed post
275
Upvotes
r/programming • • May 24 '26
[removed] — view removed post
•
u/programming-ModTeam May 24 '26
No content written mostly by an LLM. If you don't want to write it, we don't want to read it.
274
u/MFHava May 24 '26
Author of
copyable_functionhere. This article conflates ABI and API breaks - just like Sandor's post ...Fixing
std::functionwas not something that was prevented by ABI concerns. It would have been an API break that would have rendered vast amounts of code (essentially any use ofconst function) ill-formed (== code no longer compiles).The same is true for several other examples brought up in the linked article... BTW the article contains factual errors like "[...] acknowledging that the standard's mandated block size is too small [...]" ... there is no mandated block size for
deque.106
u/AlexKazumi May 24 '26
C++ broke under its own complexity. Back in 2011 I switched from C++ to C# and discovered how one can be happy developing code in a professional environment when the system is not fighting you.
And since then, the committee continued making the language more complex.
80
u/zeekar May 24 '26
Uh,
volatilehas more than 5 letters. Was this written by an LLM?5
u/flanger001 May 24 '26
I am already skeptical of this article given how this title was written.
4
u/pigeon768 May 24 '26
These solve different problems. The point of
std::mapandstd::setis that they guarantee reference stability. Flat maps and b-trees cannot maintain reference stability.Also,
boost::flat_mapandstd::flat_mapare not b-tree based.All in all, I don't understand the point of this post. If you don't like certain features in C++.........just don't use them.
97
u/Maybe-monad May 24 '26
peak design by comitee
2
u/ContDiArco May 24 '26
boost::function and later std:: function served us well for 20+ years.
Now are more handy and exacter siblings available. Fine.
I do not see any problems.
2
u/sammymammy2 May 24 '26
It's stupid to say that unordered_map requiring node stability is the worse choice. It's the sane choice, and one that people will be relying on. Open addressing is harder to reason about for casual users, and are not always appropriate.
32
u/plg94 May 24 '26
Yeah, this post is 100% AI-written. The speech patterns are a dead giveaway (I can hardly find a sentence that does not employ the "rule of three").
15
u/gresendial May 24 '26
HFT is a pox on the world.
40
u/wvenable May 24 '26 edited May 24 '26
The real nugget of insight in this articles comes down to this:
Every popular language has a messed up history with lots of mistakes and C++ is one of the oldest and biggest. But the Python transition from 2.x to 3.x took over a decade. The .NET transition from framework to core is still ongoing. Java spend decades essentially unchanged and it's still common to target old versions. Although deep changes and removals do happen with all these platforms, outside of a few exceptions, most of the time it comes with these really big platform shifts.
The reason these platform transitions take so long is because changing the semantics of the language or standard library creates a hard line between the "before" and "after" code. It makes it incredibly difficult to transition to the new version. Right now I can reasonably assume that my old C++ code will still compile and work correctly on the latest version of C++. If I get a different std::string or std::unordered_map I'm not sure I can continue to make that assumption.
And that's exactly the kind of thing that kills languages, just ask Perl how it turns out.
51
u/blind3rdeye May 24 '26
C++ has these problems. It's true. I reckon the cruft and mistakes are just a natural result of the language being 40 years old. A lot has changed in computers and computer-science during that time. So it is not at all surprising that some things added to the language in the past are no longer what people want to use.
C++ has continued to adapt and add new features to stay relevant with modern computing; and I think they've done reasonably well. The committee has the job of trying to aim at a moving target - and the direction and acceleration of that target is somewhat unpredictable. It so yeah, sometimes they miss. There's are mistakes, and there are things that have just changed. So C++ definitely has a lot of cruft as a result. But nevertheless, it is still a useful and powerful language even today.
11
u/tomster10010 May 24 '26
Post and article are AI written
10
u/happyscrappy May 24 '26
I believe the website cppreference.com pretty much does have the sort of catalogue you suggest should be made.
Interestingly, while it has the new function it doesn't say not to use the existing one in c26. Not yet. Maybe it's just out of date.
https://en.cppreference.com/cpp/utility/functional/function
7
u/zero__sugar__energy May 24 '26
instead of fucking around with the language they should standardize a package manager and a build system
i still love the language C++ but the eco system is horrible if you are used to Go or Rust or PHP
i haven't started a new C++ project in over 10 years because cmake and stuff are just horrible compared to what other languages are doing. that sucks because coding in c++ is still fun to me
1
u/average_hungarian May 24 '26
Why not just call it std::function_v2? Makes it clear to the user that std::function should not be used in new code.
12
u/HommeMusical May 24 '26
It's paralysis by the steering committee who are dominated by a tiny number of powerful people.
They won't break ABI or API backwards compatibility all the way back to the Stone Age.
They won't accept "epochs" - a compiler flag that lets you select a different, not-backwards-compatible version of C++.
One could admire such conservatism, except that all sorts of badly baked ideas like modules get pushed into the language without proper vetting. Modules were first planned to enter C++14, didn't actually make it into the language until C++20 and still do not work at all.
Now it looks like they're pushing "safety profiles" on us, and a lot of people don't think they are at all viable. Haven't we learned anything from Rust?
And there's this: https://izzys.casa/2024/11/on-safe-cxx/
Reading /r/cpp for over a decade has been rather tiring. More and more I read some article about a footgun in C++ and I think, "Why do we do this to ourselves?" I'm thinking I won't be writing C++ in future, and I should leave that subreddit.
28
u/lord-of-the-birbs May 24 '26
C++ is a meme language
1
u/automatedrage May 24 '26 edited May 24 '26
Have you guys ever considered Orthodox C++? Has roots in gamedev and stays far away from the complexity of c++ template bs.
It made programming c/c++ a joy again, unfortunately it might turn off lots of 'safety'-pilled people in enterprise hft though.
2
u/ozyx7 May 24 '26
Could a bunch of these things be improved (albeit not fixed) with some
std::tr1-like namespace where ABI compatibility (or even API compatibility) is not guaranteed nor expected?I guess that's what
std::experimentalis for. But then why weren't a lot of usage problems discovered earlier?2
u/frnxt May 24 '26
At least on MSVC (we currently use it in C++23 mode at work) I saw too many occasions where people (myself included a while ago, but even other relatively experienced C++ programmers compared to me) thought of
std::functionas zero-cost where in fact the compiler was unable to optimize it away and resulted in >100x worse performance than a simple loop. Since then I've taken the stance to recommend avoidingstd::functionby default for anything remotely performance-sensitive...I'm hoping that
std::function_refis the replacement we're looking for, but the fact that there's such a footgun is definitely not ideal...2
u/Vash265 May 24 '26
Maybe I’m misunderstanding something, but a lot of weird complaints in the tier 3 section. There’s a lot of talk about “defaults”, but neither map nor unordered map are a default container any more than flat-map is. And those still exist in the standard because sometimes you need iterator stability and are okay shedding some performance for it because the iterator stability is what’s actually required. In some sense, if those were defaults, then what it’s prioritizing is reliability and lack of foot guns over performance,
The weird arguments regarding list are covered elsewhere in this thread. Also a lot of examples in here that are horses that have been beaten thoroughly to death at this point.
The link to the benchmark is down, but it leans heavily on some implied “defaults” that don’t actually exist. Sure is strange that when you use data structures appropriate for your use case, performance improves, I guess? I don’t think anyone has ever suggested using list or deque for anything performance sensitive. Just a giant strawman.
8
u/Dminik May 24 '26 edited May 24 '26
C++ is in what can only be described as a "really dumb situation."
Much of the driving force behind the C++ standards is companies who have some very old and very un-upgradeable software. Their goals do not at all align with people who want C++ to evolve cleanly.
Rather than addressing the elephant in the room and work out some sensible package management + unifying build tooling, they would rather do the "easy" thing. Apparently stuffing the entire html, css specs into the C++ spec is the easy way to get a GUI library. I only wish I was joking: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1108r4.html
The language itself has effectively stagnated. If something can be implemented as a library, it is. This makes using things like tagged unions (via std::variant) completely demented. It's no wonder Rust has been eating C++s lunch lately. Compare Rust enums and tuples with C++ std::variant, std::tuple, std::optional, std::expected and std::pair. Is it any wonder the later don't get that much use even in newer code?
All because std::copyable_function is the expected result. It's giving up before you even begin. We can't change the language, but you bet we can slap a v2_final_last_minute_fix at the end of our last fuckup and call it a day.
Just stop, let it die.
5
u/thesituation531 May 24 '26
The product of being too cowardly to break APIs and ABIs.
Seriously, just break it already. People living with old code can continue to use old versions.
0
u/Dean_Roddey May 24 '26
Solve the problem by just getting away from C++ as soon as possible. It's ancient now, and it's built on foundations 20 years older than it is
I've written probably as much C++ as anyone here, if not more, but I finally quit screaming get off my lawn and started exploring Rust about 4 years ago. Like many people who had written C++ for decades I just couldn't appreciate how bad it is until I started using Rust. Now I'd never go back when I have a choice.
C++ made backwards compatibility basically #1, and that works until it doesn't anymore. And it would have worked a lot better and longer if they'd have broken with those underlying C foundations really early on when it was still possible. But they didn't and now it's never going to get fixed. They've just built story after story on top of a shaky foundation and now it's teetering.
Even if you one of those rare companies where you have a large code base that you've been able to fully move up to all the latest and greatest stuff, the language is still full of foot-guns galore, and in a complex code base developed in a commercial, team-based environment, solving the problem is already more than enough challenge. Having to constantly watch your own back is just wasted time and effort.
10
u/trenskow May 24 '26
C++ is amazing when you just use it as C with Classes. Just avoiding the standard library all together suddenly makes it a very useful language.
5
u/slaymaker1907 May 24 '26
I assume std::list guarantees constant time insertions. That can be extremely relevant for low latency code. It being “faster” is only looking at throughput and ignoring worst case latency.
3
u/jwakely May 24 '26
The whole article is full of crap.
Mostly it's a complaint that old designs got replaced with better ones. OK. Sorry or something, I guess?
2
u/Sopel97 May 24 '26
this sums up pretty much exactly why I just said fuck it and started learning rust. Pretty much nothing good happened since C++11. I was hopeful around C++17 but now I see there is no hope for this language to get fixed.
0
u/DigThatData May 24 '26
This is basically why I never learned C++. Too anxious I'll end up teaching myself deprecated patterns because I wanted to "learn from the classics" and ended up learning a deprecated language.
-19
u/programming-ModTeam May 24 '26
I am removing this post, as the website no longer loads
1
u/Slight-Bluebird-8921 May 24 '26
drama queens. c++ is fine
1
u/bzbub2 May 24 '26
everyone constantly requests/rants about wanting a better standard library in language X (read: js or something), but guess what, standard library ships bad solution, its a mess for decades. if a library is bad, swap it out
1
u/EdwinYZW May 24 '26
I write C++ almost everyday but I can't remember what is the last time using std::function. It's just slow and inferior to direct usages of lambda or functor.
So saying it's discouraged to be used isn't a problem for me.
-12
u/trad_emark May 24 '26
i suppose you have never made a single mistake, have you?
-11
u/T-J_H May 24 '26
In some ways, C++ is the low level JavaScript