#Rust Runtime Compiler

9 messages · Page 1 of 1 (latest)

spark lichen
#

My goal for having a Runtime Compiler is be able to create apps on mobile devices, mainly Android. I've looked into shipping cargo with the app and I found this: https://github.com/BrainiumLLC/cargo-mobile
As I understand, this allows me to create a mobile app that creates other mobile apps. This is a step in the right direction, but my specific goal is to modify and create the app from within the app. This makes the process simpler, and faster to iterate.

spark lichen
#
spark lichen
#

There's a Runtime Compiler for C# which allows to create compiled code from within a built Unity executable. This is different from hot-reloading. External scripts run as fast as internal scripts.
(C# Runtime Compiler: https://assetstore.unity.com/packages/tools/integration/roslyn-c-runtime-compiler-142753).
Is there such a thing for Rust? Compiled scripts would run much more efficiently than interpreted scripts like Lua and I'd like to take advantage of that. I'd like to embed Rust Runtime Compiler within a Rust-Bevy program. I'm looking at the Scripting Languages page, but don't see anything like it.
(Rust Resources: https://arewegameyet.rs/ecosystem/scripting/)
(More Rust Resources: https://github.com/rust-unofficial/awesome-rust)

mild surge
#

if youre fine with using lua, id suggest luajit, youd be hard pressed to find something as fast and as easy to use

dreamy thunder
#

even before you consider shipping a Rust compiler, you first need to solve linking your separately compiled plugin with your main program. let's just say that's nontrivial to start with: https://nullderef.com/blog/plugin-tech/

spark lichen
#

yeah, it looks like when I say 'Runtime Compiler', what I want is a JIT compiler, and Rust is primarily AOT compiled...

dreamy thunder
# spark lichen yeah, it looks like when I say 'Runtime Compiler', what I want is a JIT compiler...

Roslyn doesn't do JIT either, it compiles AOT to CLR IL. Having library API to drive compilation does not imply JIT. The reason Rust doesn't have such an API is more due to the amount of effort required to design and maintain an ABI makes such an API somewhat limited, thus not many are interested in it. And asking devs to install Rust with rustup themselves usually works.

As an experiment you can totally make an environment that ships a fixed cargo and rustc version and spawn them as child processes. Linux distro maintainers do this with bash scripts, but nothing prevents you from doing it with a Rust program.