3 ms·
Obviously Rust has some features, like async, that are not needed for 'C with safety'. But in my experience you need most of the other features. So any 'C with
by phicoh 2y ago
Obviously Rust has some features, like async, that are not needed for 'C with safety'.
But in my experience you need most of the other features. So any 'C with safety' will have a lot of the complexity of Rust. Though of course the syntax and defaults may be different.
At some point it becomes very subjective. Does a language need a UTF-8 string type, or is an array of 8-bit characters enough?
The research question would be, what is a minimal subset of Rust that still allows for programs that are commonly written in C to be easily written in this subset.
Some things, like the tuple type, or 'if let' can be removed, but is it still convenient to write programs without them? Closures are a bit tricky to see if they can be removed.
In any case, C struck a very good balance between being small and powerful. In my opinion Rust strikes a similar balance. Rust is a lot bigger, but it gives powerful tools to write reliable code.
- kragen 2y agoit is impossible for you to have experience with better alternatives that haven't been invented yet; they are unlikely to look like subsets of rust. c is not a subset of pl/1
- phicoh 2y agoIndeed, I don't. But languages can be compared based on features. Even a language that doesn't exist can be described based on what features it needs to have. I'm not an expert in type systems, but there is a huge amount of research in how type systems can be described, what features you need to make a type system safe, etc. If we compare C and PL/I then obviously the syntax differences between C and PL/I are mostly based on the taste of the language designer. But there are a lot of features in PL/I that simply have no equivalent in the C language. Either because when C was design they no longer needed to be in the language or because the features are move to the standard library. In particular I/O is something that lots of language have as part of the language and C doesn't. So it is in many ways obvious why C a lot smaller than PL/I without losing any power. But now we go in the opposite direction. We know what the safety outcome should be. So we can make a list of things that need to be in a 'C with safety', even if we cannot predict what the exact syntax will look like.
- kragen 2y agosafety isn't achieved by adding capabilities, but by omitting capabilities. the hard part is how to avoid omitting necessary capabilities > In particular I/O is something that lots of language have as part of the language and C doesn't. So it is in many ways obvious why C a lot smaller than PL/I without losing any power. that's not why; often obvious things are wrong