Introducing Rust alongside C in Julia's source tree?

The Julia runtime is a bit unusual. It is not actually a terribly big or complicated program, and we generally try to move anything we can into Julia.

The code generation part of the runtime uses C++ because that’s really the only first-class API for LLVM. The way it uses C++ has been criticized by real C++ programmers as “C with method calls”, which is entirely accurate and intentional. I suspect that using Rust to interface with LLVM would be a major impediment and cause us to have to wait not only for new LLVM releases but for Rust interfaces to LLVM to catch up to those releases, and of course it’s an extra layer of potential bugs. So I don’t think replacing code generation stuff with Rust would be a win.

Then there’s the basic OS runtime stuff. This is written in C and could more plausibly be implemented in Rust. However, a very large amount of this would have to be unsafe. As I said, it’s a very unusual program: it inherently needs to do a lot of unsafe (in the Rust sense) low level memory manipulation and does very little dynamic memory allocation that isn’t subsequently managed by Julia’s own GC. There’s a very small amount of concurrent data structure work, but it’s pretty minimal and unlikely to grow or change too much. Rust could maybe help there, but it seems better to keep the runtime as simple and lowest common denominator as possible, which favors C.

32 Likes