this post was submitted on 23 Jun 2024
1 points (100.0% liked)

Rust

5989 readers
6 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

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).

top 10 comments
sorted by: hot top controversial new old
[–] [email protected] 0 points 4 months ago
[–] [email protected] 0 points 4 months ago

I assume you're talking about embeddable languages. I've used Rhai and it's quite nice but I wish it had type annotations.

Gluon is another option but IMO they've gone way too far into crazy and unergonomic ML-style syntax. Which is weird considering it's implemented in Rust which has much nicer syntax for the same things which they could have copied.

[–] [email protected] 0 points 4 months ago (1 children)

With requirements like yours, just use RUST itself.

GO language can be used as scripting language on Linux.

I imagine the same approach can be used with RUST.

[–] [email protected] 0 points 4 months ago (1 children)

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...

[–] [email protected] 0 points 4 months ago (1 children)

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)

[–] [email protected] 0 points 4 months ago

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 Rust std library since many implementations in there have small strategic uses of unsafe 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 the unsafe keyword specifically.

[–] [email protected] 0 points 4 months ago (2 children)
[–] [email protected] 0 points 4 months ago

I don't know how I didn't register the existence of roc.
I'm reading through the tutorial, and it looks very interesting.

[–] [email protected] 0 points 4 months ago (1 children)
[–] [email protected] 0 points 4 months ago

According to the readme, that’s Lua bindings and not the language itself, that’s probably why it’s not on the list since it wasn’t written in Rust.