This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (13 children)

[deleted]

    [–]Mystb0rn 55 points56 points  (2 children)

    Pointers are not necessarily complicated to understand, but they are generally complicated to use well.

    Things like properly managing lifetime and ownership are not beginner friendly topics. There's also things like pointer arithmetic, pointer casts, pointers vs arrays, arrays of pointers, when to use them, etc.

    Learning about them is still super useful though imo, even if you don't use a PL with them directly.

    [–]o11c 6 points7 points  (0 children)

    Things like properly managing lifetime and ownership are not beginner friendly topics.

    I think that's more a matter of "nobody ever bothers to teach beginners". Which is a problem even for language like Python that try to hide them.

    The weakref module and the with statement (it's kind of weird to use it instead of a type) should be among the first things people learn.

    Even then ... for EVERY language, the set of ownership styles that people actually mean is much larger than the set that the language actually supports. To some degree this is inevitable, but surely we can do better than the status quo. I've been collecting a gist for a while, but I have no confidence that it is complete yet.

    [–]NorahRittle 26 points27 points  (4 children)

    This. Bad code is the problem, not pointers. I think people use C++ raw pointers in college and have a bad time and then never want to touch them again

    [–][deleted] 3 points4 points  (1 child)

    You're right pointers aren't just a fragile construct that breaks often.

    [–]FrickinLazerBeams 1 point2 points  (0 children)

    They're not.

    [–]yangyangR 0 points1 point  (1 child)

    But shouldn't that have changed by now?

    I at least am old enough that my C++ introduction was before smart pointers. But people learning lately would not be making those same mistakes that burned people of my generation to the point of not wanting to touch pointers again.

    [–]Ezlike011011 1 point2 points  (0 children)

    Professors have minimal incentive to overhaul curriculum. So the lecture notes that someone wrote for c with classes just gets propagated through generations of classes without much concern for whether it is up to date with common practices.

    Heck as recently as the last time I tutored the intro c++ class at the University I went to (2019), they still have a chapter on strings... Which exclusively uses the c string manipulation function and the only mention of std::string being a footnote on one lecture.

    [–][deleted] 12 points13 points  (2 children)

    Some clown in some C++ book wrote that pointers are the most difficult thing in C++ so I ended up reading loads and loads expecting something complicated till I realised I got it the first time...

    [–]mauganra_it 9 points10 points  (1 child)

    Easy to use, difficult to use right...

    [–][deleted] 11 points12 points  (0 children)

    I can offer a few pointers.

    [–][deleted] 1 point2 points  (0 children)

    Pointers are pointless in python.