Dev

One Year Since the Announcement of Rust-Embedded Scripting Language "Roto," Version 0.11.0 Released

One year after its announcement, the JIT-compiled scripting language Roto for Rust applications has released version 0.11.0, featuring static typing and high performance.

6 min read Reviewed & edited by the SINGULISM Editorial Team

One Year Since the Announcement of Rust-Embedded Scripting Language "Roto," Version 0.11.0 Released
Photo by Chris Ried on Unsplash

The scripting language “Roto,” designed to be embedded in Rust applications, has reached its one-year anniversary since its announcement. To mark this milestone, its developer, NLnet Labs, has released the latest version, v0.11.0.

What is Roto?

Roto is a JIT-compiled scripting language designed for seamless integration with Rust applications. One of its defining features is its use of static typing and Just-In-Time (JIT) compilation, which converts code into machine language at runtime. This architecture allows Roto to achieve execution speeds that often exceed those of traditional scripting languages. Although NLnet Labs initially developed Roto for its Rotonda project, the language is designed to be versatile enough for use in other applications. Rotonda is a platform for collecting and analyzing BGP (Border Gateway Protocol) data, which is utilized in network operations.

A Productive First Year Over the past year,

Roto has seen remarkable progress. According to a blog post by NLnet Labs, six new versions have been released during this time, introducing numerous new features and bug fixes. The team has also actively participated in events, delivering talks about Roto at the European Rust Conference “EuroRust” and the open-source conference “FOSDEM,” which helped boost awareness within the developer community. As part of its branding efforts, the project adopted a new logo and significantly improved its documentation with the help of a technical writer. Roto has also begun to be adopted by external projects. Beyond its initial use case in-house, the scripting language is gradually being implemented in external applications, indicating its growing versatility and maturity. On the development infrastructure side, the project repository has been migrated to Codeberg, a European open-source code hosting platform. This move reduces dependence on GitHub and aligns with the preferences of projects looking for alternative hosting solutions.

Significant Language Feature Enhancements

Since its initial release, Roto’s language specifications have evolved significantly. Key new features include: - Control Flow Enhancements: The implementation of while and for loops allows users to write iterative processes directly within Roto scripts. - String Manipulation: The introduction of f-strings (formatted string literals) enables embedding variable values directly within strings. - Expanded Operators: New operators, such as the modulus operator (%), and compound assignment operators (e.g., +=) have been added, enabling more concise code. - Advanced Data Types: New features like enumerations (enums), global constant bindings, and generic parameters for types have also been introduced.

Implementation of the List Type and

Interoperability with Rust One of the most significant new features is the implementation of the List type. This allows users to create lists of arbitrary Roto types and perform operations such as concatenation and iteration on the lists. Developing the mechanism for seamless data exchange between Rust and Roto, particularly for lists, proved to be a challenging task. NLnet Labs reports that this feature is now fully supported, enabling relatively low-cost data transfer between Rust’s native data structures and Roto’s scripting constructs. This seamless integration further enhances Roto’s value as an embedded scripting language.

Transition to a More Rust-Like Syntax Roto’s

syntax has also undergone significant changes to improve compatibility with Rust. For example, the keyword for function declarations has been changed from function to fn, and comment syntax has shifted from # to //. These changes are expected to lower the learning curve for developers already familiar with Rust. However, NLnet Labs has clarified that Roto will not become a complete subset of Rust in the future, as the language plans to include features like string formatting and filters that are not present in Rust. Below is a sample Roto script showcasing the new language features: const DUTCH_CITIES: List[String] = [ "Amsterdam", "Rotterdam", "Utrecht", "Delft", ]; fn is_dutch_location(x: String) -> String { for city in DUTCH_CITIES { if x == city { return f"The beautiful Dutch city of {x}!"; } } f"{x} is not in the Netherlands..." } In this code snippet, a List type is declared as a global constant, and a for loop and f-strings are utilized. The syntax is reminiscent of Rust while maintaining the simplicity of a scripting language.

Overhauling the Integration Framework with

Rust A critical aspect of Roto’s value lies in the quality of its integration with Rust. At the heart of this integration is a mechanism that registers Rust types, functions, and constants with Roto scripts. This enables application developers to expose custom functionalities to their scripts. NLnet Labs has significantly revamped this registration mechanism. While the specifics are detailed in their blog post, the update appears to reduce the burden on developers writing Rust code, making it more intuitive to expose Rust functionalities to Roto.

Roto’s Place in the Embedded Scripting

Language Ecosystem The embedded scripting language space has long been dominated by Lua, which has established itself as the de facto standard for game engines and various applications. Recently, interest in embedded scripting languages within the Rust ecosystem has been growing. Projects like Rhai and Rune are exploring different approaches to integration with Rust. Roto distinguishes itself from these alternatives with its focus on static typing and JIT compilation. Static typing enables error detection before script execution and reduces runtime type-checking overhead. JIT compilation offers faster execution compared to interpreted scripting languages. These features make Roto particularly well-suited for use cases that demand high performance and reliability, such as configuring network devices and describing policies.

Future Outlook NLnet Labs plans to continue

developing Roto, focusing on expanding language features, improving integration with Rust, and enhancing documentation. The extent to which Roto is adopted by external projects will play a critical role in its growth. While the language currently has a clear use case in the Rotonda project, it is still exploring its potential as a general-purpose scripting language. As the Rust ecosystem continues to expand, the demand for scripting languages that can be embedded in Rust applications is expected to grow. It will be interesting to see how Roto’s design philosophy, emphasizing static typing and JIT compilation, positions it within this evolving space.

Frequently Asked Questions

What types of use cases are suitable for Roto?
Roto is a scripting language designed for integration with Rust applications. Its static typing and JIT compilation make it particularly well-suited for scenarios requiring performance and reliability, such as configuring network devices and describing policies. NLnet Labs developed Roto with its BGP data collection platform "Rotonda" in mind.
How is Roto different from existing embedded scripting languages like Lua?
The biggest differences lie in its use of static typing and JIT compilation. While many scripting languages, such as Lua and Python, use dynamic typing and an interpreted execution model, Roto conducts type-checking before execution and compiles to machine code at runtime. This reduces runtime errors and improves execution speed. Additionally, its syntax is similar to Rust, lowering the learning curve for Rust developers.
Is Roto open source? Where can I access its source code?
Yes, Roto is an open-source project. Its development repository is hosted on Codeberg, and the changelog for the latest version, v0.11.0, is also available there. You can find links to these resources in the blog posts published by NLnet Labs.
Source: Lobsters

Comments

← Back to Home