Ask HN: Is A Tour of C++ the best way to learn c++?

6 points by iudqnolq ↗ HN
I know Rust, but after hitting my head against a wall trying to generate Rust bindings for a templated c++ library[1] I realized I should just write this part of my project in c++.

My current plan is to read through Stroustrup's A Tour of C++, then start working on my project. When I encounter issues I'll look the topic up in Stroustrup's The C++ Programming Language.

I'm hoping someone with relevant experience can tell me if this is a decent plan, and if there's a better or faster way to learn enough C++ to write a small program that calls such a library.

[1]: https://github.com/mapnik/mapnik

4 comments

[ 2.7 ms ] story [ 22.9 ms ] thread
It's fine, you'll only get so far with a book anyway. It's a good idea to get the book phase out of the way as soon as possible and A Tour of C++ is a fine way to do it.
Learning C++ is a big endeavor, I think you first need to think about what you want to achieve. As I read it, I think it would be easier to just write a little simple Cpp class layer or even rather simple functional C API on top of the functionality you need from the templated lib, and then bind that to Rust. For those bindings, you can find more easily simple examples. Saves you entering a big rabbit hole, the hassle of needing to know about many cpp aspects, they are plentiful.
That's close to my plan, but I quickly realized I needed to rigorously learn a minimum amount of cpp to write that layer correctly. I've never bound to this templated and complex a cpp library before.

(My exact plan is to expose a tiny API with very straightforward data structures. I'll then write simple Rust bindings to that. I need web and native. I've explored enough to think that compiling the cpp to a wasm module via emscripten and then manually writing Rust to call functions in a different wasm module should be feasible)

Is there a good guide for writing Rust-like C++, e.g. using stuff in the recent standards to avoid the many footguns?