3 ms·
Using C as an output language, backed by guarantees at the higher level, could certainly work. I believe ATS [1] works this way, and can even avoid garbage coll
by pbsd 13y ago
Using C as an output language, backed by guarantees at the higher level, could certainly work. I believe ATS [1] works this way, and can even avoid garbage collection altogether if desired. I understand it is not an easy language, though.
Nimrod [2] also generates C, but as I understand it garbage collection is unavoidable.
[1] http://www.ats-lang.org/ http://www.ats-lang.org/
[2] http://nimrod-lang.org/ http://nimrod-lang.org/
- comex 13y agoThis is one reason I'd like to see the removed LLVM C backend brought back and modernized, with Rust as the source language. Rust is safe, has no mandatory garbage collector, and has a much lower impedance mismatch with C or C++ than most higher level languages, so it should work well for libraries that are expected to integrate with C code.
- stormbrew 13y ago> removed LLVM C backend What are you referring to here?
- Athas 13y agoLLVM used to have a backend that could convert its low-level bitcode to portable C.
- andrewaylett 13y agoI'm not clear why you'd want to compile your rust down to C, only to then compile that C again? Surely you're better off with a single compiler invocation, and taking rust straight to object code? I know that historically it's been easier to write a code generator than a compiler backend, but with LLVM you get the backend just as cheaply as the code gen.
- lmb 13y agoMakes it easier to target embedded arches. For example, LLVM doesn't target the MSP430 from TI, but there is a gcc fork for it. Sure, you can write a new backend for LLVM, but that's a whole different ballgame. This way it would be Rust -> LLVM IR -> C -> GCC for MSP430.