Answers.Body: <p>You are looking at a room full of post-grad students, who are thus convinced of their superior intelligence, some of whom have zero programing experience... I think your only hope is to lean into <em><strong>live coding</strong></em>.</p>
  <p>Whatever you do, don't try to start off with a huge example that shows everything all at once, thinking that you will slowly introduce and describe the basics after the fact.  This will only intimidate and discourage the newbies.</p>
  <p>Start off with the basics, move as quickly as the students will allow and demonstrate everything in the compiler yourself as you go along. In addition to seeing the concepts work in the real world, the code they are creating also acts as note taking and gives them a reference for the future.</p>
  <p>Once you are rolling you can fast forward through topics when you see that the students are groking the basics. Covering everything, but spending as little time on it as possible: This is an IDE, it lets you build and compile a program. Commands look like this, notice the dot / arrow notation, it will become important.  Variables have a type and hold values. Basic arithmetic looks like this, notice how values are accumulated. Looping and conditions are managed thusly, see how we can nest the structures together. Methods help with organization and are the most awesome boring topic in existence.</p>
  <p>What will make all of this stick is having the students code it along with you. Create a basic program demonstrating it all live as you type it in, while the students follow along tying it in on their own computers. Pause after each major topic to give them a chance to solve a mini problem where they use the tool on their own.</p>
  <p>Stay away from pointers and references. I know the ideas are at the core of C/C++ but * and -&gt; notation is enough to send any newbie away screaming.</p>
  <p>After each meeting, leave them with some homework. Have them create a project that highlights what they learned, incorporating as many of the past topics as possible. Make the projects as fun and interesting as possible, incorporating graphics as much as you can, even if this means giving them 90% of an app as a starting framework for them to build on.</p>
  <p>The more experienced the students get, the more confident they get in their ability, the more time you can spend on lecture instead of demonstration.</p>
  <p>Finally, save class structure for the very end.  After they have been creating static methods and local/global variables for a while, the idea of encapsulating it all into an object that can have multiple instances should now fit into their brains. This is also the time to introduce the idea of pointers and references.</p>
  <p>Now... does all that qualify as best practice? Meh, I don't think there is such a thing in teaching. While I can back it up by mentioning that I have 15 years of experience teaching at both the high school and college level, it is all of course only my humble opinion.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T14:32:16.147Z
Answers.Text: In general I agree with your answer but I disagree on classes. Students don’t seem to have much trouble with it and on the contrary they seem to appreciate the elegance of code organization. Maybe it helps that I give them exercises that are elegantly expressed with objects.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T14:58:38.260Z
Answers.Text: Agree to disagree. I have students that get organization right from the start, but most students need to drink in the idea of coding and confront a page full of endless left justified code before the need for organization sinks in.  Functions is actually the second topic I cover in my intro course -- right after they get to know the IDE. But, I don't touch on objects in intro at all. The organization of class structure is straight forward, but the fact that you can instantiate multiple instances of the class, each with its own instance variables, can be a bitter pill to swallow.
Answers.UserDisplayName: codingCat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T16:04:11.183Z
Answers.Text: Happy to disagree.  I used to teach `struct`s before classes, just to get the notion of "bundle of data" in to their heads. Have since stopped mentioning structs altogether, but the examples / exercises still have objects that are data-like. For instance `class Point { double x,y; ...... }` so that you can have `Point Point::shift(....)` and `Rectangle::Rectangle( Point,Point )` (rectangle from topleft/botright points). I don't recall there ever being a problem with that. (Are your materials online?)
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-14T18:31:48.463Z
Answers.Text: Why should I bundle data or use classes? I only care about it after I've tried to manage 16 separate variables and methods that represent one entity and run into problems. I'm unlikely to understand or care about loops or arrays until I've tried to write `person0`, `person1`, ... `person16` and print each one's name or figure out their average age. Students don't typically appreciate a solution without experiencing a problem first.
Answers.UserDisplayName: ggorlen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T07:37:44.520Z
Answers.Text: If you are not going to teach pointers or references, it is an indication that you shouldn't be teaching C/C++ - they are fundamental to the way the language works and the benefits that C++ has over e.g. Java (the complexity of C++ is the cost you pay for that benefit).  +1 for live coding though.
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T12:08:51.627Z
Answers.Text: @Dikran Marsupial I would tend to agree. C/C++ should not be the language you try to teach to first semester students. However, if you are stuck starting students out in C/C++ you should try to soften the blow as much as possible and leave the ramifications of pointer manipulation until they have some mastery over the basic idea.
Answers.UserDisplayName: codingCat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T12:10:45.737Z
Answers.Text: @codingCat indeed, just because you can do arithmetic on pointers, doesn't mean you should! ;o)
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T14:17:13.010Z
Answers.LastActivityDate: 2022-05-11T14:17:13.010Z
Answers.UserDisplayName: codingCat
Answers.Body: <p>Your instincts are correct - there are alternatives to lecturing, but <a href="https://teaching.berkeley.edu/news/lecture-or-not-lecture-how-about-maybe-0" rel="nofollow noreferrer">every pedagogical method has its place</a>. I generally reserve lectures as an opportunity to highlight a few difficult concepts from the text and address questions.</p>
  <p>I favor OER textbooks, a flipped classroom, and students working on assignments in class. Assignments could be either straight programming tasks or guided exercises. Not sure what content you plan to focus or how dirty you want to get, but there are several decent C++ OER books based on Sphinx/docutils:</p>
  <ol>
  <li><a href="https://opendsa-server.cs.vt.edu" rel="nofollow noreferrer">OpenDSA</a> is an interactive open data structures textbook, but people are growing it beyond data structures content. It has config files allowing you to customize your own textbook. I used it years ago, but found working in the environment harder than I liked.</li>
  <li><a href="https://runestone.academy/user/login?_next=/" rel="nofollow noreferrer">Runestone Academy</a> is a general framework for creating interactive OER. My current textbook uses Runestone, but I self-host (on GitHub pages) so that the book is 100% free for students. Runestone can host your course for you, but there are some (small) fees for students. I have not looked deeply into it.</li>
  </ol>
  <p>Both of these environments support assessments in the text, but otherwise, the details are different. If you are already familiar with <a href="https://www.sphinx-doc.org/en/master/" rel="nofollow noreferrer">Sphinx-doc</a>, I think Runestone has a short learning curve. If you want to see a self-hosted example (<a href="https://daveparillo.github.io/cisc187-reader/index.html" rel="nofollow noreferrer">my textbook</a>). <a href="https://github.com/DaveParillo/cisc187-reader" rel="nofollow noreferrer">Book source</a> is on GitHub. A <a href="https://github.com/DaveParillo/cisc192-reader" rel="nofollow noreferrer">first semester version</a> based on <a href="https://open.umn.edu/opentextbooks/textbooks/how-to-think-like-a-computer-scientist-c-version" rel="nofollow noreferrer">How to Think Like a Computer Scientist</a> is a work in progress. You could look at that outline to get a sense of what is reasonable for a single semester.</p>
  <p>Another thing to consider are the assignments themselves. Most of my assignments are in the style of <a href="https://exercism.org" rel="nofollow noreferrer">Exercism.io</a>. Students are presented with a programming problem and they need to write code that passes the unit tests. Most students find this approach both challenging and engaging.</p>
  <p>Another approach useful in a flipped classroom is POGIL. There is a Process Oriented Guided Inquiry Learning <a href="https://cspogil.org/Home" rel="nofollow noreferrer">(POGIL) in Computer Science</a> group and they provide activities, training, mentoring, and POGIL workshops-on-request. I have found them to be quite responsive and helpful.</p>
  <p>Whatever you do, focus on getting students to write code. You can listen to classical music your whole life and never learn to play an instrument. Programming is not a spectator sport.</p>
  <p>As far as content, I prefer to teach a more modern version of C++. Generally, I'm in alignment with <a href="https://cseducators.stackexchange.com/a/7375/12055">codingCat</a> - I focus on coding as much as is possible -&gt; the type system, string and vector first, then functions, structures, and classes mostly in that order - although I use <a href="https://en.cppreference.com/w/cpp/named_req/PODType" rel="nofollow noreferrer">POD's</a> from the first few weeks. I will say that unlike codingCat, I cover pointers and references (not in that order) when I cover passing semantics for functions.  Something to consider is that if you focus on (post?)-modern C++, you can write much more code that appears to have pass by value semantics, but isn't (move semantics).  You can have your examples look simple and then once the basics are understood explain the magic that make the simple looking stuff happen (e.g. move semantics).</p>
  <p>I see a lot of courses in a big hurry to teach OO right away. There are a lot of pitfalls to be aware of in OO and C++ is already a language with more pitfalls than most. Classes are collections of functions and data. If students can't write decent functions, then they are unlikely to write decent classes. Classes are everything that functions are and <em><strong>more</strong></em>. Also, C++ is a multi-paradigm language - people need to expect that not everything will be in a class. This can become a religious war, but I assume you have a course outline you are required to follow, so do what you have to do.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-12T23:31:12.540Z
