Live data from Hacker News

Roto: A Compiled Scripting Language for Rust

blog.nlnetlabs.nl

41–50 of 116 posts

Re: Roto: A Compiled Scripting Language for Rust

#41
post #20
post #8

Earlier quoted context omitted.

Border Gateway Protocol But I don’t even think people in networking would say that, it is canonically BGP. This is kind of like complaining about the abbreviation HTML, sure yes it is Hypertext Markup Language but everyone knows it as HTML to the point that there are probably people that don’t know it’s an abbreviation.

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, or outages caused by misconfigurations, as BGP is critical for directing traffic across the global internet. For example, a Hacker News article might cover BGP-related incidents like route leaks or hijacks, which can disrupt connectivity or enable cyberattacks.

If the context suggests something else (e.g., a specific acronym in a niche domain), could you provide more details about the article? I can also search for the specific post if you have a link or title."

Pretty good, eh?

Re: Roto: A Compiled Scripting Language for Rust

#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 Rust's safety, it's not even that bad to re-open and re-load the binary when it changes; the big footgun with dlopen is use-after-free.

Re: Roto: A Compiled Scripting Language for Rust

#43
post #23

> Roto fills this niche for us. In short, it's a statically typed, JIT compiled, hot-reloadable, embedded scripting language. To get good performance, Roto scripts are compiled to machine code at runtime with the cranelift compiler backend. Statically typed, hot reloadable scripting? Sign me up.

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?

Re: Roto: A Compiled Scripting Language for Rust

#44
post #36

Earlier quoted context omitted.

Be warned that V8 is a behemoth and adds 100+MB to your binary size, is quite slow to link, and is not practical to compile from source for most projects. If you want a lighter weight JS runtime there's quickjs, if you want WASM there's wasmtime. Personally I don't think it's a good choice for what it seems Roto is used for (mission critical code that never crashes) since TS doesn't have a sound typesystem and it's s…

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

Re: Roto: A Compiled Scripting Language for Rust

#45

In case the author comes in, I'm curious about how you designed the registration mechanism. We have a Python application that makes heavy use of decorators to give strong runtime introspection capabilities, and I've always wondered if the same could be done at or near compile time in an equivalent Rust context. I think learning about the drawbacks and boons of the designs you settled on would be really informative!

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 information to pull the current version of. More powerful introspection/reflection is not possible without derive macros. If you're ok with derive macros though, you could look into the 2 crates I mentioned.

Hope that answers your question!

Re: Roto: A Compiled Scripting Language for Rust

#46
post #23

> Roto fills this niche for us. In short, it's a statically typed, JIT compiled, hot-reloadable, embedded scripting language. To get good performance, Roto scripts are compiled to machine code at runtime with the cranelift compiler backend. Statically typed, hot reloadable scripting? Sign me up.

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…

> game development

I've been out of the loop for a while, but last I checked, the running gag was that there are more game engines written in rust than games. Have things changed? Any high profile games that were made in rust?

Re: Roto: A Compiled Scripting Language for Rust

#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?

Re: Roto: A Compiled Scripting Language for Rust

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

Re: Roto: A Compiled Scripting Language for Rust

#49
post #45

In case the author comes in, I'm curious about how you designed the registration mechanism. We have a Python application that makes heavy use of decorators to give strong runtime introspection capabilities, and I've always wondered if the same could be done at or near compile time in an equivalent Rust context. I think learning about the drawbacks and boons of the designs you settled on would be really informative!

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?

Re: Roto: A Compiled Scripting Language for Rust

#50

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.
Post reply on HN