Hi! Is it possible to compile and run Roc on a host at runtime? I've only seen mentions of building native binaries using C-ABI as a glue. Does it always have to be pre-built and linked statically to the host binary?
Roc can build a shared library with --lib
or an object file with --no-link
Brendan Hansknecht said:
Roc can build a shared library with
--lib
or an object file with--no-link
So the way that i can do something like hot reloading for Roc scripts in my runtime is calling to roc
compiler binary, then dynamically linking to the output object?
Yeah, roughly that.
just dlopen and replace the shared library
Brendan Hansknecht said:
just dlopen and replace the shared library
Honestly that sounds kinda tough when host/runtime is not already implemented in C, C++ or Rust. Are there any plans on making wrappers around that so it is possible to run dynamic Roc scripts easily?
I mean, I think hot reloading in general is complex and error prone. So probably best done in lower level languages.
For general use, whatever cffi tool the higher level language has should work for interacting with roc. That said, a c/c++/zig/rust shim can make life easier.
As the ecosystem matures, it would be nice to expand the support for more automation here, but past supporting glue (binding generation) generically, nothing concrete is thought out.
That clears things up a bit. Thanks.
Last updated: Jul 05 2025 at 12:14 UTC