3 ms·
Ask HN: Is C++ making a comeback? “modern C++” versus Golang/Rust/Zig/Nim/D?
I'm hearing the term "modern C++" bandied about.
I'm guessing it means "C++ has evolved to something worth considering versus more modern languages".
What do you think? Given a real world project, what might lead you to use modern C++ instead of Golang, Zig, Rust etc?
Or is C++ too old and dusty despite its updates?
Some references:
"Welcome back to C++ - Modern C++" https://learn.microsoft.com/en-us/cpp/cpp/welcome-back-to-cpp-modern-cpp?view=msvc-170
"21 New Features of Modern C++ to Use in Your Project" http://www.vishalchovatiya.com/21-new-features-of-modern-cpp-to-use-in-your-project/
"What is modern C++"? https://www.reddit.com/r/cpp_questions/comments/tgs6ir/what_is_modern_c/
"C++ is the next C++" https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2657r0.html
"modern c++ features"
https://github.com/AnthonyCalandra/modern-cpp-features
C++ 23 to introduce module support "https://www.infoworld.com/article/3662808/c-plus-plus-23-to-introduce-module-support.html"
"C++ 2023" https://en.wikipedia.org/wiki/C%2B%2B23
- andrewstuart 4y agoclickable: "Welcome back to C++ - Modern C++" https://learn.microsoft.com/en-us/cpp/cpp/welcome-back-to-cpp-modern-cpp?view=msvc-170 https://learn.microsoft.com/en-us/cpp/cpp/welcome-back-to-cp... "21 New Features of Modern C++ to Use in Your Project" http://www.vishalchovatiya.com/21-new-features-of-modern-cpp-to-use-in-your-project/ http://www.vishalchovatiya.com/21-new-features-of-modern-cpp... "What is modern C++"? https://www.reddit.com/r/cpp_questions/comments/tgs6ir/what_is_modern_c/ https://www.reddit.com/r/cpp_questions/comments/tgs6ir/what_... "C++ is the next C++" https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2657r0.html https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p26... "modern c++ features" https://github.com/AnthonyCalandra/modern-cpp-features https://github.com/AnthonyCalandra/modern-cpp-features C++ 23 to introduce module support "https://www.infoworld.com/article/3662808/c-plus-plus-23-to-introduce-module-support.html https://www.infoworld.com/article/3662808/c-plus-plus-23-to-..." "C++ 2023" https://en.wikipedia.org/wiki/C%2B%2B23 https://en.wikipedia.org/wiki/C%2B%2B23
- steveklabnik 4y ago“Modern C++” is a term that’s over a decade old; it was first used to describe improvements brought in C++11. That said from an outsider perspective it seems that there’s no clear universal definition. Which is totally fine! It’s just more of a vibes-based term than a strict one.
- andrewstuart 4y agoTrue, it's an old tag but I guess I'm drawing attention to the fact that lately it seems to be a term getting some traction. Perhaps C++ has accumulated enough change to really make it worth a look.
- thesuperbigfrog 4y ago>> Perhaps C++ has accumulated enough change to really make it worth a look. If you have not used C++ since before C++ 11, then yes, there are substantial changes. From C++ 11, 14, 17 and onward there are lots of changes, but it's more incremental.
- Bostonian 4y agoThe same could be said of "Modern Fortran", which could refer to any Fortran standard from 1990 on.
- Rochus 4y ago> it was first used to describe improvements brought in C++11. No, it was first used by Stroustrup himself for C++98/03, see https://www.stroustrup.com/DnE2005.pdf https://www.stroustrup.com/DnE2005.pdf.
- steveklabnik 4y agoAh ha, thank you! I wasn't sure if 03/11 was actually true, so I did some googling, and 11 seemed to be the consensus. I will update that fact in my brain, thanks again.
- Rochus 4y agoPeople often don't realize that C++11 only brought syntactic sugar. Even unique pointers and move semantics can also be done in C++03, as e.g. demonstrated by Boost.Move. So if people insist that "modern C++" started with C++11, they actually claim that it was the syntactic sugar which made C++ "modern".
- thesuperbigfrog 4y ago>> Is C++ making a comeback? It has not gone anywhere. C++ has slowly been losing some marketshare to Java and C# (late 90s and 00s) and more recently Rust (late 10s and early 20s / present), but the majority of C++ is still where it has been for decades.
- andrewstuart 4y agoIt's interesting that there is async/await in C++ now. I don't like the idea that it is thread based - part of what makes async/await fast in other languages is that it is NOT thread based. Here's an example from ChatGPT (not checked for correctness) int main() { // Define an asynchronous task that returns a string auto my_task = []() -> std::string { return "Hello, world!"; }; // Call the task using async and wait for the result auto future_result = std::async(std::launch::async, my_task); std::string result = future_result.get(); // Print the result std::cout << result << std::endl; return 0; } "In this example, we define an asynchronous task using a lambda function. The lambda function returns a string, but since it is an asynchronous task, it is executed in a separate thread. Next, we use the std::async function to execute the task asynchronously. The std::async function takes two arguments: the launch policy and the function to execute. In this example, we use the std::launch::async policy to launch the function in a new thread. The std::async function returns a std::future object, which represents the result of the asynchronous operation. Finally, we use the get method of the std::future object to wait for the result of the asynchronous operation. The get method blocks the calling thread until the asynchronous operation is complete and the result is available."
- nathants 4y agoi just started working with c++17 in clion ide and i’m having a ton of fun. clion even helps you close over variables in a lambda, which was a delight to discover.
- kosolam 4y agoThe real fun begins when you deploy a release build in production and it occasionally crashes with something related to concurrency and memory management;-)
- Kukumber 4y agomodule could have helped, but unfortunately you still need to predeclare everything, and it doesn't support cyclic references, they built modules on top of decades of dated architecture, that was a mistake, they should have took the opportunity to do better to be future proof