r/ProgrammingLanguages • 🧿 Pipefish • Apr 28 '26

Hindsight languages

A thought experiment. What languages should they have been writing in the 60s, 70s, 80s, 90s? We can see their faults, in hindsight, and also we've had some really cool ideas since then --- but we can't answer this just by pointing to our shiny new modern languages and saying "they should have done it like that", because of compile times.

(E.g. Pipefish is meant to be for rapid iteration and livecoding, and also does a topological sort on everything at compile-time so you can do top-down declaration. Those wouldn't be compatible goals in the 1980s, I can get away with it now.)

So for example if we think of "a better C", are there any cool modern ideas they could and should have used back in 1972, had they known about them --- or should they just have tweaked the precedence slightly, found a less arcane way of describing types, and left it at that?

39 Upvotes

72 comments sorted by

View all comments

Show parent comment

2

u/yuri-kilochek Apr 30 '26

Well from a C perspective, nullability is a consequence of the memory model. A pointer is just an address, there's no other associated info. You don't even know if it's an address inside your allocated memory space. NULL (0x0) isn't even necessarily special, its just another address. In plenty of embed systems its a valid, writable/readable address. You can make new addresses with pointer math or casting, whats the static type in that case?

You aren't actually allowed to do what you describe in standard C. It's not legal to do arithmetic on NULL, or increment an object pointer out of bounds of the complete object (one that isn't a subobject of another object) it points to. So it's not just an address, but tracking this metadata is the responsibility of the programmer, the compiler and runtime don't help you.

1

u/Norphesius Apr 30 '26

I was imprecise and not quite accurate with what I said (as other people have pointed out). NULL is special, and usually 0x0 is NULL, but it doesn't have to be.

That being said, even if the particular concept of NULL didn't exist in the C standard spec, you would still probably have common convention of 0x0 or some other address acting as "this address is invalid" informally (although more error prone, since you could write to it). Whether explicit or implicit, NULL & C are bound together.