| ▲ | pjc50 9 hours ago | |||||||||||||||||||||||||
The lifetimes argument is extremely sound: this is information which you need from the developer, and not something that is easy to get when generating from a language which does not itself have lifetimes. It's an especially bad fit for the GC case he describes. | ||||||||||||||||||||||||||
| ▲ | Findecanor 8 hours ago | parent | next [-] | |||||||||||||||||||||||||
> not something that is easy to get when generating from a language which does not itself have lifetimes Not easy, but there are compilers that do it. Lobster [0] started out with automatic reference counting. It has inferred static typing, specialising functions based on type, reminiscent of how Javascript JIT compilers do it. Then the type inference engine was expanded to also specialise functions based on ownership/borrowing type of its arguments. RC is still done for variables that don't fit into the ownership system but the executed ops overall got greatly reduced. The trade-off is increased code size. I have read a few older papers about eliding reference counting ops which seem to be resulting in similar elisions, except that those had not been expressed in terms of ownership/borrowing. I think newer versions of the Swift compiler too infer lifetimes to some extent. When emitting Rust you could now also use reference counting smart pointers, even with cycle detection [1]. Personally I'm interested in how ownership information could be used to optimise tracing GC. [0]:https://aardappel.github.io/lobster/memory_management.html [1]:https://www.semanticscholar.org/paper/Breadth-first-Cycle-Co... | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
| ▲ | jcranmer 6 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
If I were targeting Rust for compilation, I wouldn't do lifetimes, instead everything would be unsafe Rust using raw pointers. I'd have to do an actual project to see how annoying it is to lower semantics to unsafe Rust to know for sure, but my guess is you'd be slightly better off because you don't have to work around implicit conversions in C, the more gratuitous UBs in C, and I think I'd prefer the slightly more complete intrinsic support in Rust over C. | ||||||||||||||||||||||||||
| ▲ | bux93 8 hours ago | parent | prev [-] | |||||||||||||||||||||||||
I mean, the argument boils down to "the language I'm compiling FROM doesn't have the same safeguards as rust". So obviously, the fault lies there. If he'd just compile FROM rust, he could then compile TO rust without running into those limitations. A rust-to-rust compiler (written in rust) would surely be ideal. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||