Embeddable scripting langs for Rust, and why I hate them all

For the last few months, I’ve been slowly tinkering away at writing my own custom X11 (via xcb) window manager, dawn (not open-source yet, sorry!). Because I hate the thought of dealing with named pipes and the like for things such as “resize this window” “move that window over there” etc etc etc, I decided to instead just add scripting to dawn so that I can do all this stuff via scripting. I’ve not yet gotten as far as designing a scripting API for this, and deciding what all I’d expose to the scripting language, since the specifics of the language will, to an extent, affect how I do this.

I’ve not actually tested out all of these; this is more of an overview of my first impressions and how I feel about the languages that are actually implemented. Those first impressions matter, y'know? And I don’t want to use something that gives me a nasty taste in my mouth on first look.

Helpfully, there’s a list of embeddable scripting languages that’s easy enough to read, and I’m sure I can find more via GitHub. But you know, I just want a scripting language that meets my few wants:

Easy, right?

Oh how fucking wrong I turned out to be…

dyon #

A rusty dynamically typed scripting language

Well, okay. I’m unsure how I feel about “rusty,” so I’m a bit apprehensive already. Dynamic typing is fine with me – I actually prefer it as long as the language constructs make it sane (looking at you, Elixir!) – so that’s not an issue. Well let’s look at some syntax… Oh hey, the README even has some shown and-

dyon syntax

Dear god in heaven, what the everliving FUCK is that? Why are there tildes everywhere? I thought this was dynamically typed, what’s with that type-looking stuff in the function declaration? Wait, are those the function’s arguments?? This scares me. I hope the tutorial looks better… The Rust-like syntax is already off-putting, and-

lifetimes?????

I’m sorry, what the fuck. I’m looking for a scripting language to get AWAY from Rust-isms, not to have more of them!!

To be serious: I know that it’s a reasonable design choice, and I’m sure some people out there like it, but there’s absolutely no way that it’s for me.

Well, this isn’t a reassuring start. Let’s hope that the next ones are better…

glsp #

The GameLisp scripting language

Okay, a lisp is up next. I’m not a huge fan of these, but I’ll take a look. That tagline isn’t too helpful…

Oh.

7 commits and no activity in the last 5+ months. Scary. That TODO list is kinda spooky too. But let’s check the website, maybe there’s something that’ll redeem it!

Aaaaaaand the method declaration keyword appears to be meth. I’m out.

gluon #

A static, type inferred and embeddable language written in Rust.

You know, that actually sounds kinda good. I’m interested, let’s look at some code!

haskal- I mean, gluon

Well okay, this appears to be a haskal Haskell-like language. I’m not really a fan of those, but if it works then it’s fine with me. I wonder if there’s any more-complicated examples…

Oh.

macro hell????

Wait, is that import! macro just C’s #include? I know it isn’t really, but it sorta reads like it’s just #include + #pragma once

I'm stupid

Oh.

yep I'm stupid

Yep, I’m officially too stupid for this. Moving on…

hlua / luajit-rs / rlua / torchbear #

These are all just lua interpreters, so it can’t be too bad, I hope. I don’t rly like lua, but hey, if one of these is good then let’s go!

hlua hasn’t been updated in over 2 years, and has 45 open issues + 6 open PRs + seems to have no activity. Moving on!

luajit-rs seems to have minimal? activity and popularity, and looking at those usage examples, I’m just not really a fan of the API, I think. I’m not sure. luajit feels like super overkill for this, tho. Oh wait, the example has you returning C values. Never mind, I want something that interops nicely with Rust, not Rust-but-pretending-to-be-C.

rlua is under the org for the Amethyst game engine, so maybe there’s hope! Oh, it’s got more open issues + PRs than hlua, seems a touch inactive, and is also pre-1.0. I’m more scared than anything now…

Well let’s try torchbear!

…Oh. 215 open issues and no examples of using it from Rust in the README.

internal screaming

ketos #

Lisp dialect scripting and extension language for Rust programs

ketos is a lisp-like, which pretty much instantly excludes it. Has real docs tho, so it’s already doing better than a lot of other candidates.

lichen #

Scripting DSL with Rust interpreter

Inactive for nearly 4 years, and seems to be pretty specifically for dialogues in games and the like. NEXT!

mun #

Mun is a programming language empowering creation through iteration.

I remember seeing this one on… /r/rust? Hacker News? One of those orange websites, I’ll remember which eventually.

Mun actually looks cool. I’m a fan of the ideas. The combination of Rust-like syntax + AOT + not-1.0 (tho I get that this is just the Rust ecosystem…) + focusing heavily on speed makes me… not really like it, honestly. I want a fairly-simple, fairly-stable, not-Rust-copy scripting language. The README also gives me the vibe that it’s a very… Well, not very-scripting-language language. It feels like it’s trying to be its own native language like Rust. And that’s a fine goal! But it doesn’t fill my needs.

rhai #

Rhai - An embedded scripting language for Rust

Actively-developed, which is pretty reassuring. And it’s made by the people behind Chaiscript, so how bad can it be?

Oh, no struct / record definitions? I have to define them all in Rust? No traits or classes or …? No first-class functions? No first-class closures? BUT THERE’S FUNCTION POINTERS??? I guess map literals make up some for the lack of types, but what the fuck. This is just unusable for me.

rune #

An embeddable dynamic programming language for Rust.

Dynamic, actively-developed, legible README, higher version than like 0.2 or something, … This seems promising! Let’s find some syntax examples and see where it goes. I bet the official website has some…

rune is just rust but not

That’s just Rust but with extra steps. I also don’t want to have to define a main() in all my scripts.

deep sigh

rustpython #

A Python Interpreter written in Rust

Alright. I’m pretty cool with python, and holy HECK that repo is ACTIVE. I can even JIT stuff from the python scripts! That’s pretty neat. The README does warn us that

RustPython is in development, and while the interpreter certainly can be used in interesting use cases like running Python in WASM and embedding into a Rust project, do note that RustPython is not totally production-ready.

so I might be holding off on this one. There’s an eval which is nice, and a Rust API, but nothing really documented about it, it looks like? I discovered the eval and stuff via digging through the docs on docs.rs, which makes me feel like it’s not an intended use-case of this. I’ll be keeping an eye on it to see where it goes, at least.

wlambda #

WLambda - Embeddable Scripting Language for Rust

The README says

WLambda is an embeddable dynamic scripting language for Rust, where every value can be called and the syntax is a blend of Perl, Lua, JavaScript and LISP/Scheme/Clojure.

and I’m not sure how to take this. Is every value secretly a function? Is the syntax an unholy disaster? Let’s find out! The README helpfully has a syntax explanation, so I think that there’s a pretty good chance that-

oh

Oh.

?

So if isn’t a keyword, but a ? instead? Okay…

keywords???

WHY DOES while GET A KEYWORD BUT NOT if?????

MONEY AND FUNCTIONS

Why is there a $ before true!? What in the actual fuck is that function declaration syntax?!

worse than C++

What. The. FUCK. Satan himself couldn’t invent something this bad. I’m running VERY far in the opposite direction.

Conclusions #

If it’s not obvious, I pretty much hate all of these. I’m horrified and saddened by what I’ve seen here. I’m losing hope in just getting an embeded scripting language that does what I want. Maybe I should just look for an embedded Ruby? Dunno…

 
3
Kudos
 
3
Kudos

Now read this

Dynamic function “definitions” in Elixir

This is more of a dumb hack than anything, I just happened to learn about this today. Suppose that you’re writing a shell-command executing library. You can, of course, always use System.cmd/3 to do so. However, what if you wanted to... Continue →