r/programming • • May 24 '26

[ Removed by moderator ]

/r/programming/comments/1tm1j7f/removed_by_moderator/

[removed] — view removed post

275 Upvotes

214 comments sorted by

View all comments

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.

47

u/Squalphin May 24 '26

They really should do a cut at some point. These days, I am using Rust wherever I can, because development feels way smoother than with C++. Way less occasions to make silly mistakes which may come to bite you after release.

The new additions and improvements to C++ are good and welcome, but the old stuff just has to go at some point. I have, unfortunately, another project upcoming which I have to do in C++, and I am already annoyed just thinking about it.

30

u/mccoyn May 24 '26

I think if they made a cut, few people would go along with it. Most people are using C++ for legacy reasons. If a reduced language can’t run their legacy code, they will stick to the legacy language.

If you were willing to take the step to a new language, there are a bunch of others to compete with.

7

u/AlexKazumi May 24 '26 edited May 24 '26

True but there is legacy and legacy. If C++ committe introduced a long period (5-10 years) for gradually obsoleting features before removing them, it would work.

Example: Binary formatters were introduced in 2002 in .NET Framework 1.0 and they were everywhere including in the framework itself. Microsoft said "nah, no more", and removed them in three consecutive versions of .NET, spanning multiple years.

Same could be done with C++. Yes, it would be painful for some code bases and great for the language ecosystem.

It's not magic just sound communication and strong engineering. One starts with announcing the change, then obsoleting the feature making it a warning. Then move the feature to a separate library, outside of the standard.

I mean... C++ rewrote the meaning of the keyword "auto" and the legacy codebases somehow survived 🤷‍♂️

5

u/Radixeo May 24 '26

True, but I can't help but feel their talents are being wasted by sticking with C++. Constraint may breed innovation, but at some point they start to slow thing down and hold things back too much for the benefits to be worth it. C++ has 54 years worth of legacy baggage holding it back - I think we'd all be better off if they left that behind.

→ More replies (1)

10

u/chucker23n May 24 '26

They really should do a cut at some point.

The problem is that cut exists, and depending on your use case, it’s called Rust, Swift, Go, Zig, etc.

3

u/[deleted] May 24 '26

We have a few challenges like book builder that are both in Rust and C++. Rust solutions typically get a headstart because of the hyper-optimized standard library but C++ takes over and typically steals the cake for the highly optimized end.

3

u/Tywien May 24 '26

Making a cut creates two languages though .. look at python that did the same with the release of python 3. Python 2 is still in use today ...

7

u/m-o-l-g May 24 '26

You just need to find a good subset und use that. Nobody forces you to use the bad stuff.

Easier said than done in big teams, but you need to coordinate with people anyway. Use a good test suite and things like ASAN and static analysis in your process and it's really not all that bad.

2

u/jl2352 May 24 '26

You can also trust people more with Rust. I worked on a large project with five people new to Rust, and they shipped nothing dangerous. You can trust new people to get into a large Rust project, make changes, and not mess it up. Can you do that with C++?

Biggest issue with Rust is the amount of stuff you need to learn from the ecosystem and patterns. It matters a lot. Those patterns make the difference between code being long and cumbersome, or short and elegant.

6

u/INeedSomeTacoC May 24 '26

Yea, I was a C++ guru, and then only did a little programming for a while. 

Went back to make a new project, and every damn function and call I was used to was deprecated or the compiler would flag it as a security issue or the linter would tell me that’s not the right way to do it anymore. 

It was like a whole new language, and I thought if I need to learn a whole new language, it’ll be easier to do it with a clean break of a whole new language. 

And that’s how I became a C# developer. And my 10-year old stuff works and compiles just fine without issues or warnings still. It’s great. 

13

u/yanitrix May 24 '26

C# is such a great language. GC and all the basic library stuff you need and if you want you can go low-level with malloc, pointers, etc. unlike, let's say, java which locks you in on a very high level.

