4 ms·
There has to be a bottom to the stack. What I mean is, at some point types become bytes and instructions. Not every program or interaction is capable of being e
by hctaw 6y ago
There has to be a bottom to the stack. What I mean is, at some point types become bytes and instructions. Not every program or interaction is capable of being expressed at every levels of that stack, the invariants must be broken in code and maintained explicitly by programmers on either side of APIs. That simple fact is why FFI boundaries are inherently unsafe.
This doesn't have to do with C, it has to do with the nature of systems programming - not everything can be baked into the one type system to rule them all that is checked by all programs in all languages at compile time. Metadata is insufficient, you need runtime type checking, which is not free.
And to be honest I don't think this is an attractive thing to strive for. OS APIs are not that hard to program against (well, maybe Windows APIs are). Differences between OS's and versions are, however. We don't really need safer systems interfaces, what we need are standard ones that actually work to solve hard systems problems like asynchronous i/o, real time scheduling on non-realtime kernels, and arbitrary control flow. These are very unsafe things that do not have good solutions in the OS APIs, adding strict types where they are not needed creates little value for the systems programmers that want to make cool new systems.
- withinboredom 6y agoSo much this. People (and languages) seem to forget that an HTTP request is a string of bytes (another “bottom of the stack”). A JSON object isn’t a type, it’s a string of bytes.
- anfilt 6y agoI would say it's more accurate to call an HTTP request or a JSON object a subset of the set of all strings. If step out the realm of sets and into programing languages types are very similar to sets. Heck there is type theory which also is very similar to set theory, but has a few difference.
- deleted 6y ago[deleted]