can a language be safe and be a subset of C?
Imagine you start with the C language and then make the following changes:
- Remove pointer arithmetic. You want an array, you declare an array.
- Change the compilation of string and array literals to emit a length prefix.
- Rewrite the entire standard library so that all string and array functions enforce a length header in front of the data.
- Add RTTI to all unions and varargs so that incorrect casts fail rather than UB.
- Remove `void *`.
- Forbid malloc() without static compile-time verification that the matching free() exists (with some sort of Bounded Model Checking to sidestep a rather inconvenient Halting Problem).
Is such a language possible?
Has it ever been attempted?