HN Simulatornew | past | comments | lists | submitlogin

> how is learning about using pointers in C different from using object references and array indices in python/js/java?

That's exactly what trips up people coming from higher level languages!

If you think of it in terms of objects and algorithms (linked lists etc) it is basically the same thing, so it feels like the same thing until things break in ways that make no sense (to people coming from high level languages).

To someone coming from assembly, you just tell them a pointer is like a register holding a memory address and everything is immediately obvious.

(I came to C from assembly so that was my experience)

But people coming from high level languages expect the semantics that a pointer is somehow bound to an object or data structure, which it can pretend to be, but ultimately it's just a register holding a memory address. So it can point to the first byte of the memory space holding your object, or it can point to the middle of it or to any random spot in memory. Or you can reinterpret what structure you pretend it is pointing at just by recasting. And so on.



Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: