Imagining a Rusty scripting language
⚓ Rust 📅 2025-10-12 👤 surdeus 👁️ 8From time to time I've a little curiosity with Rusty scripting languages.
I've seen this Karina language recently which is a Rusty one that targets the JVM, but it's far from complete.
What I would like in a Rusty scripting language is...
- Fast compile times just like regular scripting languages
- Enum variants tagged with a string (e.g.
Variant = "variant") and a number simultaneously (e.g.Variant = ("variant", 0)).- Tagging a variant with a string seems useful for markup like in React.js/JSX (e.g.
<s:Component1 variant="normal"/>) and occasional type inference, too.
- Tagging a variant with a string seems useful for markup like in React.js/JSX (e.g.
- Built-in JSX-like feature
- Defaults to garbage collection
structinheritance is said to be an anti-pattern, but it's useful for certain corner cases (like implementing DOM nodes and their event model (e.g. to avoid an additional "detail" parameter on event listeners)).- Event declaration (i.e. events that are possibly dispatched by a struct), allowing for type inference when listening to events and perhaps dispatching events.
JSX-like feature
For a compiler to work, it may have to rely on specific host APIs. For example, TypeScript tsc supports React.js-tied JSX markup which targets the React.js API (by default specifically for the WHATWG DOM). A potential scripting Rusty compiler would need to target a number of different technologies as well with its own markup capabilities.
As to markup syntax, people seem to argue that Dioxus's default template engine looks more efficient to type:
rsx! {
Component1 {
x = 10
}
}
I prefer a XML-like or JSX-like way because its structure seems a little cleaner, although it requires closing tags when an element is non-empty. (Here's where is required a nice IDE support.)
Unlike React.js, I'd rather not rely on a separate styled-components package and support multiple CSS blocks out of the box, scoped to a markup's tag.
xml! {
<w:HGroup>
<w:Style>
r###"
:host {
background: red;
}
"###
</w:Style>
</w:HGroup>
}
In this case w would be a native prefix identifying the framework (e.g. Whack) and other prefixes are simply identifying Rusty modules.
Target
More native as possible. For a framework target wasm and rely on things like skia-safe and wgpu.
Implementing anything so far?
No, I don't understand bidirectional type checking at all, so I'm paralyzed for now, and I also am not sure I want a "Rusty" language (too complex to implement (e.g. decl and proc macros) and there are some feature tradeoffs compared to the other dialect I like).
1 post - 1 participant
🏷️ Rust_feed