6 ms·
The trouble with "Modern C++" is that nothing gets deleted from "Classic C++". Too much legacy code. They're trying to compete with Rust while remaining backwa
by Animats 4y ago
The trouble with "Modern C++" is that nothing gets deleted from "Classic C++". Too much legacy code. They're trying to compete with Rust while remaining backwards compatible. That generates so many special cases that you need a 1300 page book. Learn to embrace the pain.
And yet converting code to Rust is hard. It is very tough to convert object-oriented C++ code to Rust. The models are too different.
- Sakos 4y agoUnfortunately, the real world often gives us constraints that we can't change and we have to work around. We should absolutely use Rust or other "safer" languages where we can. But if we can't, for whatever reason, it makes sense to try to make the best of the hand we're dealt. That means regardless of what new developments are made in other languages, it's necessary to figure out how to use existing tools/languages like C++ safely.
- arinlen 4y ago> The trouble with "Modern C++" is that nothing gets deleted from "Classic C++". This is not exactly true. For example, with the introduction of smart pointers, manual memory management is kicked out of C++'s happy path. This makes code far simpler to reason about and safer. Sure, you can still use new and delete, but since C++11 you better have a very good reason to use those. Nevertheless, it doesn't make sense to complain about not deleting stuff from C++ when a) until recently C++ was repeatedly criticized for having an extremely spartan standard library, b) since C++98 basic features were added to C++ such as support for parallel and concurrent programming, c) there is no feature that gathers anything resembling a consensus on beig worth taking out of the standard. I'd add that pseudo-standard libraries for C++, such as Boost and POCO, have been popping up and growing in both scope and adoption. This reflects a clear need felt by the C++ community to increase the scope of it's standard components.
- Animats 4y agoThere are too many APIs that still want raw pointers.
- arinlen 4y ago> There are too many APIs that still want raw pointers. Irrelevant. C++'s smart pointers deal with ownership and life cycle management. You can still pass raw pointers to objects managed by a smart pointers. The only exception is when you're dealing with a framework which already handles life cycle management, such as Qt. Nevertheless, even Qt offers its own smart pointers suite.
- UncleMeat 4y ago> You can still pass raw pointers to objects managed by a smart pointers. Not if the API is taking ownership and you want your program to be correct. This happens far more often than dealing with something like Qt.
- rtpg 4y agoIf the API takes ownership, can't you just release the smart pointer, effectively forgetting about it and letting the new owner deal with it? Maybe I'm missing somethign.
- UncleMeat 4y agoThat means it is no longer managed by a smart pointer and you need to understand the nature of the API. I understood the above comment to mean that you can just solve problems by calling "get" and moving on with your life.
- cjaybo 4y agoEven if they want to take ownership, smart pointers allow the semantics to be expressed clearly and in a safe manner.
- Koshkin 4y agoThere's nothing wrong with using a raw pointer as an argument of a function. In this context this is usually equivalent to using a reference. What is wrong, in fact, is passing, instead, a unique pointer (by reference, necessarily) or, even worse, a shared pointer (by value) when there is no need for sharing.
- oncewas 4y agoOutside of the happy path doesn't mean, inaccessible or uncommonly used. C++ is on track to be a composition of ten languages by 2030. I'm not against that in general, it's kind of liberating, but at some point in time I hope someone does decide to do some house keeping.
- pjmlp 4y agoNot when it is COM-oriented C++ code, which is based on interface (aka traits) inheritance, or the IPC mechanisms used on Android/Fuchsia.
- ncmncm 4y agoAnybody still coding to COM has asked for all the pain they experience.
- pjmlp 4y agoReality check, the OS used by 80% of the world for desktop workloads uses COM as the main userspace API since 2007. Classical Win32 C APIs are for all practical purposes frozen since Windows XP. And the answer you practical won't like, when not using COM directly, the advised way from Microsoft is to make use of .NET bindings for the OS APIs, either via C++/CLI, or the new kid in town, C++/WinRT as Windows Runtime Component. Even if you don't use Windows as desktop, the other desktop contenders, also use COM like APIs on their driver stack, IO Kit, DriverKit, Treble, and XPC/Binder aren't much different from DCE RPC development experience.
- UmbertoNoEco 4y agoWriting as someone just learning Rust (knowing more C++) I think a comprehensive Rust book would be in that scale too (+1000 pages). > Learn to embrace the pain. Judging by how much I suffered just to try to implement a sqrt function generically I think that is not an exclusive C++ thing. > And yet converting code to Rust is hard. Exactly, that is why many many projects will remain in C++ for a long long time.
- ncmncm 4y agoAll projects in C++ will remain C++ forever. Some projects will be coded in other languages, and stay in those languages. Wherever that language fizzles, the project will too.
- bogeholm 4y agoThree sentences, each with the same thing stated twice - three tautologies.
- ncmncm 4y agoI.e., you did not understand it.
- tialaramex 4y ago> All projects in C++ will remain C++ forever. Anybody who believes this ought to think it an excellent reason to stay away from C++. For actual software projects I mean. Obviously if you want a career writing books (like the one reviewed) or on the conference circuit, or training, or several other prospects, this is great news. C++ is a good language it which to charge somebody $1000 per day plus expenses to tell them what they already knew. But if you actually write software, or worse, if you need software but that isn't really what you actually wanted to do just a necessity like farmers need to know how to drive a tractor, then this ought to put you off. C++ doesn't want to be your best choice, according to ncmncm anyway, it wants to be a trap you fall into and can't get out of. Run away!
- 4y ago
- Koshkin 4y ago> They're trying to compete with Rust I honestly think it's the other way around.
- ncmncm 4y agoYes. Rust needs radically more use not to end up fizzling like myriad languages before it. But its stalwarts are hostile to measures to make it easier for people to pick up, even easy ones that do not alter the language at all. (E.g., allowing a debug build to complete despite borrow complaints.) It takes a special dedication to overcome barriers that most of the people it must attract lack. It was meant to supplant C, but C users, as a rule, are defined by seeing a thousand other languages go by and not jumping. So Rust mostly picks up discontents from other languages, including Java, Go, and, yes, C++. The danger in appealing to discontents is that they are likely to jump ship for the next shiny thing.
- oncewas 4y agoI mean I get what you are saying about how old stuff doesn't have adoption issues. But, rust is a pretty unique paradigm. The safety guarantees it offers aren't found in other languages without garbage collectors. Rust is boring and technical. Boring in the "it just works and when it doesn't it's not hard to figure out why" way. You didn't say this, but for others passing by, it would be a mistake to view rust as a "shiny thing". People use it for a reason, barring syntax entirely.
- neutronicus 4y agoThe Rust community is, uh, a little in denial about how similar Rust and C++ are (and how much more similar Rust is to C++ than to C)
- oncewas 4y agoI've talked with people in the rust community about modern c++ being similar to rust. They all agreed and honestly thought it was cool. Maybe 1 out of 50 rust programmers language bash and are ignorant, those people tend to be junior and are trying to learn. Everyone else is cool. That said rust is pretty different from c++. Most people don't compare rust to c because c is so heinously unsafe and rust being the polar opposite. Ironically, rust was indoctrinated as the second supported language to the Linux kernel, alongside C. So they have that in common... I wouldn't make too many assumptions about the rust community, they are pretty nice smart reasonable people who tend to write c/c++ for work...