Best way for writing a dynamic function

In many cases, you won't be able to trust the dynamic code. In that case, sandboxing is needed.

Lua is a good way to do it, but there are some caveats. I recently inquired on this forum if someone has experiences with Lua and Rust, then decided to work on my own sandboxing system (but there are already some existing libraries, see linked post).

Depending on what you want to execute, you might want a touring complete language, or a less powerful language. And you might want to think about limiting the resources used by the executed code (e.g. memory or CPU use, or total execution time).

1 Like