7 ms·
I've similarly thought about building a language that compiles to Rust, but handles everything around references and borrowing and abstracts that away from the
by dejawu 1y ago
I've similarly thought about building a language that compiles to Rust, but handles everything around references and borrowing and abstracts that away from the user. Then you get a language where you don't have to think about memory at all, but the resulting code "should" still be fairly fast because Rust is fast (kind of ending up in the same place as Go).
I haven't written a ton of Rust so maybe my assumptions of what's possible are wrong, but it is an idea I've come back to a few times.
- vlovich123 1y agoWhy compile to Rust for this? Many people that build transpilation languages target C directly.
- nine_k 1y agoA C compiler won't complain if your generated code does certain horrible things.
- lblume 1y agoThink of Rust as a kind of kernel guaranteeing correctness of your program, the rules of which your transpiler should not have to reimplement. This may be compared to how proof assistants are able to implement all sorts of complicated simplification and resolution techniques while not endangering correctness of the generated proofs at all due to them having a small kernel that implements all of verification, and as long as that kernel is satisfied with your chain of reasoning, the processes behind its generation can be entirely disregarded.
- nine_k 1y agoWhy, macros that put Arc<Box<T>> everywhere might just be it.
- lblume 1y agoArc<Box<T>> is redundant, for the contents of the Arc are already stored on the heap. You may be thinking of Arc<Mutex<T>> for multithreaded access or Rc<RefCell<T>> for singlethreaded access. Both enable the same "feature" of moving the compile-time borrow checking to runtime (Mutex/RefCell) and using reference-counting instead of direct ownership (Arc/Rc).