Answers.LastActivityDate: 2022-05-12T23:31:12.540Z
Answers.UserDisplayName: DaveParillo
Answers.Body: <p>I agree that pure lecturing is really bad. I let students do lots of exercises, including during class time. (And just to prove that lecturing is bad: two minutes after they have seen something on a slide they can not remember it for their lab exercise.)</p>
  <p>The reason I like doing labs in lecture time is that I walk through the class (with a co-teacher) and look over everyone's shoulder. Tell them &quot;That's good&quot; or &quot;I see you're stuck, take a look at....&quot; or &quot;You can do it that way, but I like .... because ....&quot;.</p>
  <p>Feel free to use my book. Item 3 on: <a href="https://theartofhpc.com/" rel="nofollow noreferrer">https://theartofhpc.com/</a> It comes with sources for the slides, lots of example programs, and skeleton codes for exercises to get them started. Everything is up to C++17 standards. There are also some fairly nifty end-of-semester coding projects.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T14:18:22.800Z
Answers.Text: Formative assessment at it's finest.  :-)
Answers.UserDisplayName: codingCat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T16:14:55.457Z
Answers.Text: @codingCat Right. Giving them a week to get completely stuck on a homework assignment is the best way to lose them entirely.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-11T13:52:16.200Z
Answers.LastActivityDate: 2022-05-11T13:52:16.200Z
Answers.UserDisplayName: Victor Eijkhout
Answers.Body: <p>I also teach at the University level and have found great success in teaching C++ by doing visual &amp; interactive program examples, exercises and assignments.</p>
  <p>Something like the Coding Train's <a href="https://youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA" rel="nofollow noreferrer">Intro Programming</a> but with C++. You could use <a href="https://www.raylib.com/index.html" rel="nofollow noreferrer">raylib</a> to help provide simple drawing and interactivity.</p>
  <p>Hope this helps!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-12T23:13:32.047Z
Answers.LastActivityDate: 2022-05-12T23:13:32.047Z
Answers.UserDisplayName: rudy
Answers.Body: <p>I teach C and C++ in the second year, who were taught Java in the previous year by myself and a colleague.  Due to COVID I pre-recorded the lectures I used to give so that the students could watch them in their own time.  I indexed the videos at each change of slide so that they could easily navigate to the bit they wanted, which seemed a good compromise between having lots of short unconnected videos and an overly long traditional lecture.  The idea was that they would watch the videos, and if they had questions or wanted me to go over examples of something, they could let me know (via a discussion forum) and I would give a live lecture later in the week (just before the lab) which would be a mixture of explaining answers to questions with new slides generated for that week, informal Q&amp;A and live programming demos (my traditional lectures also had lots of that).</p>
  <p>This approach seems to work well - many students are uncomfortable asking questions out loud in a live lecture, but were much more comfortable with the chat facility used in the remote live lectures, so there was much more interaction than before and I could be more responsive to student's difficulties/questions.</p>
  <p>Different people like to learn in different ways, and this approach works whether you actually <em>like</em> watching formal programming lectures, or just want to watch them in sped-up 10 minutes sections, or ignore them altogether and read books/experiment with the computer.</p>
  <p>The key thing is for the lab classes and exercises to be well designed and get the concepts in the right order.</p>
  <p>As we do C and then C++, we cover pointers and memory allocation in C.  Note: we teach C and C++ as distinct goals, we are not teaching C purely as a prelude to C++. This is a major stumbling block for students to it is important they understand it properly at an early stage.  As they have done Java the year before, they find the concept of the variable actually being the object (rather than a reference) rather difficult and they tend to write very inefficient C++ code, so that is also something to emphasize early.  Being from a Java background they have difficulties with C++ references because Java references are epsilon different from a C pointer and the terminology confuses.  I approach classes via structs which we did earlier in the C part of the course.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T21:09:58.297Z
