C++ Concept Syllabus Topics [Feedback please]

Hello Everyone,

It took some time, but I refined the main topics of the syllabus and would like to have your comments on them. I see C++ as one of the basic programming languages, that has spawned many others. For that reason many concepts are familiar, but it would be good to go over the basics in a sorted manner so that the fundamentals are clear. There is no fun in using std algorithms and std containers, if you don’t have that basic understanding. So without further ado: these are my 16 22 Concepts that would kick off the first batch. Don’t mind the order for now.

Concept Name Teaches Notes
Basics Variable Declaration
Variable Initialization
Calling Functions
Comments
Numbers Int
Double
Arithmetics
Fundamental Types Fundamental Types float, char, (size_t)
Comparison Operators (rounding errors!)
Boolean Logic Logical Operators
Boolean
Arrays Arrays
std::vector
Conditionals Conditional Statements if, switch, initialization statements
Loops Iteration Statements while, do-while
Advanced Loops Iterators for, ranged-based for
Enums Enumeration
Scoped Enumeration
Strings C-Style Srings
std::string
Classes Classes (includes structs)
Methods
Access Controls
Advanced Classes Constructors
Destructors
Static Members
Copy and Move Copy Semantics
Move Semantics
Pointers Pointers
dynamic storage new / delete
References References
Smart Pointers Smart Pointers
Exceptions Try-Catch
Exceptions
Polymorphism Inheritance
Interfaces virtual
Templates Templates Class and Function, Situated in Header Files
Overloading Operator Overloading Show Custom Iterators
Functions Functions Return Types, Arguments
Function Overloading
Constness
Code Organization Namespaces
Header Files

I hope I can follow up with a deep dive into algorithms and containers afterwards. Also, I think we should add some C++17 / C++20 etc sections at some point.

Edit:
I split the concepts and made an extra concept for code organization. This might seem obvious to many, but it is quite confusing coming from other languages to have header and implementation files (and namespaces that are not strictly bundled to a file(name)).

5 Likes

(cc @ErikSchierboom too)

1 Like

I think that at least std::vector could be squeezed in with these concepts. It seems like a very natural extension of the arrays and also enables some of the other things like iterators and range-based for.

About the templated nature of the containers I wouldn’t worry too much, I learned how to use various STL containers way before I created my first templated function or class and still I had a pretty good idea of the meaning of the <>.

2 Likes

@vaeng It’s a very nice list! The only thing I think you could consider is breaking things up into smaller concepts. For example,

Fundamental Types teaching Int, float, char, boolean and size_t seems like too much. In many tracks we use the following setup:

  • Have a numbers concept that explains the most common integral (int) and floating-point (float) type. Then have subsequent exercises for integrals and floating-point-numbers that go into more depth, for example by listing all the possible integral/floating-point types. With this setup, you can have a fairly basic exercise explain numbers and basic arithmetic, without having to teach everything about those numeric types.

I’d also move Logical Operators and the bool type into a separate exercise.

A similar reasoning can be applied to Loops. Currently, it contains quite a lot. while and do-while go nicely together, but I’d likely put range-based-for as a separate concept. And I think iterators also deserve their own concept, as it has quite a lot going on.

But all in all it looks like a great list!

1 Like

It looks pretty thorough. I think I’d merge copy and move semantics into the same concept - it seems natural to me that those are taught together. Also, in the Classes concept, you could talk about assignment operators.

About C++20 sections: are Exercism’s C++ exercises targeting C++20 yet? I was under the impression we were still targeting C++17.

1 Like

I think it is a bit hard to read, but they are supposed to be together in the same category “advanced classes”.

That is correct. Therefore I aim at C++17 until Ubuntu 22.04 would be the latest LTS and therefore our baseline. At least this is how I understood it from Siebenschläfer.

First I had all std containers later in the tree. It is probably a good thing to have std::vector earlier, so it does not feel too unfamiliar when templates are introduced.

Good feedback. That is also something which should be done early in the planning, because I think it is more difficult to break concepts up into chunks at a later point.

2 Likes

@ErikSchierboom

I made the concepts smaller and more concentrated. I think it looks a lot better now. I think it is best to try to fit them into a tree before I move on. Might have to juggle some smaller parts around for that.

When the tree seems right, I would look at other tracks that teach similar things and mix and match them. Implement these first, then go on to work on the linking parts to have a basic structure. Lastly, I would do the Cpp-specific concepts.

I wonder when I should fit in the existing practice exercises. Maybe at an earlier stage, when I know the tree? Currently, there are no prerequisites at all for any of the exercises.

2 Likes

This is the only concept I’m unsure of. They (float/char/size_t) seem to be quite different things, so you could consider just making them different concepts.
Other than that, this is start to look really good!

1 Like

Excellent idea. Forking from existing exercises is a great idea. One tiny suggestion: when you do an exercise on boolean logic, I would recommend forking Elixir’s Pacman Rules exercise instead of Elyses Enchantments.

1 Like

I wouldn’t necessarily focus on it right now. Maybe it is best to do this on a per-concept exercise basis.

1 Like

I have to see how other tracks did those. At the moment I think they are too small to justify a whole concept for each. Char and size_t are mostly aliases of certain integers and float is a smaller double. I was aiming to have some conversion exercises to bring those together.

Usually conversion is done in the numbers exercise that introduces integers and doubles, so that’s something to consider.

I have to think about what kind of exercise would be good to have the students juggle with signed/unsiged and different bit sizes. Or does anyone know a good concept from another language that has done that before?

I only know a very bad one from C# (don’t copy that!).

Grains is a good one for that I think, although it also has to do with bit shifting. As the chessboard has 64 squares, a 32-bit int wouldn’t be enough, nor would a 64-bit signed int. Also, for the total, if the formula for the sum of the geometric progression is used, the answer is (1ULL<<64) - 1 which overflows for 64-bit ints, and there is that.

Unfortunately grains is a practice exercise and we don’t allow for them to be used as concept exercises (for various reasons)

And it would only cover that “limit is not high enough”. So students don’t get why it might be smart to use uint8 and always use int64 everywhere, because that is “safe”.
I would have to make up something that is memory restricted or some other sensible scenario. That might play into other languages that have the same restrictions.

I hope I’m not too late to the party :slight_smile:

  • “Fundamental types” is a technical term in the standard (a type can either be “fundamental” or “compound”.) If you meant this in a colloquial sense (“the most basic types” like int, double, char) I’d suggest a different term.
  • I wouldn’t put size_t into the same category as float and char. It is an important type but it is used in different (and more advanced) contexts. I’d rather introduce it later, maybe together with containers or std::ptrdiff_t.
  • You could consider introducing std::array together with arrays and std::vector. It’s only a little bit more cumbersome to type than std::vector but it’s much easier to handle than C-style arrays because it doesn’t decay to a pointer, knows its size, and can be passed to and returned from functions.
  • In “Conditionals” what is “initialization statements” supposed to mean?
  • The conditional operator might be a good fit for the “Conditionals”

That is correct. Therefore I aim at C++17 until Ubuntu 22.04 would be the latest LTS and therefore our baseline. At least this is how I understood it from Siebenschläfer.

Correct. This is what Patrick S. Jackson wrote:

in the past we’ve said that our minimum supported version should be the default installs on the oldest Ubuntu LTS version. If that still makes sense, we can now update the default to C++17, and updating to C++20 could be done when Ubuntu 18.04 goes out of support in April 2023.

1 Like

Updating to C++20 could be done when Ubuntu 18.04 goes out of support in April 2023

I already had to update the GitHub actions to Ubuntu20.04.

This includes an update to g+±10.
Clang is at version 6, I would happily update that to a newer version. We can have up to version 12 on 20.04.

Currently, there is only MSVC that completely covers all C++20 features. For g++ and clang there are small gaps here and there. I think they are not touching the features of our exercises, so we might have to discuss if we should call the track C++20 compatible.

We are completely fine with C++17 now.

1 Like

Hi, I would like to see the strengths of modern c++, like constexpr, variadic templates and some old friends in a more standardized way like SFINAE with type_traits.
Also lambdas and function objects.