Interpreted scripting languages created in Rust (with some doubts about the Ion Shell)

As this is a Rust forum, I hope you'll not consider my question impolite. :thinking: Could anyone please recommend me some interpreted scripting language written in Rust? I love Rust but still, for certain silly tasks scripting appears to be easier. So what I'm looking for is "Lua (or perhaps Rebol/Red), but with the interpreter written in pure Rust" for a general usage but not necessarily as bloated with features as Python.

In January, I spent the whole month coding in the Ion Shell (for Redox OS). I really liked Ion, I liked the syntax and everything and for a half year Ion has been working flawlessly as the default shell on all my Linux installations. However, (1) after a month of frustration I concluded Ion was too buggy for developing real programs. "Buggy" is not really a problem--I was going to report some of the most obvious bugs I believed I found but... I never did it because (2) the most recent release of Ion is from 2017 and even that one has been yanked and I moreover found on the internet other people's questions about the state of development of this shell missing any response or reaction from the developers.

Are there any new promising projects of this kind, which hopefully won´t be abandoned? Something like Lua but written in Rust would be fine. Or perhaps, does anyone has some knowledge about the future of Ion? I'm asking that here as the Redox OS forum looks dead.

Looked quickly through the list at #scripting // Lib.rs - at least Gluon — Rust-lang // Lib.rs, Dyon — Rust game dev // Lib.rs and Rune — Rust dev tool // Lib.rs look like they might be appropriate.

1 Like

Thank you @Cerber-Ursi! My first impression is that nothing compares to Lua. :neutral_face: Some of them show the complexity of Go, and some of them look nicer but unfinished. But I'll keep reading and testing. :slightly_smiling_face:

If you're into quick-n-dirty, give Rhai a try.

It should integrate with very little code.

Last weekend I jumped onto the nushell bandwagon¹, you might want to consider that. It's a great shell, though admittedly quite different than I'm used to with the likes of bash and zsh.
Working with nu code feels a lot like:

  1. A scripting language that excells at both of its jobs: being a scripting language to glue stuff together, as well as a capability to scale up when needed
  2. Written in Rust,
  3. That is actually internally consistent (language-wise this is huge! Bash and zsh were built in different eras, and it really shows now),
  4. That is also heavily FP-oriented (there are for loops, but no break, continue etc, in favor of recursion, and a deeply baked in concept of pipelines, similar though not identical to pipes in bash, zsh etc),
  5. And has a cool feature of easily parallellizing code when needed (I haven't checked this but I imagine there's some rayon or pariter API usage in there), which is safe to do courtesy of the FP paradigm
  6. On top of that is also getting better every release (I know this because I've been tracking the project for a while before deciding to try it out as a daily driver)
  7. And at 350+ the project seems to have a large enough list of contributors to avoid death by starvation in the way that Ion seems to have
  8. Has a plugin infrastructure, though the plugins mostly seem to be outdated, so it may be used more as an incubation ground for new functionality, or they simply changed their minds at some point
  9. Generally knows about the data it manipulates, which is huge compared to the byte streams of the shells of yore. For example, just becomes next to trivial to mine a version number of a Rust project and use that information for build purposes. If writing the update back to the Cargo.toml was desired, that would be quite easy to do too.

¹ Ok, so I didn't jump on just the nushell bandwagon. It's a wholesale replacement (and it seems massive upgrade) of both shell and terminal. First off, I replaced my terminal with alacrity for its raw speed. That's awesome, but alacrity doesn't support tabs, apparently by design. Bonkers as that design choice seems to me, I'm also not about to fork the project and maintain it just for that, so the tab support now comes from Zellij, which can most easily be described as a "human friendly and modernized version of tmux". In particular it makes it trivial to create and manage tabs as well as panes. The latter provides horizontal and vertical screen splits, similar to what Emacs buffers are capable of and plenty of other terminals provide out of the box.
Then finally, the cherry on top of this infrastructure cake is nushell.
One of the great things about this stack is that the entire cake, cherry included, is written in Rust.

4 Likes

Thanks @jjpe, so many people talk about Nushell that I definitely should give it a try and those 350+ contributors sound like a good argument.

Interestingly, on GitHub Nu is treated as a separate programming language and not Shell.

@schungx, thanks for recommending Rhai. It may be good for embedding but for some reason it actually looks quite complex. :thinking:

I would say that's because of the internal consistency point I made above. What it means is that the nu language is useful both as a data manipulation language (something that bash and zsh are just awful at, and often can't even do, necessitating the likes of awk, sed, grep, etc) and as a glue language.
And indeed that's something that has been sorely lacking in the shell space up until nushell showed up. It's why at some point for most data manipulation jobs I'd simply farm them out to Python. Ironically, it's Python itself I can now put out to pasture, at least for personal use :slight_smile:

I only use Python for plotting with Matplotlib. For my other needs Rust and Lua are better. Can I plot in Nu?

Not that I know of. But I'm guessing that's because they still have more core work to do, so fancy frills aren't a priority ATM.
Plotting libs aren't exactly trivial pieces of software.

OK, so I'm playing with Nushell in a container on Fedora Silverblue. At this point my keyboard stopped to work after switching between Nushell and Ion Shell:

:rofl: :joy: :rofl:

Somehow some configs must've gotten borked.
If you happened to have backed up the configs it'll be an easy restore.

Wonderful error messages! Although it seems too limited for complex calculations... I think I'll play with Nushell in a container for a few weeks before I really install it on my system. But yes, Nushell looks like the thing I was asking for in this thread. I'll mark your post as the solution and thank you! :grinning: