Pointer in C++ / C was the most anal-ystic concept I have ever come across.

  • 3
    Just for future reference, the devrant category is for rants about devRant itself.
  • 1
    ok I was not aware. sorry
  • 1
    @imshravan easy enough to miss, don't worry about it.
  • 2
    And it's just an unsigned number.

  • 1
    @iiii with a specific interpretation that actually hides a metric ton of complexity that the OS and underlying hardware keep from you

    I'm not disagreeing, but pretty much all data on a digital computer is just unsigned numbers
  • 0
    @RememberMe as far as I've heard about pointers from different people, thinking of them as just numbers makes them much less obscure and much more understandable overall. They become much less arcane
  • 2
    @iiii but numbers lie
    Numbers have properties that pointers don't (like addition and every number being same-ish. Pointer accesses can very wildly in access time and bandwidth).

    We were taught pointers as abstract arrows that happen to be represented by unsigned numbers in the von Neumann big row of memory abstraction that CPUs follow. I think that explanation is clearer because it decouples what a pointer is from how it's implemented. It's an indirection, just an arrow to something, almost like what a pronoun does in a sentence. Because computers represent everything with numbers, the arrow is also a number. Because von Neumann abstraction needs a linear contiguous memory space, the pointer-numbers occupy a linear contiguous memory space.

    Basically, the same reason why explaining recursion via call stacks is bad. Recursion has nothing to do with stacks at all, it's just the ability of something to refer to itself, usually by using its name as an indirection (hint hint abstract pointer) though there are technically other ways of doing it. It's just that ordinary function call on CPUs happens via call stacks so that's the perspective you generally learn. Important because there's no reason why recursion can't have other implementations (conversion to iteration for primitive recursion, unrolling, spatial/parallel hardware or concurrent processes etc.).
Add Comment