ring-lang-rs: Create extensions and embed Ring using Rust

126 views
Skip to first unread message

Youssef Saeed

unread,
Jan 24, 2026, 4:55:08 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello everyone,

I am excited to share a new project I have been working on called ring-lang-rs.

This project provides Rust bindings for the Ring programming language. It enables two main use cases:
  1. Write Ring extensions in Rust — Create native extensions with Rust's safety and performance.
  2. Embed Ring in Rust applications — Run Ring code from within your Rust programs.
By connecting Ring with Rust, we can now leverage the massive Rust ecosystem of libraries (crates), take advantage of Rust's memory safety, and offload performance-critical tasks (like parsing, encryption, or physics) to native code with modern tooling.

Project Link: https://github.com/ysdragon/ring-lang-rs

Key Features:
  • Access to Crates: Easily wrap thousands of existing Rust libraries to expand Ring's capabilities.
  • Ergonomic Macros: I have implemented a set of macros (`ring_func!`, `ring_libinit!`, etc.) that make writing the glue code very similar to standard Ring C extensions, but cleaner.
  • API Coverage: Currently covers about 41% of the Ring C API (VM, Lists, Strings, State, etc.).
  • FFI Support: Easily pass numbers, strings, lists, and C pointers between Ring and Rust.
Quick Examples:

Here is how simple it is to write a "Hello World" extension in Rust:

use ring_lang_rs::*;

ring_func!(ring_hello, |p| {
ring_check_paracount!(p, 0);
ring_ret_string!(p, "Hello from Rust!");
});

ring_libinit! {
b"rust_hello\0" => ring_hello,
}

And here is how to embed Ring in a Rust application:

use ring_lang_rs::*;

