Bjarne responds to "How to teach C++"

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 859 Views - Last Post: 06 December 2018 - 11:19 AM

#1 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6565
  • View blog
  • Posts: 22,530
  • Joined: 05-May 12

Bjarne responds to "How to teach C++"

Posted 02 December 2018 - 06:38 PM

It was interesting to see Bjarne Strustroup reply to this blog post: How to teach C++:

Bjarne Stroustrup, on NOVEMBER 28, 2018 AT 3:33 PM, said:

When teaching C++ (or anything else), you need to adapt to the background and need of your students.

I have two basic approaches:

For complete beginners, I use “Programming: Principles and Practice using C++”. It focuses on fundamental program development techniques. Like Marius Elvert, I start with call by value as the simplest and it is good enough initially. References and pointer come later (e.g., chapter 17 for pointers).

For people who are already programmers, I use “A Tour of C++” (2nd edition 240 pages). It is deliberately short, but covers a lot. I assume that its readers can use the Web to look for details (e.g., cppreference.com and the C++ Core Guidelines). Its readers get pointers and reference in Chapter 1.

I do not use “The C++ Programming Language” for teaching, only as backup material for more advanced students.

In both cases, I try hard not to get sucked into technical subtleties. In both cases, I use simple data structures (e.g., std::string and std::vector) from the very beginning. Neither group needs to know everything about anything in C++, at least not during a first course.


My key takeaway though, I've highlighted in bold below:

Bjarne Stroustrup, on NOVEMBER 28, 2018 AT 3:33 PM, said:

PPP is roughly C++14 and Tour2 is C++17 plus a bit from C++20. I use newer features to simplify code examples and explanations, never just to impress. As long as you don’t try to explain everything, “modern C++” can be much simpler than older C++.
Obviously, older styles and facilities has to be explained eventually or the student cannot read older C and C++ code, but I postpone that until “later” when the student has the background to understand and appreciate the differences.


Is This A Good Question/Topic? 0
  • +

Replies To: Bjarne responds to "How to teach C++"

#2 baavgai   User is online

  • Dreaming Coder
  • member icon


Reputation: 7328
  • View blog
  • Posts: 15,239
  • Joined: 16-October 07

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 05:16 AM

The problem is that the student isn't constrained to the well curated classroom. They have this amazing resource called the web where, unfortunately, you'll be offered "older C++" more often than not.

In a sense, this feels like the approach to teaching foreign language students. Keep it as simple as possible. The student won't be able to use the language effectively in the real world, but they might be able to offer a greeting and ask for directions to the bathroom.
Was This Post Helpful? 2
  • +
  • -

#3 jimblumberg   User is offline

  • member icon

Reputation: 5615
  • View blog
  • Posts: 17,312
  • Joined: 25-December 09

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 08:35 AM

Quote

The problem is that the student isn't constrained to the well curated classroom.

Quite true. And no two students even start at the same level.

Quote

They have this amazing resource called the web where, unfortunately, you'll be offered "older C++" more often than not.

Yes the web is amazing with all sorts of code, from good modern code to good old code and let's not forget the horrible modern code and the horrible old code that a poor student has no way of differentiating between the good, the bad, and the truly ugly code of any era. And unfortunately the bad and the ugly are available in much higher quantities.

Quote

In a sense, this feels like the approach to teaching foreign language students. Keep it as simple as possible. The student won't be able to use the language effectively in the real world, but they might be able to offer a greeting and ask for directions to the bathroom.

Agreed. However how would you go about teaching a group of students, many of whom have no real idea of how a computer really functions, how to program in modern C++ or any other language for that matter?

I do feel that before the end of the first semester that the student should have been introduced to the more basic data structures and how a computer operates at a basic level.

Jim
Was This Post Helpful? 1
  • +
  • -

#4 baavgai   User is online

  • Dreaming Coder
  • member icon


Reputation: 7328
  • View blog
  • Posts: 15,239
  • Joined: 16-October 07

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 09:46 AM

View Postjimblumberg, on 03 December 2018 - 10:35 AM, said:

Agreed. However how would you go about teaching a group of students, many of whom have no real idea of how a computer really functions, how to program in modern C++

I wouldn't. C++ is pretty much at the bottom of my list of first language choices.

View Postjimblumberg, on 03 December 2018 - 10:35 AM, said:

or any other language for that matter?

Well, that's a different question. I'd probably go with Python as a first choice. Then, as per usual, start working through the building blocks of the language. My critique of C++ is that, as languages go, it offers more intrinsic stumbling blocks and complexity than most. My response is merely noting that Bjarne himself is acknowledge this, but his recommendation seems more an apology than a solution, given the legion of languages available.

What could be done better? Here I think my human language simile still has a few teeth. Languages are taught via grammar but are assimilated via use cases. A student can read mountains of material on loops, but until they've used, and failed to use, a loop in their own code, it really has no context.

Writing new code is hard, but breaking extant code is pretty easy. I feel offering simple examples where the student is challenged to tweak the functionality tends to yield better results than learning a mountain of keywords and starting with a blank screen.
Was This Post Helpful? 2
  • +
  • -

#5 jimblumberg   User is offline

  • member icon

Reputation: 5615
  • View blog
  • Posts: 17,312
  • Joined: 25-December 09

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 12:21 PM

Quote

I'd probably go with Python as a first choice.

Probably a good choice. But how would learning Python first aid in learning C++ later?

Quote

My critique of C++ is that, as languages go, it offers more intrinsic stumbling blocks and complexity than most.

Very true. But with those stumbling blocks and complexity come more power.

Quote

My response is merely noting that Bjarne himself is acknowledge this, but his recommendation seems more an apology than a solution, given the legion of languages available.

Actually I'm not totally convinced this is the case. I think learning modern C++ using the modern containers like std::string, std::vector, and the C++ streams is a much better route than stumbling over pointers, arrays, and other more complicated features of C++. My biggest complaint is that, unlike Python, there is no standard support for any sort of graphics interfaces (and several other "subsystems as well) which make working on "real world" examples extremely problematic.

Jim
Was This Post Helpful? 1
  • +
  • -

#6 baavgai   User is online

  • Dreaming Coder
  • member icon


Reputation: 7328
  • View blog
  • Posts: 15,239
  • Joined: 16-October 07

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 01:30 PM

View Postjimblumberg, on 03 December 2018 - 02:21 PM, said:

But how would learning Python first aid in learning C++ later?

The first programming language is the hardest. The student is not just learning a programming language, they're learning how to program. Specifically, they're learning how to reason like a programmer. Without successfully acquiring this ability all attempts at using any computer language will be futile. Conversely, once someone has gotten a handle on problem solving in any programming language, then next one is more about language idiosyncrasies than the real challenge.

View Postjimblumberg, on 03 December 2018 - 02:21 PM, said:

But with those stumbling blocks and complexity come more power.

LOL! Power is useless, and dangerous, without the ability to competently wield it.

View Postjimblumberg, on 03 December 2018 - 02:21 PM, said:

than stumbling over pointers, arrays, and other more complicated features of C++.

And yet, this is inevitable. That's kind of the point. And if you aren't actively blowing a limb off with such things then you're missing out on that power, no?

View Postjimblumberg, on 03 December 2018 - 02:21 PM, said:

there is no standard support for any sort of graphics interfaces

Agreed. I actually prefer Java to Python for a more standard graphic approach. But all modern languages suffer from multi graphic melodrama.

When talking new programmers, first languages, and simple graphics, I inevitably wax nostalgic for BASIC: the messy GW kind with the line numbers. While a truly horrid language, it had few commands, nice primitive graphics, and offered a tinkering kid all they needed to actually make something.
Was This Post Helpful? 2
  • +
  • -

#7 jimblumberg   User is offline

  • member icon

Reputation: 5615
  • View blog
  • Posts: 17,312
  • Joined: 25-December 09

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 02:14 PM

Quote

Conversely, once someone has gotten a handle on problem solving in any programming language, then next one is more about language idiosyncrasies than the real challenge.

But, IMO, it takes more than the allotted time to learn the first language so unless there is a follow up class using the same language it doesn't really matter the language.

Quote

LOL! Power is useless, and dangerous, without the ability to competently wield it.

Agree, and I never said otherwise. Even C which is orders of magnitude simpler is extremely dangerous in the hands of novices.

Quote

And yet, this is inevitable. That's kind of the point. And if you aren't actively blowing a limb off with such things then you're missing out on that power, no?

This is why I think beginning programming classes should be at least two semesters with the same beginning language, preferably in consecutive semesters. I really don't think it is just a problem with a particular language but a lack of time. Even if the beginning language is Python I think they need more time to delve into the language to be able to develop problem solving skills in the language. You cant, IMO, develop these skills until you actually understand the language.

Also to be honest I think the bigger issue, regardless of the language, is the quality of the instructors,the materials used by the instructors and time allotted. But I tend to agree, C and C++ tend to take more resources, time, instructions, etc. than Python or Java or maybe C#. But what I worries me is that many students will take these beginning classes and not take the required effort to learn the topics because they're really interested in some other language and don't see the point of learning something else just to get to their language of choice.


Quote

When talking new programmers, first languages, and simple graphics, I inevitably wax nostalgic for BASIC: the messy GW kind with the line numbers. While a truly horrid language, it had few commands, nice primitive graphics, and offered a tinkering kid all they needed to actually make something.


Yes it was a horrid language but, it did make you make a basic design of the program before you started coding because of the limitations, especially the limitations of the editor and because is could be difficult to add code to the middle of the program if you forgot to use large enough gaps in your line numbers or you used too many gaps that made some of the branch statements impossible.


Overall I think we agree more than we disagree. IMO, the current state of most university training leave much to be desired (no matter the subject).

Jim
Was This Post Helpful? 2
  • +
  • -

#8 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6565
  • View blog
  • Posts: 22,530
  • Joined: 05-May 12

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 02:29 PM

When I was in college first 2-3 weeks of the freshman intro to programming class was all about how computers work: from a high level view of registers, memory, instruction pointers, I/O, etc. The only "programming" involved then was drawing flowcharts in the 3rd week before actually doing any programming in Pascal. Second semester continued on with Pascal but covered data structures and algorithms. Also in the second semester, C was introduced in the context of a "systems programming" class -- it wasn't quite on "Operating Systems" class, but it was meant to teach how to interface with the metal, as well as a light intro to Unix and other OSes other than DOS. The following year, the freshmen went straight into C so that they would do C++ soon afterwards. I feel that my batch got the better learning experience, but my view may also be biased since I'd already taught myself to program in BASIC, Assembly, Forth, and Pascal before even going into college.
Was This Post Helpful? 1
  • +
  • -

#9 jimblumberg   User is offline

  • member icon

Reputation: 5615
  • View blog
  • Posts: 17,312
  • Joined: 25-December 09

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 03:38 PM

Quote

When I was in college first 2-3 weeks of the freshman intro to programming class was all about how computers work: from a high level view of registers, memory, instruction pointers, I/O, etc. The only "programming" involved then was drawing flowcharts in the 3rd week before actually doing any programming


I think that this is missing in many intro courses today and when it is missing the students are at a real handicap, IMO.




Quote

The problem is that the student isn't constrained to the well curated classroom.

But you still hear the "not studied yet" defense from many students, which when true is a sign of a bad instructor, IMO.

Jim

This post has been edited by jimblumberg: 03 December 2018 - 03:38 PM

Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6565
  • View blog
  • Posts: 22,530
  • Joined: 05-May 12

Re: Bjarne responds to "How to teach C++"

Posted 03 December 2018 - 07:43 PM

This is tangentially related since we drifted over to what language to use to teach programming: Modern Logo:

Quote

Brian Harvey is a Berkeley professor who not only co-wrote Berkeley Lisp, but authored three books that, amazingly, teach the whole of computer science using nothing but Logo.

Was This Post Helpful? 0
  • +
  • -

#11 baavgai   User is online

  • Dreaming Coder
  • member icon


Reputation: 7328
  • View blog
  • Posts: 15,239
  • Joined: 16-October 07

Re: Bjarne responds to "How to teach C++"

Posted 04 December 2018 - 05:45 AM

View Postjimblumberg, on 03 December 2018 - 04:14 PM, said:

Overall I think we agree more than we disagree.

Agreed.

View Postjimblumberg, on 03 December 2018 - 04:14 PM, said:

I really don't think it is just a problem with a particular language but a lack of time.

Semi agree. I completely agree that lack of time for the material is a major factor. Given this, the complexity, or the cost of entry, for programming languages varies, and that also impacts time. Learn a higher level language and later find out about all the messy memory management that made the magic happen.

View PostSkydiver, on 03 December 2018 - 04:29 PM, said:

before actually doing any programming in Pascal.

Ah, Pascal! My high school had BASIC and then, advanced programming, Pascal. In college, as well, Pascal with the CS major go to language. Turbo Pascal, in particular, offered graphics out the box.

I do recall CS classes often going several sessions before getting to the actual "write a program" part. I was not a fan of this as student, though I understand the rationale.

Logo... when I was still in high school I got a summer job as a teaching assistant for kids grades two through five. We taught Terrapin Logo on Apple ][ computers. It was actually encouraging how well some kids took to it.

Logo never died as hard as BASIC ( granted, nothing did,) but I am surprised it didn't hang in better. Years ago the "One Laptop per Child" project offered something called "Turtle Blocks" that greatly impressed me. You can actually try this live, click on the turtle. To my knowledge, this was the first "blocks coding" language, predating critters like Scratch by a few years.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6565
  • View blog
  • Posts: 22,530
  • Joined: 05-May 12

Re: Bjarne responds to "How to teach C++"

Posted 05 December 2018 - 09:03 PM

It seems that we are settling that C++ is not really the best first language to teach students how to program. Keep in mind, though, that the typical college progression has students learning data structures and algorithms in their second semester, and assembly programming in their second year. To me, the "shoot your leg off" catastrophes students invariably run into while learning C++ prepares them for the even worse consequences of errors in assembler programming; and at the same time C++ gives them something they can use in their data structures and algorithms class.

Would C be a better option to provide a stepping stone for both of those later classes?

Or does assembly not really need a stepping stone as long as students already know how to program in any high level language? It's just a matter of teaching students how the magic in the high level language gets implemented if you had to no compiler to lean on.
Was This Post Helpful? 0
  • +
  • -

#13 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11325
  • View blog
  • Posts: 19,369
  • Joined: 19-March 11

Re: Bjarne responds to "How to teach C++"

Posted 05 December 2018 - 10:29 PM

Quote

It seems that we are settling that C++ is not really the best first language to teach students how to program


If I can butt in, I'd suggest that there ain't no such animal, and in fact it's probably worth trying to maintain some airspace between "language" and "programming".
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6565
  • View blog
  • Posts: 22,530
  • Joined: 05-May 12

Re: Bjarne responds to "How to teach C++"

Posted 06 December 2018 - 08:08 AM

Perhaps... So does that mean going all the way back to using flow charts and "recipe" cards when trying to teach programming? That seems to handle the procedural languages, but how to teach object oriented programming, as well as, functional programming?
Was This Post Helpful? 0
  • +
  • -

#15 jimblumberg   User is offline

  • member icon

Reputation: 5615
  • View blog
  • Posts: 17,312
  • Joined: 25-December 09

Re: Bjarne responds to "How to teach C++"

Posted 06 December 2018 - 09:45 AM

Quote

It seems that we are settling that C++ is not really the best first language to teach students how to program.

In most cases probably. However, IMO, C++ can be taught as the first language by a very knowledgeable instructor with good text books and enough time. And mentioning time, it is not only the instructors that need adequate time but the students need to reserve adequate time as well.

Jim
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2