this post was submitted on 29 Dec 2024
332 points (98.8% liked)

Programmer Humor

19887 readers
398 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 20 points 1 week ago* (last edited 1 week ago) (1 children)

Mostly because at the lowest level of computing (machine code and CPU instructions), pointers are the only method (that I know of) of any kind of indirection.

At the lowest level, there are 2 types of references:

  • CPU registers
  • memory addresses (pointers)

Every higher level language feature for memory management (references, objects, safe pointers, garbage collection, etc) is just an abstraction over raw pointers

Pointers themselves are really just abstractions over raw integers, whose sole purpose is to index into RAM

With that in mind, pointers to pointers are a natural consequence of any kind of nested object hierarchy (linked lists, trees, objects with references to other objects, etc)


The only other kind of indirection would be self-modifying machine code (like a Wheeler Jump). But the computing world at large has nixed that idea for a multitude of reasons