Yes, it is a very powerful language and there can be a lot to it, but it shouldn't "terrify" you.
These days, it's generally quite easy to avoid much of its C heritage (including potential security pitfalls) if using the so-called "modern C++" techniques, but the extra power and flexibility is still there if you do ever need it. There are numerous ways of easily avoiding manual memory (or other resource) management, too. The STL and Boost, among numerous other libraries that are out there, offer lots of convenient, high level functionality. The portability of C++ code is often quite excellent, the language and its standard libraries are quite stable, and there are multiple commercial-grade implementations from numerous vendors/projects. You probably won't find anything else that gives you a high degree of performance along with high level abstractions, while also giving you the peace of mind that your code will still compile just fine years or even decades from now.
While it's certainly possible to to overboard and misuse C++ to a point where it causes serious problems, one of the best things about C++ is that it doesn't force you to do that. You generally don't pay for what you don't use, and it's certainly possible to use a very effective subset of the language much as one might use Java or C#, or even Python and JavaScript.
I'd say that C++ is even easier to use than JavaScript is. C++ is much more sensible in so many ways, and nowhere near as quirky or just outright broken in fundamental ways like JavaScript, while also providing at least some type safety and other compile-time checks.
If you want a stable, portable, safe, well-supported language that offers high level functionality without the performance tradeoffs of other languages, then I think that a modern subset of C++ could very well be exactly what you're looking for.
C++ is not safe in the same sense that Rust is. Without the use of "unsafe", Rust is designed to never segfault or have undefined behavior, ever. Even a modern subset of C++ cannot make the same guarantees (consider iterator invalidation, etc.)
I'll gladly use modern C++ techniques and a bit of care, even if that means only getting say 90% or 95% of the safety that Rust potentially offers offers, if it also means that I can get my code written today, and I can trust that it'll still compile unchanged tomorrow, next week, and probably a decade from now.
I think it's great what Rust could potentially offer software developers. But it's still pretty theoretical at this point. The language and standard libraries aren't sufficiently stable enough for serious, long-term use, currently. I hear we may start to see the beginning of such stability at the end of the year, but until it actually happens, Rust isn't very useful, while C++ is.
> and I can trust that it'll still compile unchanged tomorrow, next week, and probably a decade from now.
Given the practical history of C++ implementations, this may be rather optimistic... Though it does seem to be calming down a bit. Unfortunately, my first real work with C++ was with GCC2.96 (the phantom Redhat version of GCC); scarred me for life :)
Long-term stability is not exactly needed for Project Euler solutions, don't you think?
I think you're overreacting here - somebody barely mentions a language and you immediately start praising said language for features not even needed in this particular person use cases.
I doubt that working on small casual programming puzzles is his only use for programming languages. I read his comment as saying that that's merely all he's used Rust for, so far.
Short-term and long-term stability are needed for just about any serious software application or system. They're useful to have even for short scripts that might be reused later on.
And he said he was "terrified" by C++. I explained why he shouldn't be. I'm not sure why you're getting worked up over that.
> I'm not sure why you're getting worked up over that.
I'm not! And I agree with all your points here. It's just that this is not a thread about C++, but about Rust, and about solving small puzzles with it for that matter. Which makes both original mention of being "terrified by C++" and your explanation a bit off-topic. I won't downvote you or anything, I just wanted to point this out.
The language stability of Rust has already reached somewhere similar to Python 2.0: no core features would be removed, so some syntactic changes can occur before 1.0 but that wouldn't invalidate any effort to learn the language before 1.0. Would you say that Python 2.0 is not very useful because it is constantly changing and some features even get removed (albeit quite slowly)?
Yes, it's a big language, but the complexity is at least justifiable, and generally comprehensible.
C++ gives you immense power and a huge range of functionality to choose from, and some of the complexity arises from this. It has a very long history, which also contributes to the complexity. And it's first and foremost a pragmatic language, which of course brings in some complexity in order to deal with the inherent complexity of reality.
If something is seen as "complex" in C++, there's usually a good, or at least understandable, reason for this. You can usually find technical documents or discussion that justify why things are they way that they are, and the reasoning is usually quite sound. And in many cases, it's possible to safely ignore or just not use large portions of the complexity that C++ offers without facing any sort of a penalty or harm.
It's very different from the complexity that languages like JavaScript or PHP bring. The complexity there is usually unjustifiable, and often due to very rushed work, a lack of understanding and poor design, or a lack of care and consistency. They suffer from serious flaws and complexity that were not justified when introduced, and were subsequently not cleaned up or fixed once recognized. They suffer from harmful complexity, while C++ offers beneficial complexity.
If I were to use a word, personally, it might be "daunting" instead of "terrifying" but I have at least some experience with C and manual memory management. In that regard C isn't alien to me, so my perception is a little different from the op.
I don't think the parent post was trying to say C++ was necessarily bad, but the features of C++ being justifiable or not don't really impact my feeling of it being daunting, or terrifying to learn. I could say, with reasonable certainty, that every part of a space shuttle launch probably has a good reason for being there, but the system taken as a whole is still intimidating. It's that C++ is a huge beast and there's just so much there. I haven't gone hard core at looking into C++, but every time I do people start of by saying you need to pick a sane subset of the language to work with, and they all have different views of what is and isn't sane. Add to that the fact that you can do some potentially scary stuff when you're close to the hardware, and I can see why it would be a bit scary.
In my view, the right way to approach that, if I were really trying to learn the language, would be to just pick a guide and go with the assumptions it makes until the reasoning for those assumptions becomes more clear and I can better pick and choose according to my use case. But it's still an intimidating proposition.
I'm also guessing that something like Javascript is less terrifying because of previous experience with dynamic languages. The kind of foot-shooting you do in javascript (because of accidental global scoping, poor equality semantics, or any number of things) at least make sense in the context of having programmed in a dynamic, managed language previously. C and C++ can be pretty scary when everyone talks about manually managing memory or being close to the metal or saying stuff about 'systems programming', which just sounds like crazy voodoo if you don't have a point of comparison.
I think the things your saying are all true. Just trying to offer my perspective as to why, those things being true, a language can still be scary to approach. fwiw
I often find that you need to read a page-long faq (which is an improvement over reading mailing list flame wars over boost vs raw stl vs library-du-jour) to figure out the "right" way to do anything in C++. Now knowing my way around it reasonably well, it's not an issue for me anymore, but not a newcomer.
It's so easy to do it the wrong way, and there's so many examples of badly written or non-idiomatic C++ code strewn all over the internet that a newbie is bound to fall into that trap. This is the same kind of problem I (used to) see with PHP, that it can be fine if you do it all the "right way" and don't do "stupid stuff" but it takes a while to learn what those are. What happens in reality is they google "how to do x", copy paste the code, and modify. Who cares if it's idiomatic or anything.
Yes, it is a very powerful language and there can be a lot to it, but it shouldn't "terrify" you.
These days, it's generally quite easy to avoid much of its C heritage (including potential security pitfalls) if using the so-called "modern C++" techniques, but the extra power and flexibility is still there if you do ever need it. There are numerous ways of easily avoiding manual memory (or other resource) management, too. The STL and Boost, among numerous other libraries that are out there, offer lots of convenient, high level functionality. The portability of C++ code is often quite excellent, the language and its standard libraries are quite stable, and there are multiple commercial-grade implementations from numerous vendors/projects. You probably won't find anything else that gives you a high degree of performance along with high level abstractions, while also giving you the peace of mind that your code will still compile just fine years or even decades from now.
While it's certainly possible to to overboard and misuse C++ to a point where it causes serious problems, one of the best things about C++ is that it doesn't force you to do that. You generally don't pay for what you don't use, and it's certainly possible to use a very effective subset of the language much as one might use Java or C#, or even Python and JavaScript.
I'd say that C++ is even easier to use than JavaScript is. C++ is much more sensible in so many ways, and nowhere near as quirky or just outright broken in fundamental ways like JavaScript, while also providing at least some type safety and other compile-time checks.
If you want a stable, portable, safe, well-supported language that offers high level functionality without the performance tradeoffs of other languages, then I think that a modern subset of C++ could very well be exactly what you're looking for.