Answers.Text: C "pointers" are really memory addresses, and are almost never needed in C++. So if you're teaching that on the way to C++ it's a waste of effort, and you'll probably teach them bad habits. C++ does have real pointers, usually called "smart pointers", but those are not needed in many applicaitons. In other words, I disagree with many aspects of your teaching strategy.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T21:23:52.370Z
Answers.Text: Well, you wrote "As we do C and then C++" so it does sound like you're using C as a precursor to C++.  For what it's worth, I teach C++ first, and then show how some things that are simple in C++ can be hacked around in C.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T12:58:55.780Z
Answers.Text: What you call "pointers" are not pointers. They are addresses. Smart pointers are to your "pointers" as `std::vector` is to automatic arrays: a better way to do stuff that is error-prone in C. You can perfectly well use smart pointers to implement linked lists and such with out ever having seen C "pointers". A wider point about "understanding things": it's called abstraction. You can teach to a level of abstraction, and as long aas that's a consistent and rich enough vocabulary, you don't have to teach the layer below it. So: I teach `std::vector` and not `new x[5]`; ditto pointers.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T15:25:55.387Z
Answers.Text: Well, I do point out the costs of re-allocation in `std::vector`, in the abstract. I think the lower layer should only be taught when it has a detectable impact.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T15:42:18.760Z
Answers.Text: You're right, I don't care about linked lists as such. However, linked lists are the simplest example of a Directed Acyclic Graph. And DAGs are very common in computational science.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T16:43:05.213Z
Answers.Text: No, you are completely wrong. I have no idea how you manage to misread me this much. The topic was smart pointers vs bare pointers and I said I use smart pointers to teach linked lists. I never mentioned the `linked_list` container API, you did. The thing I don't teach is how smart pointers are based on bare pointers.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T16:54:58.993Z
Answers.Text: When do you need the `get()` method?
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T19:12:52.697Z
Answers.Text: No I don't. If you do that they need to understand rvalue, lvalue, .... before they can understand the simplest mechanisms.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T20:48:50.033Z
Answers.Text: With my apologies for an easily misunderstood remark, let me clarify. I teach to undergraduate engineering students. Those are maybe not average beginners, and you may very well teach to a very different audience. Fact is that I do get students with minimal or no programming experience, who need C++ in their further career, and they seem to deal with it just fine.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-13T10:42:52.337Z
Answers.LastActivityDate: 2022-05-17T11:13:28.733Z
Answers.LastEditDate: 2022-05-17T11:13:28.733Z
Answers.UserDisplayName: Dikran Marsupial
Answers.Body: <p>If the point is to learn C++, you must learn C. Must. You must understand addresses, pointers, structures, argument passing, memory allocation, the stack and a backtrace. You must understand implicit conversions and the difference between floating point and integer math and the limits and sizes of built-in types. You must understand linkage. Any way you do it, you can't escape these topics.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-13T11:47:04.863Z
Answers.Text: Learning C is actively detrimental to learning C++. Yes, you must learn pointers, linkage, etc. but there is no reason to learn C itself since a great many things in C have been superseded in modern C++ (or even old C++).
Answers.UserDisplayName: Jack Aidley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T08:02:32.857Z
Answers.Text: @JackAidley the fact that a lot of systems programming is (best) done in C is a good reason to learn C.  The other advantage of C is that the students are capable of fully understanding it all as they learn, because it is all very simple and nothing is hidden.  Learning C++ directly requires the students to take a lot on trust, and using things without understanding what you are doing seems somewhat antithetical to university education (and is a bad habit students easily fall into because the are often goal-directed).  Both approaches have advantages/disadvantages.
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T10:34:14.660Z
Answers.Text: @DikranMarsupial There may be many good reasons to learn C, but in order to learn C++ is not one of them.
Answers.UserDisplayName: Jack Aidley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T12:05:03.137Z
Answers.Text: @JackAidley C++ is a superset of C, you can't learn C++ without learning C, it is just a matter of emphasis on which parts of it you use.  If you want to learn OOP, then learning Java first is better than C++.  C++ is no longer a good language to learn first (as it was back in the late 1980s) - it is too complex and compilers too unfriendly (due to the complexity of the language).
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T12:08:35.060Z
Answers.Text: Having said which, learning C+=0.5 (i.e. C but without OOP), which is the approach some take, is the worst of all worlds.
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T14:42:47.987Z
Answers.Text: @DikranMarsupial It is not true that you need to learn the C subset in order to learn C++. Many C features have been superseded in C++ and are rarely used in C++ - certainly not at the beginner level. malloc/free would be the most obvious but there are others. What's more the way you program in C and the way you program in C++ are different, learning the C way - as a beginner - is unhelpful to learning the C++ way.
Answers.UserDisplayName: Jack Aidley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T14:50:04.800Z
Answers.Text: @JackAidley malloc/free is part of the standard library, not the language.  The only fundamental difference between the ways you program in C++ that you don't in C are OOP (you can do this in C, but it isn't worth the hassle), operator overloading and templates (although you can do that in C if you want in the way C++ did before templates were part of the language).  C++ uses much the same control structures, fundamental types and functions as C.
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T14:50:52.757Z
Answers.Text: "C++ way" is a superset of "C way", you can do all the same things, but with more stuff added.  C++ is a multiparadigm language - "C way" is one of those paradigms.  And as I said (possibly another thread) C++ is not a beginners language anymore (IMHO).
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-15T19:41:56.070Z
Answers.Text: Re, "C++ is a superset of C." That was true back in the early days of C++, but the C++ language has diverged from C in subtle ways. If you want to teach C++, then by all means, start with a small subset, and build on that subset bit-by-bit. But you could have avoided most of this argument simply by not calling the subset, "C."
Answers.UserDisplayName: Solomon Slow
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T21:06:25.400Z
Answers.Text: Unless you have experimental evidence of your notions, I will disagree. 1 First learning C leads to really bad C++ code. 2. Many parts of C are not needed because C++ does things better. 3. Many experts (find Kate Gregory's lecture "Stop teaching C") agree with me.
Answers.UserDisplayName: Victor Eijkhout
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-17T09:56:45.200Z
Answers.Text: @SolomonSlow most of the things that are legal in C but no longer legal in C++ are things that most C programmer wouldn't do anyway (at least not anymore).  The reason for teaching C first is because the student may need C in it's own right, I am not saying that it is a good way to teach C++ if teaching C++ is your *only* goal.  I would also say that C++ is not a good first programming language anymore (it was back in the late 80s/early 90s).
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-17T10:00:11.040Z
Answers.Text: @VictorEijkhout for 1 it largely depends on how you teach C, C doesn't encourage good programming, but it doesn't forbid it either.  However I agree with you that if your only aim is to teach C++, then teach C++.
Answers.UserDisplayName: Dikran Marsupial
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-13T01:27:34.087Z
Answers.LastActivityDate: 2022-05-13T01:27:34.087Z
Answers.UserDisplayName: Andrew
Answers.Body: <p>You need to stay within the zone of proximal development.</p>
  <p>Learning C++, and learning to program at the same time, is too big a step. People can not learn too much at one time.</p>
  <p>Therefore students should first learn to program, then (if needed) learn C++.</p>
  <p>The ideal language to use when learning to program will be a language that does not need learning, because it has no or little syntax.</p>
  <p>In by experience, (tutoring university students, and working with graduates) Java it too complex to use as a teaching language. Students spend too much time stuck, too much time trying to learn the language, while still having no idea how to program. They can learn to program, because they don't know the language. They can learn the language, because they can't program. If they don't get help to learn to program via a different language, or have “the right stuff“, then they end up not being able to program.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-12T21:02:16.043Z
Answers.LastActivityDate: 2022-05-12T21:02:16.043Z
Answers.UserDisplayName: ctrl-alt-delor
Body: <p>I'm trying to teach C++ to postgraduate students, some of whom have no coding experience. A previous lecturer has left powerpoint presentations and videos but they're simply not engaging enough and nothing sticks in the student's minds. We teach Python via Jupyter notebooks, which works well, although the subject matter is easier. I found an C++ version of jupyter notebooks but I'm not sure it's appropriate for C++ (It's not helped C+ is such a big sprawling language that it's hard to cut down easily.</p>
  <p>What is considered best practice for teaching C++ in 2022. I'm leaning towards thinking a traditional lecture is pretty much the worst way to go, but I'm not sure whether it's just difficult regardless.</p>
  <p>What do you think is a realistic level for students to get to learning C++, given 40 hours of labs, seminars and zoom meetings (in total)?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-11T12:41:33.133Z
Comments.Text: What level are your students? High school? College? And what do you mean by 40 hours of contact time? You only see them for 40 hours?
Comments.UserDisplayName: codingCat
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-11T14:21:10.427Z
Comments.Text: Can I say I wish I'd spoken to you both about 10 weeks ago!
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-11T16:05:29.997Z
Comments.Text: There's always a next semester.
Comments.UserDisplayName: Victor Eijkhout
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-11T21:01:56.907Z
Comments.Text: For those with no coding experience… can you start with something other than C++?
Comments.UserDisplayName: Bergi
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-12T07:35:40.843Z
Comments.Text: Can you explain why c++? It doesn't seem to make much sense for this group of non-coders. Python and many other options (eg R, Matlab, Mathematica...) likely make more sense as they are easier to start with plus students are more likely to use them afterward.
Comments.UserDisplayName: Zizy Archer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-12T09:05:00.430Z
Comments.Text: Not my choice, I'm afraid. Python does seem like an obvious answer though
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-12T12:26:11.820Z
Comments.Text: C++ introduced without pointers/references and move-semantics, etc. is a fairly direct and readable language. Variables, assignments, functions, loops, and conditionals... that's fundamental programming and it's perfectly approachable in C++. Introduce C++ as merely a particular syntax to procedural programming in general.
Comments.UserDisplayName: Matthew M.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-12T20:34:37.100Z
Comments.Text: I have been teaching c++ for many years, the most useful tool I use is codio.com we do pay a subscription but it is worth it!
  You will find a full course ready for you in there.
Comments.UserDisplayName: Stephen Smith
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-14T18:34:56.070Z
Comments.Text: Why are your students learning C++? What is the goal of the class? If they're postgrads, I assume they're highly specialized in some discipline or another (are they all from the same background, if so, which, if it's relevant?) and are in the class in some context of that discipline. This would have a potentially large impact on what you're teaching and how you approach it relative to a random general audience wanting to pick up coding basics. C++ and programming in general are huge topics and there are so many approaches depending on goals.
Comments.UserDisplayName: ggorlen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-16T07:39:47.157Z
Comments.Text: I just wanted to mention that you _can_ use Jupyter notebooks to teach C++, see https://github.com/jupyter-xeus/xeus-cling
Comments.UserDisplayName: blue
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-17T12:49:57.117Z
Comments.Text: Just because it's *possible* to do C++ in jupyter does it make it reasonable? (genuinely asking!)
Comments.UserDisplayName: Rushi
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-19T13:48:36.510Z
Comments.Text: @Rusi presumably it allows you to embed working code fragments within the documentation that explains the concept being demonstrated.  That sounds like a useful thing to me, especially if you are teaching a class that has previously studied Python.
Comments.UserDisplayName: Dikran Marsupial
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-19T14:20:24.373Z
Comments.Text: @DikranMarsupial Yes Knuth-style "literate programming" is one attraction of jupyter. But with a beginner having to just get through basic C++ being the mammoth task it is, I'd question whether secondary frills n spices like LP are relevant here. To me, jupyter "cheats" by postponing the bare necessities of pragmatic programming -- setting up a dev env -- to later
Comments.UserDisplayName: Rushi
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-19T14:24:04.133Z
Comments.Text: @Rusi that is a fair point.  The sort of beginners that are suitable for C++ are the sort that would be happy with vi and make.  I wouldn't teach C++ to beginners anymore, I did back in the late 90s, but the language has evolved so much since then it is a language for experts these days.  It's not just baroque, it's the full Rococo ;o) (but I *like* Rococo)
Comments.UserDisplayName: Dikran Marsupial
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-19T15:36:10.277Z
Comments.Text: @DikranMarsupial Baroque = Bach I like. Baroque = C++ I don't . And I'm reasonably certain that even one who (claims to) love baroque will have his limits. Eg in our time vi, make, ranlib, gdb, etc were de facto part of learning C/C++. Would you add autoconf ?
Comments.UserDisplayName: Rushi
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-19T15:39:06.117Z
Comments.Text: True, I like Rococo C++, but I like build systems to be more "twinkle twinkle little star" for recorder ;o)
Comments.UserDisplayName: Dikran Marsupial
Tags: <course-design>
Title: Redesigning a C++ Course
ThreadText: # Redesigning a C++ Course
  
  (Asked by: username_0 on 2022-05-11)
  
  I'm trying to teach C++ to postgraduate students, some of whom have no coding experience. A previous lecturer has left powerpoint presentations and videos but they're simply not engaging enough and nothing sticks in the student's minds. We teach Python via Jupyter notebooks, which works well, although the subject matter is easier. I found an C++ version of jupyter notebooks but I'm not sure it's appropriate for C++ (It's not helped C+ is such a big sprawling language that it's hard to cut down easily.
  
  What is considered best practice for teaching C++ in 2022. I'm leaning towards thinking a traditional lecture is pretty much the worst way to go, but I'm not sure whether it's just difficult regardless.
  
  What do you think is a realistic level for students to get to learning C++, given 40 hours of labs, seminars and zoom meetings (in total)?
  
  **Tags:** course-design
  
  > **Comments:**
  > **username_1**: What level are your students? High school? College? And what do you mean by 40 hours of contact time? You only see them for 40 hours?  
  > **username_0**: Can I say I wish I'd spoken to you both about 10 weeks ago!  
  > **username_2**: There's always a next semester.  
  > **username_3**: For those with no coding experience… can you start with something other than C++?  
  > **username_4**: Can you explain why c++? It doesn't seem to make much sense for this group of non-coders. Python and many other options (eg R, Matlab, Mathematica...) likely make more sense as they are easier to start with plus students are more likely to use them afterward.  
  > **username_0**: Not my choice, I'm afraid. Python does seem like an obvious answer though  
  > **username_5**: C++ introduced without pointers/references and move-semantics, etc. is a fairly direct and readable language. Variables, assignments, functions, loops, and conditionals... that's fundamental programming and it's perfectly approachable in C++. Introduce C++ as merely a particular syntax to procedural programming in general.  
  > **username_6**: I have been teaching c++ for many years, the most useful tool I use is codio.com we do pay a subscription but it is worth it! You will find a full course ready for you in there.  
  > **username_7**: Why are your students learning C++? What is the goal of the class? If they're postgrads, I assume they're highly specialized in some discipline or another (are they all from the same background, if so, which, if it's relevant?) and are in the class in some context of that discipline. This would have a potentially large impact on what you're teaching and how you approach it relative to a random general audience wanting to pick up coding basics. C++ and programming in general are huge topics and there are so many approaches depending on goals.  
  > **username_8**: I just wanted to mention that you _can_ use Jupyter notebooks to teach C++, see https://github.com/jupyter-xeus/xeus-cling  
  > **username_9**: Just because it's *possible* to do C++ in jupyter does it make it reasonable? (genuinely asking!)  
  > **username_10**: @Rusi presumably it allows you to embed working code fragments within the documentation that explains the concept being demonstrated.  That sounds like a useful thing to me, especially if you are teaching a class that has previously studied Python.  
  > **username_9**: @username_10 Yes Knuth-style "literate programming" is one attraction of jupyter. But with a beginner having to just get through basic C++ being the mammoth task it is, I'd question whether secondary frills n spices like LP are relevant here. To me, jupyter "cheats" by postponing the bare necessities of pragmatic programming -- setting up a dev env -- to later  
  > **username_10**: @Rusi that is a fair point.  The sort of beginners that are suitable for C++ are the sort that would be happy with vi and make.  I wouldn't teach C++ to beginners anymore, I did back in the late 90s, but the language has evolved so much since then it is a language for experts these days.  It's not just baroque, it's the full Rococo ;o) (but I *like* Rococo)  
  > **username_9**: @username_10 Baroque = Bach I like. Baroque = C++ I don't . And I'm reasonably certain that even one who (claims to) love baroque will have his limits. Eg in our time vi, make, ranlib, gdb, etc were de facto part of learning C/C++. Would you add autoconf ?  
  > **username_10**: True, I like Rococo C++, but I like build systems to be more "twinkle twinkle little star" for recorder ;o)  
  
  ---
  
  ## 7 answers
  
  ### Answer by username_1 on 2022-05-11. Score: 7
  
  You are looking at a room full of post-grad students, who are thus convinced of their superior intelligence, some of whom have zero programing experience... I think your only hope is to lean into ***live coding***.
  
  Whatever you do, don't try to start off with a huge example that shows everything all at once, thinking that you will slowly introduce and describe the basics after the fact. This will only intimidate and discourage the newbies.
  
  Start off with the basics, move as quickly as the students will allow and demonstrate everything in the compiler yourself as you go along. In addition to seeing the concepts work in the real world, the code they are creating also acts as note taking and gives them a reference for the future.
  
  Once you are rolling you can fast forward through topics when you see that the students are groking the basics. Covering everything, but spending as little time on it as possible: This is an IDE, it lets you build and compile a program. Commands look like this, notice the dot / arrow notation, it will become important. Variables have a type and hold values. Basic arithmetic looks like this, notice how values are accumulated. Looping and conditions are managed thusly, see how we can nest the structures together. Methods help with organization and are the most awesome boring topic in existence.
  
  What will make all of this stick is having the students code it along with you. Create a basic program demonstrating it all live as you type it in, while the students follow along tying it in on their own computers. Pause after each major topic to give them a chance to solve a mini problem where they use the tool on their own.
  
  Stay away from pointers and references. I know the ideas are at the core of C/C++ but \* and -> notation is enough to send any newbie away screaming.
  
  After each meeting, leave them with some homework. Have them create a project that highlights what they learned, incorporating as many of the past topics as possible. Make the projects as fun and interesting as possible, incorporating graphics as much as you can, even if this means giving them 90% of an app as a starting framework for them to build on.
  
  The more experienced the students get, the more confident they get in their ability, the more time you can spend on lecture instead of demonstration.
  
  Finally, save class structure for the very end. After they have been creating static methods and local/global variables for a while, the idea of encapsulating it all into an object that can have multiple instances should now fit into their brains. This is also the time to introduce the idea of pointers and references.
  
  Now... does all that qualify as best practice? Meh, I don't think there is such a thing in teaching. While I can back it up by mentioning that I have 15 years of experience teaching at both the high school and college level, it is all of course only my humble opinion.
  
  > **Comments:**
  > **username_2**: In general I agree with your answer but I disagree on classes. Students don’t seem to have much trouble with it and on the contrary they seem to appreciate the elegance of code organization. Maybe it helps that I give them exercises that are elegantly expressed with objects.  
  > **username_1**: Agree to disagree. I have students that get organization right from the start, but most students need to drink in the idea of coding and confront a page full of endless left justified code before the need for organization sinks in.  Functions is actually the second topic I cover in my intro course -- right after they get to know the IDE. But, I don't touch on objects in intro at all. The organization of class structure is straight forward, but the fact that you can instantiate multiple instances of the class, each with its own instance variables, can be a bitter pill to swallow.  
  > **username_2**: Happy to disagree.  I used to teach `struct`s before classes, just to get the notion of "bundle of data" in to their heads. Have since stopped mentioning structs altogether, but the examples / exercises still have objects that are data-like. For instance `class Point { double x,y; ...... }` so that you can have `Point Point::shift(....)` and `Rectangle::Rectangle( Point,Point )` (rectangle from topleft/botright points). I don't recall there ever being a problem with that. (Are your materials online?)  
  > **username_7**: Why should I bundle data or use classes? I only care about it after I've tried to manage 16 separate variables and methods that represent one entity and run into problems. I'm unlikely to understand or care about loops or arrays until I've tried to write `person0`, `person1`, ... `person16` and print each one's name or figure out their average age. Students don't typically appreciate a solution without experiencing a problem first.  
  > **username_10**: If you are not going to teach pointers or references, it is an indication that you shouldn't be teaching C/C++ - they are fundamental to the way the language works and the benefits that C++ has over e.g. Java (the complexity of C++ is the cost you pay for that benefit).  +1 for live coding though.  
  > **username_1**: @username_10 I would tend to agree. C/C++ should not be the language you try to teach to first semester students. However, if you are stuck starting students out in C/C++ you should try to soften the blow as much as possible and leave the ramifications of pointer manipulation until they have some mastery over the basic idea.  
  > **username_10**: @username_1 indeed, just because you can do arithmetic on pointers, doesn't mean you should! ;o)  
  
  ---
  
  ### Answer by username_11 on 2022-05-12. Score: 4
  
  Your instincts are correct - there are alternatives to lecturing, but [every pedagogical method has its place](https://teaching.berkeley.edu/news/lecture-or-not-lecture-how-about-maybe-0). I generally reserve lectures as an opportunity to highlight a few difficult concepts from the text and address questions.
  
  I favor OER textbooks, a flipped classroom, and students working on assignments in class. Assignments could be either straight programming tasks or guided exercises. Not sure what content you plan to focus or how dirty you want to get, but there are several decent C++ OER books based on Sphinx/docutils:
  
  1. [OpenDSA](https://opendsa-server.cs.vt.edu) is an interactive open data structures textbook, but people are growing it beyond data structures content. It has config files allowing you to customize your own textbook. I used it years ago, but found working in the environment harder than I liked.
  2. [Runestone Academy](https://runestone.academy/user/login?_next=/) is a general framework for creating interactive OER. My current textbook uses Runestone, but I self-host (on GitHub pages) so that the book is 100% free for students. Runestone can host your course for you, but there are some (small) fees for students. I have not looked deeply into it.
  
  Both of these environments support assessments in the text, but otherwise, the details are different. If you are already familiar with [Sphinx-doc](https://www.sphinx-doc.org/en/master/), I think Runestone has a short learning curve. If you want to see a self-hosted example ([my textbook](https://username_11.github.io/cisc187-reader/index.html)). [Book source](https://github.com/username_11/cisc187-reader) is on GitHub. A [first semester version](https://github.com/username_11/cisc192-reader) based on [How to Think Like a Computer Scientist](https://open.umn.edu/opentextbooks/textbooks/how-to-think-like-a-computer-scientist-c-version) is a work in progress. You could look at that outline to get a sense of what is reasonable for a single semester.
  
  Another thing to consider are the assignments themselves. Most of my assignments are in the style of [Exercism.io](https://exercism.org). Students are presented with a programming problem and they need to write code that passes the unit tests. Most students find this approach both challenging and engaging.
  
  Another approach useful in a flipped classroom is POGIL. There is a Process Oriented Guided Inquiry Learning [(POGIL) in Computer Science](https://cspogil.org/Home) group and they provide activities, training, mentoring, and POGIL workshops-on-request. I have found them to be quite responsive and helpful.
  
  Whatever you do, focus on getting students to write code. You can listen to classical music your whole life and never learn to play an instrument. Programming is not a spectator sport.
  
  As far as content, I prefer to teach a more modern version of C++. Generally, I'm in alignment with [username_1](https://cseducators.stackexchange.com/a/7375/12055) - I focus on coding as much as is possible -> the type system, string and vector first, then functions, structures, and classes mostly in that order - although I use [POD's](https://en.cppreference.com/w/cpp/named_req/PODType) from the first few weeks. I will say that unlike username_1, I cover pointers and references (not in that order) when I cover passing semantics for functions. Something to consider is that if you focus on (post?)-modern C++, you can write much more code that appears to have pass by value semantics, but isn't (move semantics). You can have your examples look simple and then once the basics are understood explain the magic that make the simple looking stuff happen (e.g. move semantics).
  
  I see a lot of courses in a big hurry to teach OO right away. There are a lot of pitfalls to be aware of in OO and C++ is already a language with more pitfalls than most. Classes are collections of functions and data. If students can't write decent functions, then they are unlikely to write decent classes. Classes are everything that functions are and ***more***. Also, C++ is a multi-paradigm language - people need to expect that not everything will be in a class. This can become a religious war, but I assume you have a course outline you are required to follow, so do what you have to do.
  
  
  ---
  
  ### Answer by username_2 on 2022-05-11. Score: 4
  
  I agree that pure lecturing is really bad. I let students do lots of exercises, including during class time. (And just to prove that lecturing is bad: two minutes after they have seen something on a slide they can not remember it for their lab exercise.)
  
  The reason I like doing labs in lecture time is that I walk through the class (with a co-teacher) and look over everyone's shoulder. Tell them "That's good" or "I see you're stuck, take a look at...." or "You can do it that way, but I like .... because ....".
  
  Feel free to use my book. Item 3 on: <https://theartofhpc.com/> It comes with sources for the slides, lots of example programs, and skeleton codes for exercises to get them started. Everything is up to C++17 standards. There are also some fairly nifty end-of-semester coding projects.
  
  > **Comments:**
  > **username_1**: Formative assessment at it's finest.  :-)  
  > **username_2**: @username_1 Right. Giving them a week to get completely stuck on a homework assignment is the best way to lose them entirely.  
  
  ---
  
  ### Answer by username_12 on 2022-05-12. Score: 1
  
  I also teach at the University level and have found great success in teaching C++ by doing visual & interactive program examples, exercises and assignments.
  
  Something like the Coding Train's [Intro Programming](https://youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA) but with C++. You could use [raylib](https://www.raylib.com/index.html) to help provide simple drawing and interactivity.
  
  Hope this helps!
  
  
  ---
  
  ### Answer by username_10 on 2022-05-13. Score: 1
  
  I teach C and C++ in the second year, who were taught Java in the previous year by myself and a colleague. Due to COVID I pre-recorded the lectures I used to give so that the students could watch them in their own time. I indexed the videos at each change of slide so that they could easily navigate to the bit they wanted, which seemed a good compromise between having lots of short unconnected videos and an overly long traditional lecture. The idea was that they would watch the videos, and if they had questions or wanted me to go over examples of something, they could let me know (via a discussion forum) and I would give a live lecture later in the week (just before the lab) which would be a mixture of explaining answers to questions with new slides generated for that week, informal Q&A and live programming demos (my traditional lectures also had lots of that).
  
  This approach seems to work well - many students are uncomfortable asking questions out loud in a live lecture, but were much more comfortable with the chat facility used in the remote live lectures, so there was much more interaction than before and I could be more responsive to student's difficulties/questions.
  
  Different people like to learn in different ways, and this approach works whether you actually *like* watching formal programming lectures, or just want to watch them in sped-up 10 minutes sections, or ignore them altogether and read books/experiment with the computer.
  
  The key thing is for the lab classes and exercises to be well designed and get the concepts in the right order.
  
  As we do C and then C++, we cover pointers and memory allocation in C. Note: we teach C and C++ as distinct goals, we are not teaching C purely as a prelude to C++. This is a major stumbling block for students to it is important they understand it properly at an early stage. As they have done Java the year before, they find the concept of the variable actually being the object (rather than a reference) rather difficult and they tend to write very inefficient C++ code, so that is also something to emphasize early. Being from a Java background they have difficulties with C++ references because Java references are epsilon different from a C pointer and the terminology confuses. I approach classes via structs which we did earlier in the C part of the course.
  
  > **Comments:**
  > **username_2**: C "pointers" are really memory addresses, and are almost never needed in C++. So if you're teaching that on the way to C++ it's a waste of effort, and you'll probably teach them bad habits. C++ does have real pointers, usually called "smart pointers", but those are not needed in many applicaitons. In other words, I disagree with many aspects of your teaching strategy.  
  > **username_2**: Well, you wrote "As we do C and then C++" so it does sound like you're using C as a precursor to C++.  For what it's worth, I teach C++ first, and then show how some things that are simple in C++ can be hacked around in C.  
  > **username_2**: What you call "pointers" are not pointers. They are addresses. Smart pointers are to your "pointers" as `std::vector` is to automatic arrays: a better way to do stuff that is error-prone in C. You can perfectly well use smart pointers to implement linked lists and such with out ever having seen C "pointers". A wider point about "understanding things": it's called abstraction. You can teach to a level of abstraction, and as long aas that's a consistent and rich enough vocabulary, you don't have to teach the layer below it. So: I teach `std::vector` and not `new x[5]`; ditto pointers.  
  > **username_2**: Well, I do point out the costs of re-allocation in `std::vector`, in the abstract. I think the lower layer should only be taught when it has a detectable impact.  
  > **username_2**: You're right, I don't care about linked lists as such. However, linked lists are the simplest example of a Directed Acyclic Graph. And DAGs are very common in computational science.  
  > **username_2**: No, you are completely wrong. I have no idea how you manage to misread me this much. The topic was smart pointers vs bare pointers and I said I use smart pointers to teach linked lists. I never mentioned the `linked_list` container API, you did. The thing I don't teach is how smart pointers are based on bare pointers.  
  > **username_2**: When do you need the `get()` method?  
  > **username_2**: No I don't. If you do that they need to understand rvalue, lvalue, .... before they can understand the simplest mechanisms.  
  > **username_2**: With my apologies for an easily misunderstood remark, let me clarify. I teach to undergraduate engineering students. Those are maybe not average beginners, and you may very well teach to a very different audience. Fact is that I do get students with minimal or no programming experience, who need C++ in their further career, and they seem to deal with it just fine.  
  
  ---
  
  ### Answer by username_13 on 2022-05-13. Score: 0
  
  If the point is to learn C++, you must learn C. Must. You must understand addresses, pointers, structures, argument passing, memory allocation, the stack and a backtrace. You must understand implicit conversions and the difference between floating point and integer math and the limits and sizes of built-in types. You must understand linkage. Any way you do it, you can't escape these topics.
  
  > **Comments:**
  > **username_14**: Learning C is actively detrimental to learning C++. Yes, you must learn pointers, linkage, etc. but there is no reason to learn C itself since a great many things in C have been superseded in modern C++ (or even old C++).  
  > **username_10**: @username_14 the fact that a lot of systems programming is (best) done in C is a good reason to learn C.  The other advantage of C is that the students are capable of fully understanding it all as they learn, because it is all very simple and nothing is hidden.  Learning C++ directly requires the students to take a lot on trust, and using things without understanding what you are doing seems somewhat antithetical to university education (and is a bad habit students easily fall into because the are often goal-directed).  Both approaches have advantages/disadvantages.  
  > **username_14**: @username_10 There may be many good reasons to learn C, but in order to learn C++ is not one of them.  
  > **username_10**: @username_14 C++ is a superset of C, you can't learn C++ without learning C, it is just a matter of emphasis on which parts of it you use.  If you want to learn OOP, then learning Java first is better than C++.  C++ is no longer a good language to learn first (as it was back in the late 1980s) - it is too complex and compilers too unfriendly (due to the complexity of the language).  
  > **username_10**: Having said which, learning C+=0.5 (i.e. C but without OOP), which is the approach some take, is the worst of all worlds.  
  > **username_14**: @username_10 It is not true that you need to learn the C subset in order to learn C++. Many C features have been superseded in C++ and are rarely used in C++ - certainly not at the beginner level. malloc/free would be the most obvious but there are others. What's more the way you program in C and the way you program in C++ are different, learning the C way - as a beginner - is unhelpful to learning the C++ way.  
  > **username_10**: @username_14 malloc/free is part of the standard library, not the language.  The only fundamental difference between the ways you program in C++ that you don't in C are OOP (you can do this in C, but it isn't worth the hassle), operator overloading and templates (although you can do that in C if you want in the way C++ did before templates were part of the language).  C++ uses much the same control structures, fundamental types and functions as C.  
  > **username_10**: "C++ way" is a superset of "C way", you can do all the same things, but with more stuff added.  C++ is a multiparadigm language - "C way" is one of those paradigms.  And as I said (possibly another thread) C++ is not a beginners language anymore (IMHO).  
  > **username_15**: Re, "C++ is a superset of C." That was true back in the early days of C++, but the C++ language has diverged from C in subtle ways. If you want to teach C++, then by all means, start with a small subset, and build on that subset bit-by-bit. But you could have avoided most of this argument simply by not calling the subset, "C."  
  > **username_2**: Unless you have experimental evidence of your notions, I will disagree. 1 First learning C leads to really bad C++ code. 2. Many parts of C are not needed because C++ does things better. 3. Many experts (find Kate Gregory's lecture "Stop teaching C") agree with me.  
  > **username_10**: @username_15 most of the things that are legal in C but no longer legal in C++ are things that most C programmer wouldn't do anyway (at least not anymore).  The reason for teaching C first is because the student may need C in it's own right, I am not saying that it is a good way to teach C++ if teaching C++ is your *only* goal.  I would also say that C++ is not a good first programming language anymore (it was back in the late 80s/early 90s).  
  > **username_10**: @username_2 for 1 it largely depends on how you teach C, C doesn't encourage good programming, but it doesn't forbid it either.  However I agree with you that if your only aim is to teach C++, then teach C++.  
  
  ---
  
  ### Answer by username_16 on 2022-05-12. Score: -2
  
  You need to stay within the zone of proximal development.
  
  Learning C++, and learning to program at the same time, is too big a step. People can not learn too much at one time.
  
  Therefore students should first learn to program, then (if needed) learn C++.
  
  The ideal language to use when learning to program will be a language that does not need learning, because it has no or little syntax.
  
  In by experience, (tutoring university students, and working with graduates) Java it too complex to use as a teaching language. Students spend too much time stuck, too much time trying to learn the language, while still having no idea how to program. They can learn to program, because they don't know the language. They can learn the language, because they can't program. If they don't get help to learn to program via a different language, or have “the right stuff“, then they end up not being able to program.
  
  
  ---
  
  