Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've learned 15+ years ago, and I stopped paying attention around ~2010, which is just before significant changes were made. Even though I read up on some features and concepts from C++11 and C++14, I feel so disconnected from what's going on as if what I learned was a completely different language.

Can anyone recommend any source for someone with lots of pre-C++11 experience to get up to speed with current capabilities, and the current community?

EDIT: Thanks everyone for the suggestions!

EDIT2: I skimmed Anthony Calandra's list, and most of the new features seem indeed just cute, but not fundamental changes. Still, I want to reiterate the worry I expressed downthread: how much did the underlying semantics, the idioms, and the general way of thinking change?



I've been in the same boat--relearning C++ after using C++98(!) for a long time. My first go-to book was _A Tour of C++_ , 2e by Stroustrup. Also _Effective Modern C++_ by Scott Meyers (of _Effective C++_ fame).

Other books I've been reading: _C++ 17 The Complete Guide_ by Josuttis _C++ 17 in Detail_ by Filipek

Lots of good blogs out there. Also the CPP Podcast. http://cppcast.com/

There are also a lot of great blogs covering new features. Also


More of a meta-comment, but the underscores you used to presumably get markdown italics should actually be asterisks on HN. Normally it doesn't make a readability difference but trying to parse the book names from your post was a tad mentally painful. Took me a little while to realize the asterisk v. underscore thing so I thought I'd pass it on.

Note: I do wish HN would adopt standard markdown


Oops. Sorry. I had completely forgotten HN markdown. I usually use the underscores around book titles with cleartext in mind. I'll remember asterisk in the future.


> I'll remember asterisk in the future.

Aaand you've just learned all the formatting HN has :). That, and URLs automatically turn into clickable everywhere except the body of a self-submission (i.e. submitting a text instead of a link). Any other formatting here is just convention.


_Thank you!_


I used to swear by Meyers in my old C++ days; his Effective C++ and More Effective C++ were my favorite software books. But recently, in the course of catching up with modern C++, I got the impression his ideas aren't considered good in the current community anymore. Can anyone comment on that?


Interestingly Meyers is now a "retired C++ expert". He says he can't keep up anymore with the current C++ standard development to properly maintain errata for his books.

http://scottmeyers.blogspot.com/


I'll second A Tour of C++ 2e. It's a great way to get up to speed on the most important aspects of C++. It's very readable if you're already familiar with C syntax style languages.


Still learning myself, but this seemed really good when I came across it a year or so ago:

https://github.com/AnthonyCalandra/modern-cpp-features/blob/...


https://en.cppreference.com/

If you already know the language flow control you don't need to read paragraphs of a book to relearn to how "think" in the language. You just need the "whats new" parts.


I'm not confident how deep the impact of the new features is on thinking in the language. I can learn the new features, but I fear I'll still be essentially writing C++03 with C++17 bells & whistles. Did the semantics and idioms change much?

(I hear the compile times are the same though -.-)


The Abseil C++ "Tip of the Week" posts are really good, but not comprehensive: https://abseil.io/tips/


I like the Modern C++ Programming Cookbook, since you have small recipes demonstrating the new features.


Just read this and you will be just fine: https://github.com/AnthonyCalandra/modern-cpp-features


> I've learned 15+ years ago, and I stopped paying attention around ~2010, which is just before significant changes were made.

Which probably means that someone who learned modern C++ will have significant difficulty with older C++.

Sometimes it makes me wonder if someone should just declare a subset of C++ as "good" and call it a new language.


There's nothing really fundamental to the changes in C++11 and beyond: There are lots of little tweaks, as well as some deprecations and outright removals. However, there's the prevailing sense in the community that the many tweaks together genuinely change the flavour of the language, at least from the perspective of traditional C++ development.

The combination of "auto" (plus template type inference), ranged for-loops, initializer lists, structured bindings, lambdas and certain new standard library mechanisms (std::unique_ptr, std::variant, std::optional, std::move, etc.) together change the high-level expressiveness of the language, encoding a lot of common patterns and eliminating common, redundant code. For example:

  std::vector values = {1, 2, 3};
  for (auto v : values) { ... }
New for loops support structured bindings:

  for (auto &&[key, value] : mapOfStuff) { ... }
There's a lot of little conveniences, such as the ability to define a default constructor, or accept a initializer list in the constructor:

  struct Foo {
    Foo(std::initializer_list<int> values) { ... }
  }

  Foo f = {1, 2, 3};
or indeed named initializers:

  struct Person {
    string name
  }
  Person p = {.name = "bob"};
The forthcoming range library in C++20 also finally make lazy sequence iteration functional and composable, e.g. something like (off the top of my head):

  getNumbers()
    | view::filter([](int a, int b) { return a > b; }
    | view::reverse()
    | view::take(10);
Another big change that's coming is concepts, which are somewhat similar to Rust traits or Haskell typeclasses: The ability to put compile-time constraints on template arguments. For example, in classical C++, invalid template invocations generate notoriously bad error messages, since templates are only compiled once they have been expanded with their arguments:

  template <typename T>
    T add100(T v) {
      // Compiler will fail on this line:
      return v + 100;  
    }

  auto n = add100("hello world");
Concepts will let you constrain T to something that actually supports the operations you need:

  template <Incrementable T>
    T add100(T v) {
      return v + 100;
    }

  // Compiler fails on this line:
  auto n = add100("hello world");
Then there's the contract spec, which adds support for Eiffel-type contracts.

Lastly, C++ designers seem to have thought a lot about safe memory semantics, and so there's a renewed focus on smart pointers (that actually work) together with move semantics and tightening of cop constructor semantics. The end result is that it's generally easier to work with RAII and avoid explicit heap allocation with the "new" keyword.


Wow, thanks for the detailed description! I guess I'll have to think a bit about each new feature from C++11, 14 and 17, and then Google some more, to understand the full implications.


Do let us know if you find any kind of "summary for old C++ devs". I agree that such a document would be super useful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: