Quote:
Linked lists are great for teaching how pointers work, but that does not imply they are great for teaching how to do manual memory management with dumb pointers.
Could you expand on that possibly? If linked lists by implication aren't great for teaching how to do manual memory management, then how do they teach how pointers work at all?
Quote:
I don't get your "this is a dumb C++ example, this is a good C example." A data structure is language independent
I think the point is that C has more implementation options than C++ does. Consider the standard <list> library, what would you change about it? The answer is probably not much. So most alternative interfaces will have funny problems that the standard one doesn't have. And I highly doubt that a student would reproduce the standard interface, unless there was a lot of direction. But that's just what I think about what he's saying. You might want to reread that part.
Quote:
There is always a point in having people learn to implement their own data structures
What do you think that point is?
Quote:
You know, using a doubly linked list for education of pointers, smart pointers and circular references is a good foundation, I think. People will understand 1) how the concept of pointers work (we can easily add and remove nodes everywhere)
Well, I agree, but not for the reason that you stated. To be able to add and remove nodes everywhere, a linked list is self-referencing. Pointers are the implementation tool you have for that. The way pointers work is independent from that. But seeing a practical use of indirection helps explain why you need it. People also get practice dealing with indirection, so they learn what is required of them.
In my opinion, although this depends on aptitude, the linked list data structure also helps you establish abstract thinking that you need to understand what pointers do. It's reasonable to assume that you don't understand what a pointer does until you can see pointees and arrows with your mind's eye.
Quote:
2) make_unique* for new dynamic allocations 3) weak_ptr for dealing with circular references, and the knowledge that it's just not point and shoot - even with smart pointers, you have to be careful about circular references or you will get memory leaks.
That seems to me like it teaches a lot of valuable stuff, the C++ way.
And I agree with you because I think smart pointers can teach all the things I mentioned above. It probably just takes a skilled teacher and the right lessons. I wish I had your optimism. I think that the semantics of all the smart pointers you mention have the potential to create information overload though, and then we end up with people who don't necessarily understand the linked list data structure. It would be a small miracle if they came out of that understanding smart pointers.
[edit] I want to be clear that I don't hold you responsible for the problems with the approach that you advocate (well, maybe I should...) BUT I don't expect you to provide me with the latest and greatest way to run a CS course. [/edit]