4 ms·
I've often wondered how anybody manages to teach C++ today. I love working with the language, and I understand the reason behind many of the features, but I can
by maxlybbert 10y ago
I've often wondered how anybody manages to teach C++ today. I love working with the language, and I understand the reason behind many of the features, but I can't help but feel like it would be impossible to teach to beginners.
- speedkills 10y agoMaybe they don't bother. PSU is still teaching C++98.
- maxlybbert 10y agoThat was the thing: starting with C++98, I was able to pick up C++11. But starting from scratch? I'm not sure.
- izacus 10y agoWe have a rather lagerish codebase of C++11/14 and we manage to get people coming from other languages (Java / ObjC) to start working with it just fine. Modern C++ is pretty decent and readable (excluding some quirks of STL naming). Of course good code reviews and testing is a must to help people to get up to speed and stop shooting themselves in the foot :)
- cmrdporcupine 10y agoWow I feel the opposite. Because C++98 and earlier were so deficient in a lot of ways, people who got clever with it often ended up down a rabbit hole of template metaprogramming, boost:: bloat, custom classes for callback stuff, custom classes for reference counting or other smart pointers, etc. etc. Unlearning all that took me some time. In my 5 years at Google, I've watched many developers start from scratch on our subset of modern C++. There doesn't seem to be a huge challenge with it.
- acqq 10y agoIs the subset of boost in Google still the same as the public one? https://google.github.io/styleguide/cppguide.html https://google.github.io/styleguide/cppguide.html It it is, I consider Google very lucky to have these who decided not to allow everything.
- _delirium 10y agoThe norm in the game industry is usually to expect some kind of background in low-level programming (maybe C, maybe some version of C++), and then teach new employees a very specific, restricted subset of C++ that's the in-house dialect (and every company has its own, different subset).
- baq 10y agothat's because it is impossible. it takes years to master the language and that was before i lost touch with it around 2010 back when C++11 was TR1 or whatnot. i understand that what is usually considered good form is trying to completely forget about C features like pointers and arrays and use their STL counterparts like unique/shared_ptr, std::vector, std::array and iterators. this gets you a nice modern subset of the language that makes it relatively difficult to shoot yourself in the foot.
- maxlybbert 10y agoI didn't use C-style string functions for the longest time. If I had a char*, perhaps because I got it from some C library we were using, I would turn it into a std::string and use it's functions and operators. One day, I realized how silly that was: I'm sure I was causing gratuitous memory allocations (not all strings qualify for the short string optimization). Perhaps part of my hangup is the expectation that you would teach the difference between, say, enum and enum class. There are good reasons to use enum, and I believe there always will be. There are good reasons to use pointers (in fact, one of the main reasons I use pointers is to point to the payload of a std::unique_ptr, and I use std::unique_ptr when I have an obvious owner, even if I might need other functions to access the payload while the owner is still around). So I don't think that it's possible to ignore "the old ways" completely.
- baq 10y agoit isn't possible if you're doing real work, but it is possible if you're learning or teaching, especially if stdin and stdout are the only ways your program will do IO. it's actually pretty nice and code is surprisingly concise, especially if you use stream iterators.
- kire456 10y agoFwiw, I followed this course at my university[1]. The 'schedule' and 'setup' links provide an idea of what is treated, and the full book is available[2]. The full course took slightly over six months, so yes, it takes a while :) 1. http://www.icce.rug.nl/edu/ http://www.icce.rug.nl/edu/ 2. http://www.icce.rug.nl/documents/cplusplus/ http://www.icce.rug.nl/documents/cplusplus/
- JackdawX 10y agoHere is the course I was taught by at university: http://www.dcs.bbk.ac.uk/~roger/cpp/ http://www.dcs.bbk.ac.uk/~roger/cpp/ Lots of value came from the lectures with roger. Sadly he has retired, it would have been nice to have them up on youtube.
- ant6n 10y ago"...but I can't help but feel like it would be impossible to teach to beginners." So a relatively easy way to learn C++ is as an 'upgrade' to C, starting of with picking the parts of the language that help you the most: * you start by already knowing C, but maybe not feeling super productive, using it as structs + functions * you set up the C++ compiler (most modern version available), and just continue writing C * you start using streams to print (because it can be more convenient than printf) * you start using std::vector and std::string, arrays being one of the big pain points of C * you start using `auto` and for-in loops * you start using simple classes, without any inheritance. just structs with methods * you start adding operators - so much fun! * you start learning about references and const, and suddenly all your method arguments become `const T& v` * you learn about not using pointers (as much on stack as possible), move semantics, shared/unique pointers. This means you'll also use more templates. * you deepen your understanding of writing your move/copy constructors. Learn RIAA, and become a fan of `}`. * you learn about constexpr and constexpr functions * this is already a pretty happy subset of C++, and as you learn to use templates, you may at some point start writing one yourself. Same with lambdas - if you need them you learn them.
- mlvljr 10y agoRAII, not RIAA :) RIAA (https://www.riaa.com/ https://www.riaa.com/) is the ebil music recording capitalists :)