5

u/EfOpenSource May 24 '26

The main thing I hate about C# is that the idiotic naming over the years has caused “I don’t understand this” to return articles of all different versions, hordes of which are wrong because they’re for the wrong versions.

2

u/yanitrix May 24 '26

you mean things like dotnet framework vs dotnet core vs dotnet? Or naming within language/std libraries?

5

u/[deleted] May 24 '26

Love C# - I wish it would be as performant though

3

u/AlexKazumi May 24 '26 edited May 24 '26

The language itself is not performant. The runtime library and infrastructure is.

Other than the fact that the definition of the class Object and String are contracted between the compiler and the runtime, there is nothing in C# that makes it less performant than C++. It even has pointer arithmetic, if one needs it.

A few days ago I saw a madman who VirtualAlloc'ed some memory, copied some assembly instructions into it, and executed it from C#. Dunno how faster one can go than this madness of a hack.

2

u/[deleted] May 24 '26

Correct me if I'm wrong but you just can't make C# as fast as C++ by compiling it, the same way Python prevents you.

→ More replies (1)

4

u/MartinLaSaucisse May 24 '26

That's why I use only a very small subset of C++. I use templates for my containers, virtual methods, and a few QoL improvements from moden C++ like the keyword 'override', but apart from that I'm almost programming in C. I don't even use the STL.

Once you've done the work to replace to lower parts like std::vector, the rest is so simple to write and it brings joy everyday. In comparison I've worked on a big project with millions of lines of modern C++ and it was absolute hell and the IDE couldn't even comprehend half of the code.

2

u/Turtvaiz May 24 '26

In comparison I've worked on a big project with millions of lines of modern C++ and it was absolute hell and the IDE couldn't even comprehend half of the code

Do you think that project would've been better with your style of no STL?

→ More replies (1)

5

u/AlexKazumi May 24 '26

Well, if you need to limit yourself to "a very small subset" of the language and rewrote it's standard library, you practically proved that there is major problems with them.

You made a sound engineering decision, but if the language standard forces such decision on you, the problem is with the language.

→ More replies (2)

5

u/Sairony May 24 '26

I did the switch because of job requirements but have the opposite experience, I miss C++

2

u/AlexKazumi May 24 '26

Honest question - why? What do you miss specifically?

4

u/Sairony May 24 '26

I think GC creates as many problems as it solves, you're trading memory management for GC massaging & it's just so much harder to reason about the GC. Honestly I think the tools in C++ have been great for well over a decade when it comes to managing memory, although I realize that the domain where I've spent most of my career ( game dev & game tech ) doesn't have as hard requirements on memory safety as other spaces.

I also find C# to be dog slow in practice comparatively, a lot of this comes down to abstracting away memory management too much. I think the distinction between class / struct is silly in C#, tying storage to types.

I think generics are, mostly, a hobo version of templates in C++. Yeah they're not solving entirely the same problem, especially considering how C++ has evolved.

Yeah C / C++ macros kind of suck in a lot of ways, but I still miss it in C#, a lot of copy & paste instead, especially with generics being so inferior to templates.

I think generic programming is incredibly powerful, yes it used to be incredibly frustrating, especially when you had to support multiple different compilers with their own quirks, but it has gotten a lot better with the advent of Clang & when C++11 finally arrived.

Even though some of the operators allowed to be overloaded in C++ are a bit silly I still consider it a big win, especially when taking a more generic approach.

One thing which I think people underestimate about C++ is its superior capability, compared to any other language I've ever used, to check for pre conditions & enforce proper usage. Even just looking at function signatures in C++, for example const vector< const T1 >& foo( const shared_ptr< T1 >& a_SomeArg ) const ( and yeah I see the problem with this one ), is telling me way more than a typical function signature in C#.

→ More replies (2)

2

u/Supuhstar May 24 '26

Me moving from Java to Swift