If you gaze long into an abyss, the abyss also gazes into you. --- Nietzsche
...but what about the void?
Let's look into the void together.
What do you see --- nothing or anything?
Same word. Different meanings. Different worlds.
In C: void* = "anything" (actually unknown)
It means: "This points to something... I just won't tell you what."
int x = 10;
void *ptr = &x;
That void*:
- can point to any data
- carries no type information
- forces you to decide what it is
printf("%d", *(int*)ptr);
Which means:
- You must cast it
- You can be wrong
- The compiler trusts you anyway
Technically it's not "anything" --- it's just unknown.
In modern languages: void = nothing
void myMethod() {
// returns nothing
}
No tricks. No guessing.
Just: "There is no value here."
What actually changed
Modern languages didn't remove power --- they moved responsibility:
- Generics instead of raw pointers
- Type systems instead of blind casts
- Memory safety instead of "good luck"
The mental trap
How can the same word mean both?
- C-style thinking: unknown data (
void*) - Modern thinking: no data (
void)
Same keyword. Different abstraction level.
Analogy
C
void*--- a sealed box. You must label it yourself.Modern
void--- no box exists.
Honest question:
Do you ever miss void*... or are you happy letting the compiler carry that burden?