4 ms·
Idris 1 compiles via C, it just has to implement a garbage collector in its runtime system. It should be noted that Idris 1 has much worse performance than Idri
by kryptiskt 6y ago
Idris 1 compiles via C, it just has to implement a garbage collector in its runtime system. It should be noted that Idris 1 has much worse performance than Idris 2 compiled to Chez Scheme, it would take a serious effort to do better than the current Chez backend.
The logical target for a high-performance backend would be LLVM instead of rust. After elaboration Idris 2 has a series of intermediate languages, from lambda calculus to a simple register machine. Creating LLVM code from the least abstract of them wouldn't be any harder than creating Rust code.
- madushan1000 6y agoI was thinking of rust specifically because of GC, I don't know how to write a GC and I don't even want to try. But if I use rust, I won't have to because of rust's zero cost abstractions.
- icen 6y agoThere seems to be a bit of confusion here. Idris doesn't provide the same tools and guarantees as Rust does to manage memory, and instead requires that implementations provide a garbage collector. If you're producing code for a collected language, you can forward on all of the allocations to that language, and if not, you will need to implement one. Zero-cost abstractions or not, Idris needs a GC from somewhere.
- kryptiskt 6y agoReference counting would go a long way though as there is very little mutation in a typical Idris program, so you could probably sew something together in Rust with Rc cells and a simple cycle detector. But basically, having true closures requires some kind of GC. That was already recognized in Steele's Lambda papers in the 70s. Rust has to make compromises with its closures to avoid that.
- madushan1000 6y agoI was hoping I could get by without resolving to to GC, utilizing the rust allocation model(RAII with syntactic sugar and compiler helping out basically). If I "have to" write a GC because idris programming model requires is, I don't think there is a lot of value in writing a rust code generator.