Quote:Original post by DevFredQuote:Original post by gharen2
Personally, I wish more classes taught about pointers early.
The problem is: IMHO there are no simple examples where pointers make sense (without arrays and dynamic allocation), except for emulating pass by reference (by passing pointers by value). Maybe you have a good example?
I think the best solution is to not start with a language like C. Start with something like Ruby where everything is a pointer. Then, when you get to variables in C, people will be wondering why you'd bother with something that wasn't a pointer. At least, that's what I thought when I started learning C after Smalltalk and Java.
If you want to stay in C, I think a good way would be to not start with stuff like declaring a variable in main(). Have them interact with an API from the start and have the API only interact through pointers. Maybe it doesn't "make sense", but it doesn't need to because the only reason it needs to make sense is to avoid questions like, "Why use pointers when variables are so much easier?" If you never told them about hammers, they won't question why you're solving the problem with a screwdriver.