Is C++ and Object-Oriented Numeric Computing for Scientists and Engineers by Daoqi Yang still relevant?

I'm looking to learn C++ primarily from a scientific computation perspective. The approach of the textbook seems ideal to me as it covers C++ from first principles with an emphasis on numerical computation.

However, the textbook was published in 2001. Will studying from this textbook teach me methods which are now not recommended or that have been supplanted in newer editions of the language?

• The core of the language is still the same. I think 95% of what you learn from the book will remain unchanged even if there was a newer edition. – Wolfgang Bangerth Mar 27 '20 at 15:15

I agree with Wolfgang's comment that the fundamentals are the same. Nonetheless there are quite a few things that have changed since 2001 and it's a common refrain that C++ is growing very fast, with even some experts saying they can barely keep up. There are two that I think are especially important:

• Smart pointer types like unique pointers have made it mostly unnecessary to ever use raw pointers or call new and delete yourself. Many applications in scientific computing have particularly simple object ownership semantics so this is an absolute lifesaver. Some of these were introduced in 2003 but they became really usable in 2011.
• Template hackery has grown a lot since 2001. I looked at a preview from that book and while it covers templates, at the time it was written many of the commonly available C++ compilers didn't even implement them correctly. Some notable examples:
• optimizing linear algebra operations through expression templates; see Eigen and armadillo.
• deal.II, of which Wolfgang is one of the lead developers, uses templating on the dimension for writing PDE solvers that work regardless of the problem dimension

Once you've learned enough of the basics to feel comfortable reading other people's code, I think you're much better off finding an open-source software library in C++ that tackles some scientific problem you're interested in. Learn how to use it and then start reading their code.

• Good answer! However, raw pointers can and should still be used for optional parameters. – dweber Mar 27 '20 at 18:15
• @dweber -- no, actually, raw pointers are completely pointless and can be completely avoided. A std::unique_ptr or std::shared_ptr can also hold a nullptr if you want to use that as the default for an optional argument. – Wolfgang Bangerth Mar 27 '20 at 23:12
• That's a great answer, by the way. That said, deal.II originated in 1997 and all of the basic template tricks for dimension-independent programming were there already and supported by the compilers I had access to at the time. It is true that template programming has grown substantially since then and may not have been reflected in the 2001 book in question. – Wolfgang Bangerth Mar 27 '20 at 23:13
• Hah and once again showing how many ways you can do the same thing in C++, I disagree with @dweber's comment because you can use std::optional now, or (my personal preference) avoid writing functions with optional parameters at all! – Daniel Shapero Mar 28 '20 at 17:28
• DanielShapero yes, std::optional is also my preference when i have c++17 at hand. But I disagree with @WolfgangBangerth, passing unique_ptr might pass ownership and this is not what might be intended (or what i had in mind). – dweber Mar 28 '20 at 21:43