Is there a good general-ish purpose scripting language (something like Lua on the smaller end or Python on the bigger) that’s implemented in only Rust, ideally with a relatively low number of dependencies?
Have you used it yourself, if so for what and what was your experience?
Bonus points if it’s reasonably fast (ideally JITed, though I’m not sure if that’s been done at all in Rust).
Disclaimer that I have no experience with writing compilers myself, but conceptually I don’t see any obvious reason that someone couldn’t create a JIT compiler for Rust so that it can be treated like a scripting language and do rapid iteration…
Sure you could JIT Rust, the question is if you can write a JIT compiler in rust since it needs to do some quite scary stuff to swap in compiled routines when evaluating code. I’m not even sure if unsafe is enough for that, you may need goto or arbitrary function pointers (which is kind of the same thing)
Considering most JIT compilers for JavaScript are written in C++, I can’t conceive of a reason you couldn’t implement one in Rust.
Is part of your requirement that
unsafe
doesn’t get used anywhere in the dependency tree? If so you’d have to take away most of the Ruststd
library since many implementations in there have small strategic uses ofunsafe
under the hood.In my entire software engineering career, which spans embedded systems to CAD applications, I’ve never encountered a case where
GOTO
is actually needed (but maybe some places where it can be used as a dirty shortcut to save you some lines of code).As for arbitrary function pointers, if those function pointers are written in Rust then they’ll come with all the safety assurances afforded to Rust code. I suppose if you’re worried about the danger of running ussr-code with
unsafe
in it, you could probably have your JIT refuse to compile theunsafe
keyword specifically.