3 ms·
Speaking as a professional C++ developer for the past 20 years, I think this sums it up well. A modern project should be able to use most of C++17 at least. Ev
by TillE 4y ago
Speaking as a professional C++ developer for the past 20 years, I think this sums it up well.
A modern project should be able to use most of C++17 at least. Even if you still need to target some ancient garbage like Windows XP, you can use an MSVC toolchain that supports C++17. That's a good basis to work from.
So your real concern is the moldy old code that's written for C++03, that's still not using std::unique_ptr or anything equivalent. If you're given license to finally rewrite that code to modern standards, that can be fun if it's not a complete mess. But if you just have to live with it, and still write C++03, absolutely not, I would never do that job.
- steve918 4y agoIf C++03 is old code then you're in one of the outer circles. The code base I'm working on has "Old style" C function declarations that predate C89.
- mort96 4y agoDo we have a reason to believe the code base you're working on is representative or is it just an anecdote?
- rizzaxc 4y agodo you have a good template (pun intended) on how to best learn modern c++? coming from Go and Typescript which have very mature devX tooling, c++ is a landmine to navigate. and that's when I already have professional experience with it (the place just didn't have strong c++ culture)
- olvy0 4y agoTry watching the "back to basics" videos from the last 4 years' cppcons. But that's mostly learning modern paradigms of the language. If you also mean the tooling, then it depends: Learn CMake which is sort of an industry standard. There are books and videos, but for a concrete experience, try looking through the CMakeLists.txt of some non-trivial C++ open source project.
- dummydummy1234 4y agoWith regards to CMake, look at professional CMake by Craig Scott. Probably the best resource for CMake modern best practices/ rational of those practices. Most tutorials online are outdated, CMake documentation is hard without a firm mental model of how it works.
- boppo1 4y ago>CMakeLists.txt You say that like there's one for a project but I've been learning Blender's codebase and every folder has a CMakeLists.txt. What gives?
- devnullbrain 4y agoModernes C++ & Scott Meyers' 'Effective Modern C++' are excellent.
- dummydummy1234 4y agoMake sure you have a good linting/static analysis setup. Use clangd, clang-tidy, cppcheck. (These will tell at you if not using best practices) Use the stl as much as possible (or at least make "would this work using stl" your go-to question. Write a vector with iterators from scratch in c++20
- bluGill 4y agoI have license to any one C++03 area to C++14 (and I have my own implementation of optional that I'm allowed to use when until C++17 is available). However I can only do a few of them so I need to target where. If C++03 code has been working great for years and isn't broke, why would I break it?
- lelanthran 4y ago> If you're given license to finally rewrite that [C++03] code to modern standards Then you aren't choosing C++20-something, you're choosing a new language altogether. This is why the demand for C++ devs is dropping - if you're going to bite the bullet and rewrite, why not choose a better language, preferably with GC?
- trinovantes 4y agoThey probably want the performance of C++ without the learning curve of Rust It's not like C++20 is completely different. There's just a lot more utilities in the stdlib so hopefully less raw pointer magic.
- Shorel 4y agoD-lang exists.
- lelanthran 4y ago> It's not like C++20 is completely different. There's just a lot more utilities in the stdlib so hopefully less raw pointer magic. What was best practice for C++03 is not the same for C++20. Switching a codebase from C++03 to C++20 for a nontrivial codebase means changing design so radically it may as well be a new project, rewritten from scratch. It'd certainly be easier to rewrite in C++20 for the C++03 projects I've recently worked on, than to try to squash in a C++20 design.
- zozbot234 4y agoWhat learning curve? Rust is easier than C++, and a whole lot easier than C++20 further extended with modern safety guidelines.
- menaerus 4y agoRight, "easier" as in: - Immature compiler susceptible to generating performance traps - Build times even longer than the infamous ones in C++ - Simplistic declarative-based build system - Inability to opt-in or to opt-out from static analysis - Harder to scratch up quick PoCs because borrow-checker - More complicated compilation model making it harder to understand, debug and implement workarounds when codegen goes south - Much smaller ecosystem - libraries, toolchains, tools, ... - False sense of security - by default it relies on the ecosystem whose runtime and its OS is implemented in "unsafe" languages - Cannot even live to its "safety" promise because hardest problems cannot be solved without unsafe sections I sincerely wish it was different but at this moment I am not convinced that Rust trade-offs are worth switching to it. This is the PoV coming from a system-level programming, very close to the OS, and with a lot of difficult memory and concurrency scaling issues.