fn main() {
let state = ring_state_new();
// Run code directly
ring_state_runstring_str(state, r#"
? "Hello from Ring!"
"#);
// Or run a file: ring_state_runfile_str(state, "script.ring");
ring_state_delete(state);
}

Status:

This project is currently considered experimental. I am looking for feedback, testers, and contributors who are interested in bridging these two languages.

You can find installation instructions and full documentation in the GitHub repository.

Best regards,
Youssef

Mansour Ayouni

unread,
Jan 24, 2026, 5:16:53 PM (8 days ago) Jan 24
to Youssef Saeed, The Ring Programming Language
Hello Saeed,

Looks like a huge step for enabling Ring programmers to embed Rust power in their programs!
I'm willing to test it but first I need you to explain to me the principle of that solution:
  • Is it an extension like the ones we have for C and C++, and hence it requires building DLLs and including them with the Ring code ?
  • Are they just scripts that fire Rust executable and get returns in Ring?
  • How is it used in a Ring program by Ring programmers? The example does not show a load("your-extension.ring") and then use of wrapper functions like we usually do in other extensions...
  • Or is it just a low level solution that we must use by writing Rust code and making some build process before we get those functions accessible to Ring?
My questions will necessarily let you get the point that I don't understand what the extensions does exactly, and how I should use it from a Ring programmer's perspective...

Thank you in advance for your clarifications.

Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/2f555868-7797-4dcf-9b74-60c8a90c8a86n%40googlegroups.com.

Youssef Saeed

unread,
Jan 24, 2026, 5:48:03 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Mansour,

Thank you for the kind words and the excellent questions!

To put it simply: It works exactly like standard C/C++ extensions.

Here are the specific answers to your points:

1. Is it an extension like C/C++ (DLLs)?
Yes, exactly.
You write the code in Rust, and when you compile it (using `cargo build --release`), it generates a shared library (`.dll` on Windows, `.so` on Linux, `.dylib` on macOS). You then load this DLL in Ring using `loadlib()`.

2. Are they scripts that fire Rust executables?
No.
This is not a wrapper that runs external `.exe` files. It uses FFI (Foreign Function Interface). The Rust code runs inside the Ring process, sharing the same memory. This means it is extremely fast—just as fast as a C extension.

3. How is it used by Ring programmers?
The examples in my post showed the Rust side (how to create the extension).
On the Ring side, you use it just like any other DLL extension.

For example, if you build the basic example:

cd examples/basic
cargo build --release
ring test.ring

Ring Code (test.ring):

# Load the appropriate library for each OS
if isWindows()
loadlib("target/release/basic_extension.dll")
but isMacOSX()
loadlib("target/release/libbasic_extension.dylib")
else
loadlib("target/release/libbasic_extension.so")
ok

# Now we can call the functions defined in Rust
? rust_hello() # Prints: Hello from Rust!
? rust_add(10, 20) # Prints: 30
? rust_greet("Mansour") # Prints: Hello, Mansour!

4. Is it a low-level solution?
It is a tool for extension developers.
  • The Developer: Needs to know some Rust to write the extension logic (instead of writing C).
  • The Ring User: Doesn't need to know Rust. They just `loadlib("...")` and use the functions as if they were native Ring functions.
The `examples/basic/` folder demonstrates working with numbers, strings, lists, and C pointers. You can use it as a template for your own extensions.

I hope this clarifies the architecture! It is essentially a modern way to build Ring extensions without writing C code—while gaining access to the entire Rust ecosystem (150,000+ crates).

Best regards,
Youssef

Mansour Ayouni

unread,
Jan 24, 2026, 5:58:11 PM (8 days ago) Jan 24
to Youssef Saeed, The Ring Programming Language
Hello Youssef,

Excellent and very clear!
I find that you are good at explaining things as much as you are skilled in technical skills.

If you permit me to give a general advice, to you and any open source contributor:
  • when you are done with the solution, think of the final user (in our case a Ring developer), and give him the conceptual and practical information he needs to use your solution
Waiting maybe one day, for an FFI integration of Python, which is a must in ML and AI staff :D
KEEP THE BEAUTIFUL AND CLEAN WORK!

All the best,
Mansour

Youssef Saeed

unread,
Jan 24, 2026, 6:12:22 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Mansour,

Thank you for the kind feedback and the excellent advice!

You're absolutely right—documentation from the end user's perspective is crucial. I will keep improving the README and examples to make it easier for Ring developers to get started.

Regarding Python FFI: That's a great idea! Python's ML/AI ecosystem (PyTorch, TensorFlow, scikit-learn, etc.) would be incredibly valuable to expose to Ring.

Interestingly, Rust has excellent Python interop through PyO3, so a `ring-python` bridge is definitely possible. I'll add it to my list of future projects.

Best regards,
Youssef

Mansour Ayouni

unread,
Jan 24, 2026, 6:19:35 PM (8 days ago) Jan 24
to Youssef Saeed, The Ring Programming Language
Hello Youssef,

Interestingly, Rust has excellent Python interop through PyO3, so a `ring-python` bridge is definitely possible

A very important piece of information! And it is a strong selling-point to using your Rust extension.

All the best,
Mansour 

Mahmoud Fayed

unread,
Jan 24, 2026, 6:20:49 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Youssef

Thanks for sharing :D

Added to Ring Website - News Section

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Youssef Saeed

unread,
Jan 24, 2026, 6:32:13 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Mahmoud,

Thank you for your kind words and for highlighting the project on the Ring website.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jan 24, 2026, 6:33:46 PM (8 days ago) Jan 24
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jan 26, 2026, 4:00:01 AM (7 days ago) Jan 26
to The Ring Programming Language
Hello Youssef 

Suggestions

1- As you know, when developing C extensions, we have Ring code generator that accelerate the development
Developing such a tool for ring-lang-rs could be very helpful to move forward faster

2- Picking a good rust library, then bringing it to the Ring world through ring-lang-rs will be a real example about this direction.

Greetings,
Mahmoud
On Sunday, January 25, 2026 at 12:55:08 AM UTC+3 youssef...@gmail.com wrote:

Youssef Saeed

unread,
Jan 26, 2026, 9:12:59 AM (7 days ago) Jan 26
to The Ring Programming Language
Hello Mahmoud,

Thank you for the valuable suggestions.

Regarding the code generator, I will definitely keep that in mind. I am currently looking into the best solution to implement a similar tool for generating Rust extensions to speed up development.

As for real-world examples, I have already picked a few. The first one that came to mind was Slint UI, which I am planning to release soon. I also worked on several other bindings, such as Iced, while I was testing ring-lang-rs.

Here is a preview of what they look like:

Slint UI Extension:
slint.png

Iced Extension:
iced.png

Best regards,
Youssef

Mahmoud Fayed

unread,
Jan 26, 2026, 9:16:21 AM (7 days ago) Jan 26
to The Ring Programming Language
Hello Youssef

This is very nice, looks like you are opening a new world of opportunities :D

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jan 26, 2026, 9:26:15 AM (7 days ago) Jan 26
to Mahmoud Fayed, The Ring Programming Language
Hello Youssef,

As Mahmoud said : you are extending the window of possibilities!

In fact for the two UI frameworks you cited, along with the performance of rust and multiplatform nature, they offer two important advantages:
  • Ice embraces the Elm architecture, a clean approach of programming UIs that I appreciate a lot!
  • Slint makes the move from Figma design to slit code automated, which is both productive and fun!
I'm so glad you selected them.
Waiting forward for their extensions in Ring.

All the best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.

Youssef Saeed

unread,
Jan 26, 2026, 9:42:16 AM (7 days ago) Jan 26
to The Ring Programming Language
Hello Mahmoud and Mansour,

Thank you for your kind words!

Best regards,
Youssef

Mahmoud Fayed

unread,
Jan 26, 2026, 10:45:21 AM (7 days ago) Jan 26
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Message has been deleted

Youssef Saeed

unread,
Jan 26, 2026, 6:35:53 PM (6 days ago) Jan 26
to The Ring Programming Language
Hello Mahmoud and everyone,

Following the suggestion regarding the code generator, I am happy to announce that ring-lang-rs now supports automatic extension generation!

I have implemented two approaches to give developers flexibility:
  1. ring-lang-codegen: A Rust crate that lets you simply wrap your code in a `ring_extension! {}` macro. It requires zero configuration.
        It currently supports a wide range of types including Vectors (`Vec<T>`), HashMaps, Tuples, and Slices, alongside standard primitives and Structs.
            (Examples are available under `macros/examples`)
  2.  Codegen (Tool): A tool similar to the standard Ring C extension generator. It parses `.rf` files and features auto-detection—just provide raw Rust code, and it identifies public functions and structs automatically.
            (Examples are available under `tools/codegen/examples`)
Both tools handle the most common use cases (Primitives, Strings, Result/Option, and Object management). However, please note that `ring-lang-codegen` supports a wider range of Rust types compared to the Codegen tool.

I have included various examples (Regex, UUID, JSON, etc.) within these directories to help you get started.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jan 27, 2026, 1:49:46 AM (6 days ago) Jan 27
to The Ring Programming Language
Hello Youssef

>> "Following the suggestion regarding the code generator, I am happy to announce that ring-lang-rs now supports automatic extension generation!"

This is wonderful and will be very useful for extensions developers :D

Thank you very much

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages