9
$\begingroup$

I have noticed that in many computer science courses, professors tend to focus on teaching C++11 as the primary version of the C++ programming language, rather than covering newer versions such as C++14, C++17, or C++20. I'm curious about the reasons behind this approach and whether it's common across different academic institutions.

I took plenty C++ courses at "my" (I don't own it...) university including OOP, Data Structures, Algorithms and Analysis of them,... and they always wanted us to compile the code with specific flags (Most of them don't matter, like -Wall or -Werror) such as -std=c++11. I never really noticed that in the lower level courses, but as you move up you start to notice some things aren't available in C++11, and those might be the solution to your problem.

Specifically, I would like to know:

What are the main factors that influence professors' decisions to teach C++11 over newer versions?

Are there any significant differences or challenges associated with teaching newer versions of C++ in a classroom setting?

How does this choice impact students' learning experiences and their preparedness for industry standards?

Are there any educational resources or case studies available that discuss the benefits and drawbacks of teaching different versions of C++?

I appreciate any insights or experiences shared by educators, professionals, or students who have encountered this teaching approach in computer science programs. Additionally, if there are alternative teaching strategies that incorporate more recent C++ versions, I would be interested to learn about those as well. Thank you!

P.S I'm sorry is I offended anyone by including (all) in the question title.

$\endgroup$
9
  • 2
    $\begingroup$ The bleeding edge can cause some... well you know... bleeding!! More seriously: thanks for letting me know that 11 is the common choice. To me it's almost axiomatic that jumping at the latest is likely a bad idea. [If I've a choice I prefer teaching with python 2 over 3] $\endgroup$
    – Rushi
    Commented May 26, 2023 at 7:31
  • 3
    $\begingroup$ Something i noticed while teaching, is that teachers often don't catch up with what they teach. So they only teach what they learned themselves in college. $\endgroup$
    – A.bakker
    Commented May 26, 2023 at 8:56
  • $\begingroup$ I must say I have had some pretty "uncomfortable" experiences on SO in particular, where I would post a good question and most of the responses would be "just use this... or just use and STL container, and so on" I understand that due to learning purposes professors tend not to use the STL since, well everyone can google the documentation... $\endgroup$ Commented May 26, 2023 at 15:42
  • $\begingroup$ But what strikes me as shocking is the number of times I saw comments like "This is the Java way of C++ programming" referring to the new keyword. My professor in my Data Structures class was in the industry for 17 years and I genuinely thought she was a great professor, but yeah as you mentioned some professors don't catch up on the material...Apparently, she never worked with C++ since she did front-end dev. $\endgroup$ Commented May 26, 2023 at 15:46
  • $\begingroup$ The same answer for 11 as for C: out of touch, been told to by people that are out of touch. C is not a good teaching language, and has not been a good production language for most cases for years. Now we have rust and go, it may not be the best for anything. $\endgroup$ Commented May 27, 2023 at 12:00

4 Answers 4

7
$\begingroup$

As a professor who teaches C++17/20(/23: mdspan for scientific computing): the 11 standard was the big evolution, and 14/17 are only minor improvements over it. If you learn C++11 lambdas, it's unlikely you need the 14/17 improvements in your first, maybe even second, semester of coding.

So I'd consider the -std=c++11 flag as a minimum for modern C++, as opposed to your grandparent's C++.

That said, I like std::optional and structured bindings, and I teach those. This fall will be the first time I include std::ranges which I think is fairly elegant. Wish me luck :-)

https://theartofhpc.com/isp.html

$\endgroup$
1
  • $\begingroup$ Thanks, and of course good luck! $\endgroup$ Commented May 29, 2023 at 19:56
9
$\begingroup$

The advantage of C++ for teaching programming is that it is reasonably close to the actual raw workings of the computer whilst being high level enough to teach higher level concepts. The features added in recent versions of C++ are mostly features designed to avoid working with lower level workings so using these features detracts from the pedagogical advantages of C++.

There's also probably some aspect that CS Professors are not necessarily interested in keeping up with the bleeding edge of C++ language design and fashion. These are not relevant to the kind of things that most Computer Scientists are doing. Many departments agree which language to use for base courses at the departmental level and these discussions and any changes can be highly political. This is a considerably obstacle to change.

How well it prepares you for industry depends on where you end up, there are plenty of C++ jobs out there with companies that don't use modern C++ features (the last one I had was using C++14, and used their own libraries rather than STL for most everything). But in any case, fresh graduates are expected to need six to twelve months to become properly productive in the workplace anyway, so it's not a particularly big deal whether or not you've learnt some corner of the STL.

$\endgroup$
5
$\begingroup$

In regards to "How does this choice impact students' [...] preparedness for industry standards?", as a software engineer working in industry (now retired), I would not expect a negative impact based on my experience. Side remark: The use of -Wall -Werror is an industry best practice.

Having worked in a number of Silicon Valley companies I observe that industry is often slow in utilizing new language features for production code, for practical reasons. New language features may be used in research or exploratory code by a small subset of the company's engineers.

The availability of new language features is tied to newer toolchain versions, and most companies value toolchain stability in their development work. It is not out of the ordinary to find a company having standardized on a five year old toolchain, for example because newer versions have been found to contain functional bugs or introduce performance regressions in the company's money-making products. This conservative approach can also be seen in the choice of default compiler offered on various Linux distros, where enterprise level RHEL 8 might ship with gcc 8.x, while at the same time Ubuntu 22 (possibly preferred by researchers and hobbyists) might ship with gcc 11.x.

It is also the case that, for a variety of reasons, different toolchains adopt support for new language standards at different speeds. See the compiler support matrix at the CPP Reference website for example. This comes into play when a product needs to be supported across multiple platforms, some of which may not be known yet. In that case it makes sense to restrict oneself to the use of a minimum language standard that is supported "everywhere". From what I can see, at the moment that would still seem to be C++11.

$\endgroup$
4
  • $\begingroup$ -Wall -Werror: I tried the other if my codes were clean in that respect. What?! for ( int i=0; i<myarray.size(); i++) is not allowed? Fiddle that shirt! Do I seriously have to burden my poor students with the distinction between signed/unsigned 32/64 bit? Ok, you said "industry", but see what forum we are here. $\endgroup$ Commented May 29, 2023 at 19:36
  • $\begingroup$ @VictorEijkhout I am well aware that this is CSE. I specifically only addressed the part of the question dealing with "industry standards" and stated so up front. $\endgroup$
    – njuffa
    Commented May 29, 2023 at 19:39
  • $\begingroup$ @VictorEijkhout Unfortunately, yes. At least I was taught about signedness and the bit size of integers (how they're stored in memory, and so on). I really like your attitude toward your students, you seem like a great professor. $\endgroup$ Commented May 30, 2023 at 5:29
  • 1
    $\begingroup$ @TheCompile-TimeComedian My teaching is "operational": anything my students learn needs to be reinforced with a concrete use case. 1. 32 vs 64 bit ints: I have the hardest time getting them to realize that 10k is not a large number. I don't think int overflow happens much in the first semester coding exercises I give them. 2. signed/unsigned: even more rare to run into. I save 2's complement and IEEE 754 for a more advanced class. So I'm afraid that teaching them for ( size_t i=.... this will become voodoo programming: just a magic formula they have learned, without understand the why of it. $\endgroup$ Commented May 30, 2023 at 13:24
3
$\begingroup$

I'm no teacher, though following the community online I have the impression that too many students are exposed to C++98/03, pre-standard C++ or C in their C++ courses. If they all would be making the jump to C++11, we would give them a better experience.

Personally, I don't see much difference between C++11 and C++17 while the latter provides quite some quality-of-life improvements.

An argument I've heard before was that universities teach what the industry uses. Following that reasoning I would not expect C++20, however C++17 should follow that rule.

I also believe that we, as a community, should make a better stand on what versions our considered outdated. I was glad to see boost drop C++98 requirements, though that's just a first step.

$\endgroup$
2
  • $\begingroup$ I am still in school right now, and I am taking OOP class in C++, Java and C#. Nobody in that class teaches any industry practices since they differ so much it's basically pointless (use of in-house standards). I personally see some noticable differences between C++11 and 17, like lambdas, compile time eval, threading, and STL. $\endgroup$ Commented Nov 8, 2023 at 23:41
  • $\begingroup$ That's what I meant with quality of life improvements. All those things exist in C++11 (except some STL sub libraries) though they became much easier to use. All of them are still the same concepts, so you don't need big reworks of the way you teach them, unlike ranged-for, auto, introduction of lambdas, std::move, std::unique_ptr. All of those where new concepts that really change the way people think about writing code. $\endgroup$
    – JVApen
    Commented Nov 9, 2023 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.