3 ms·
Nice. Are any of the many "safe versions of C" getting any traction? There have been so many. It's not a technical problem. It's a mindshare problem. The futu
by Animats 3y ago
Nice.
Are any of the many "safe versions of C" getting any traction? There have been so many. It's not a technical problem. It's a mindshare problem.
The future in this area may be something that takes in existing C code and uses a LLM to recognize idioms and annotate. Without some automated way to convert legacy code, this isn't going to happen.
(One big problem with converting to Rust is that Rust's data model is so far from C/C++ that you can't really convert much existing code. You have to rethink the design to fit the affine type model. That's hard.)
- simonask 3y agoRust's data model diverged from C++, but it's not very far from C. It's easy enough to write C-compatible structs and functions in Rust, as long as you don't need `Drop`. Even tagged unions (data carrying enums) are supported to some degree.
- Animats 3y agoIt's the lack of backlinks to parents that gets you. Rust can do hierarchies where an A owns a B which owns a C, but if you have a reference to C, you can't get back to A. (Yes, weak pointers, reference counts, unsafe hacks, etc. can work around that. But the language really doesn't like links to parents.) So there's no direct translation from a C++ object hierarchy to Rust structs.
- littlestymaar 3y ago> (One big problem with converting to Rust is that Rust's data model is so far from C/C++ that you can't really convert much existing code. You have to rethink the design to fit the affine type model. That's hard.) True, but that's likely going to be the case as well to convert to any ”safe version of C” as well, because in the general case the safety of a C program is undecidable: to make it safe, you have to restrict it to a subset of behaviors that can be statically proven as safe, and the borrow checker and “Rust's data model” is just that.
- pizlonator 3y agoI'm attempting something. https://www.youtube.com/watch?v=Gij9UQy_JEQ https://www.youtube.com/watch?v=Gij9UQy_JEQ https://github.com/pizlonator/llvm-project-deluge/blob/deluge/Manifesto.md https://github.com/pizlonator/llvm-project-deluge/blob/delug... Right now I'm ~90% through a major rewrite to use GC instead of isoheaps, because then I'll go from rewrite-a-bit (Fil-C previously required malloc calls to be annotated and for some unions to be changed) to rewrite-nothing (malloc will Just Work and so will unions). I hope there are others also trying various alternatives. It's too soon for most of these things to tell what traction they may or may not get.
- Gibbon1 3y agoTalking about malloc always reminds me of this paper the discusses delaying popping the stack to return temporary objects. https://www.cs.purdue.edu/homes/rompf/papers/xhebraj-ecoop22.pdf https://www.cs.purdue.edu/homes/rompf/papers/xhebraj-ecoop22...
- Animats 3y agoThat seems to be a "fat pointer" scheme, like the one GCC used to have. (Is it still in GCC?)
- pizlonator 3y agoYeah I call them wide ptrs or just capabilities. I haven’t looked at what GCC has in a while because I don’t want to get gpl tainted. :-/
- kevin_thibedeau 3y agoRust isn't the only game in town. You can convert to Ada.
- fuzztester 3y agoRight. Eiffel may be another option. Both Ada and Eiffel emphasize and support good software engineering practices.