5 ms·
::Somewhat tangential anecdote and plea for advice:: I just finished my third semester of using C++ (with Data structures 1) and we use NO modern stuff in clas
by zengid 8y ago
::Somewhat tangential anecdote and plea for advice::
I just finished my third semester of using C++ (with Data structures 1) and we use NO modern stuff in class [1]. Raw pointers. New and delete. No Lambdas (although we learned about function pointers, though not function objects). I completely understand why (we're learning low level stuff and it's worked for the last 30 years so whatever), but now I'm trying to ramp up and learn modern C++ for a personal project I'd like to start working on (basically an audio plugin using JUCE).
Here's what I've been doing to try and catch up (I have two weeks off before my internship starts). I try to watch Bjarne and Herb's keynotes but they often are speaking to an audience already familiar to modern C++, so this posts video is great! I've discovered the brilliance of Sean Parent, so I'm watching all of his talks. I've ordered Scott Meyers Effective Modern C++ (and hopefully he uses the money for a new haircut /s). I've browsed through the C++ Core Guidelines [2]. I'm reading the JUCE tutorials (and source code) which is beautifully written.
What are other good resources? I'm particularly interested in developing GUI's. I'd like to see some tutorials written like Herbs talk here: for people new to C++ and new to modern C++.
[1] This is our textbook: https://www.amazon.com/Programming-Program-Design-Including-Structures/dp/1285852753 https://www.amazon.com/Programming-Program-Design-Including-...
[2] http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-introduction http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#...
- sacado2 8y ago> I completely understand why (we're learning low level stuff and it's worked for the last 30 years so whatever) Are you sure it's not just because your teachers are not (enough) aware of those new features ? Because I work in a University and know way too many colleagues that still use new/delete on a daily basis.
- zengid 8y agoI believe you are correct, but even the textbook ignores the new stuff except for nullptr and briefly mentioning range based for loops. The professor who taught my Data Structures class (who is an exceptionally great teacher BTW) actually uses C in most of his own work, so we even learned a little bit about how to simulate recursive calls using a void* stack and goto. I hope my peers don't go out and write code like that in the wild, but that's another story..
- monocasa 8y agoFWIW, I used to be the lead of a C++14 RTOS. You can be low level and still use a lot fo these techniques. And that void*/goto hack sounds bad, even in C land. That's basically only acceptable in a byte code interpreter.
- gpderetta 8y agowell, if you have to implement a non tail-recursive function and want to have control of the max recursion depth (i.e. not get killed because you have exhausted the stack) it is an option.
- monocasa 8y agoThere you should probably pass a iteration count into the function rather than some weird goto hack.
- palisade 8y agoLearning how it used to be done isn't a bad thing, though. Because when you need to maintain code that existed before modern C++, of which there is much, you'll be ready.
- monocasa 8y agoEffective Modern C++ is a great book designed for "I learned pre C++11, but now I want to get with the times, and specifically want to know the idiomatic ways to apply it".
- TomVDB 8y agoIs Effective Modern C++ good enough for those who learned C++ in the early 2000, still use those idioms and never upgraded to C++11 ?
- monocasa 8y agoI'm not quite sure what you're asking. Is it a useful book if you plan on keeping a C++03/C++98 codebase? Probably not, Effective C++ is the better book for that world. Is it a useful book for migrating from premodern to modern C++, even iteratively? I'd say yes, that's one of the book's explicit design goals.
- TomVDB 8y agoThe second part: I want to bring my practical C++ knowledge up to date and I don't know C++ 11.
- blub 8y agoI'd recommend Bancila's Modern C++ Cookbook instead, it takes you through the new features and explains how to use them. Effective Modern C++ is part language tutorial, part series of tips, part philosophical discussion on how one should use various features. It's not appropriate as an intro to modern C++.
- monocasa 8y ago> Effective Modern C++ is part language tutorial, part series of tips, part philosophical discussion on how one should use various features. It's not appropriate as an intro to modern C++. See, I take the opposite stance. There's enough moving parts here that it's nice to get some background into what's actually happening, and then read more cookbook style stuff when you understand the underlying context.
- bluGill 8y agoHerb and Bjarne's keynotes from 2011. They are always pushing what is new and exciting, while the rest of us are just catching up. Don't forget the other information that you can get from speakers who are not as good. New and shiny is often easy to abuse simply because nobody is sure if it is a good idea or not. Not everything stands the test of time. Other things are great and critical in their niche but create an awful mess when abused to apply elsewhere.
- blub 8y agoBancila's Modern C++ Programming Cookbook is surprisingly good. There's also a video by Vittorio Romeo called "Mastering C++ Standard Library Features". Both of those are from Packt, which have a pretty poor reputation, but don't let that hold you back in this case. Josuttis' The C++ Standard Library is the classic reference.
- proverbialbunny 8y agoThe largest change is ownership semantics. If you can learn or have learned ownership semantics in such a way that ties that abstract concept to concrete real life examples, most of your work will be done. Modern day C++ has two ways to do most of the things you want to do: The C way, and the C++ way. eg, c array[] vs std::array<>, or char* vs std::string and the like. However, original C++ without C is still there and not updated. Eg, inheritance is a C++98 feature, not a C feature, so there is only one way to do inheritance for the most part. It takes little time to identify what features are C features and what features are C++ features. From there you'll know when to look up alternatives and when not to, giving you an easy upgrade map. Also, some C features are more powerful, so it is a matter of choosing the right tool for the job. For example, looping through a data structure and adding elements. Doing so invalidates iterators, but works will with an index, so it might be ideal to use the old C way in situations like that. This also adds explicitness to code. If you're working in a modern code base and in the rare spots where the C way is done, you can get an idea why and from that what the code is doing without having to read all of it. This makes reading code easier once both C and modern C++ have been learned.