Live data from Hacker News

Roto: A Compiled Scripting Language for Rust

blog.nlnetlabs.nl

51–60 of 116 posts

Re: Roto: A Compiled Scripting Language for Rust

#51
post #43
post #23

Earlier quoted context omitted.

I have dreamed of this for Rust. It is literally _the_ killer app to have a fast scripting language that pairs with Rust well. With fast development cycles and a safe scripting language, Rust will find itself in every single programming niche. Server development, game development, desktop application development. If the WASM DOM bridge gets better, maybe even web development. Everything will open up. You can prototyp…

What does Rust have that other languages with these properties don't?

[deleted]

Re: Roto: A Compiled Scripting Language for Rust

#52

Woah, this looks awesome. One of my favorite things about writing Rust is that it's expression-oriented (i.e. almost everything is an expression), something you almost never see in non-functional languages. I was wondering if Roto is also expression-oriented?

Hi! Author here. It is indeed expression-oriented, mostly following the same rules as Rust. If-else is an expression, for example.

Re: Roto: A Compiled Scripting Language for Rust

#53
post #47

Very cool! But I prefer the wasmtime webassembly component model approach these days. Built a plugin system with that, which has one major upside in my book: No stringly function invocation. Instead of run_function("my-function-with-typo") I have a instantiated_plugin.my_function call, where I can be sure that if the plugin has been instantiated, it does have that function.

How is that not also stringly typed?

                match Plugin::instantiate_async(&mut store, &component, &linker).await {
                    Ok(plugin) => {
                        match plugin
                            .plugin_guest_oncallback()
                            .call_ontimedcallback(&mut store, &callback_name)
                            .await
                        {
                            Ok(()) => debug!("Successfully called oncallback for {plugin_path:?}"),
                            Err(e) => warn!("Failed to call oncallback for {plugin_path:?}: {e}"),
                        }
                    }
                    Err(e) => {
                        error!("Failed to call oncallback for {plugin_path:?}!: {e}");
                    }
                }
See the "call_ontimedcallback"? It's not a string. The compiler ensures it exists on the Plugin type generated from the .wit file.

If of course I put a wasm file in the plugin folder that doesn't adhere to that definition, that wasm file isn't considered a plugin.

Re: Roto: A Compiled Scripting Language for Rust

#54
post #28
post #20

Earlier quoted context omitted.

A LLM response so don't trust it, but Biological and Genetic Programming: In biology, BGP can refer to methods or algorithms used in genetic programming or bioinformatics. BGP (Bureau of Governmental Personnel): In some governmental contexts, BGP may refer to a specific bureau or office related to personnel management. BGP (Bureau of Geographical Planning): In urban planning or geography, it might refer to a bureau t…

Is that the response from google/gemma-3-1b-it or something? Almost funny how off it is.

Whatever DuckDuckGo uses. First answer was board gateway protocol then I asked what is outside the context of networking.

Re: Roto: A Compiled Scripting Language for Rust

#55

Earlier quoted context omitted.

There's also Duktape for just JS minus the WASM (at least I don't think they've implemented WASM yet). https://duktape.org/

I think QuickJS wins over Duktape for ES5 compliance, though it's been a few years since I was evaluating embedded JS. They're both extremely easy to integrate into an application, in contrast to V8

Fair, I'm not quite as familiar, but always like to bring up alternatives in case they're helpful. My favorite HN comments lead me to new alternatives for programming.

Re: Roto: A Compiled Scripting Language for Rust

#56
post #20

Earlier quoted context omitted.

A LLM response so don't trust it, but Biological and Genetic Programming: In biology, BGP can refer to methods or algorithms used in genetic programming or bioinformatics. BGP (Bureau of Governmental Personnel): In some governmental contexts, BGP may refer to a specific bureau or office related to personnel management. BGP (Bureau of Geographical Planning): In urban planning or geography, it might refer to a bureau t…

That was a pretty bad response, so I tried Grok 3, using the prompt "What's the likely meaning of BGP in a Hacker News article?" Its entire response: "In a Hacker News article, BGP most likely refers to Border Gateway Protocol, a key internet protocol used for routing data between different networks (autonomous systems) on the internet. It’s often discussed in contexts like network security, internet infrastructure,…

I specifically ask the LLM about non-networking contexts because I was interested in what else BGP could mean.

I believe that every possible combination of 3 letters has at least 5 different meanings - most of them only used in some tiny niche (often just one department of a company)

Re: Roto: A Compiled Scripting Language for Rust

#57
post #45

Earlier quoted context omitted.

Hi! So for Roto, our introspection needs are actually fairly limited. We only need the `TypeId`, the type name, the size and the alignment. which Rust can give us without any additional traits. It's not possible currently to - for example - access struct fields and enum variants. That is something that I plan to add, but that might require a crate like `bevy_reflect` or `facet`. Rust is giving me just enough informat…

Did you go through many iterations on the API of the registration? If so, which designs did you disqualify and why?

Not many iterations, but a lot of head scratching was involved haha.

I decided against using a trait and a derive macro because I wanted to avoid running into Rust's orphan rule. We have a crate called routecore where most of our types are declared and then a separate crate called Rotonda which uses those types and uses Roto. I wanted Rotonda to be able to register routecore types.

That's also the downside of the current reflection crates; they require each type to have a derive macro.

Re: Roto: A Compiled Scripting Language for Rust

#58

Very cool! But I prefer the wasmtime webassembly component model approach these days. Built a plugin system with that, which has one major upside in my book: No stringly function invocation. Instead of run_function("my-function-with-typo") I have a instantiated_plugin.my_function call, where I can be sure that if the plugin has been instantiated, it does have that function.

This sounds like a good approach to overcoming rusts slow compile times and lack of dynamic linking. One thing I'm concerned about with this path is what about hot reloading and fast script running? Doesn't everything in the wasm component model need to be compiled first? I imagine that would remove some of the advantages to using a scripting language like JavaScript or Python.

You're right. Hot reloading isn't done by default.

I manually compile a plugin and in my system I can "refresh" a plugin and even say "activate version 1.1 of the plugin" or "activate version 1.2" of the plugin etc.

But that's something I had to build myself and is not built into wasmtime itself.

Re: Roto: A Compiled Scripting Language for Rust

#59
post #48

Very cool! But I prefer the wasmtime webassembly component model approach these days. Built a plugin system with that, which has one major upside in my book: No stringly function invocation. Instead of run_function("my-function-with-typo") I have a instantiated_plugin.my_function call, where I can be sure that if the plugin has been instantiated, it does have that function.

Alternatively, whenever designing a scripting/plugin host make sure to support plugin-hosting-plugins. That way you could have the Roto plugin host complied to wasm.

Sounds interesting but at the same time a bit complex.

I assume you wouldn't ship the whole plugin runtime for each plugin that wants to host another plugin?!

Re: Roto: A Compiled Scripting Language for Rust

#60
post #42

This language looks a lot like Rust. Why not dlopen() a Rust shared library instead? The implementation would be about as complicated, but it would be a well known language that's fully integrated with a large library ecosystem, well defined build and package set, rather than some custom one-off thing with no ecosystem. Going your own way means your users have to re-invent the wheel for themselves every time. With Ru…

Don't rust shared libraries have the problem of no stable rust ABI? So you either use the C ABI or you use some crate to create a stable rust ABI, because otherwise a shared lib compiled with rust compiler 1.x.y on system a isn't guaranteed to work with the binary compiled on the same system with another compiler... or on another system with the same compiler version.

Right?

Post reply on HN