From: "fredlinhares (Frederico Linhares) via ruby-core" Date: 2025-11-20T01:07:12+00:00 Subject: [ruby-core:123868] [Ruby Feature#21695] Optimizing Ruby performance with Ruby itself instead of Rust Issue #21695 has been updated by fredlinhares (Frederico Linhares). Currently, my goal is to rewrite the C++ code I have into C. To achieve this, I am creating a set of macros in Ruby on top of C that run at compile time, and the output of these macros is C code. Here is an example of what I am doing, code goes from this: ``` <%= scope do %> <%= var :my_texture, Game::Texture("img/some_texture.qoi") %> render(my_texture) <% end %> ``` to this: ``` { Texture my_texture; Texture_constructor(&my_texture, "img/some_texture.qoi"); render(my_texture); Texture_destructor(&my_texture); } ``` When I create a Ruby variable, it tracks everything; this way, the tool (I have no name for it yet) can, for example, automatically add a destructor when needed. Since you are interested, I will move my code to a gem and post the link here. ---------------------------------------- Feature #21695: Optimizing Ruby performance with Ruby itself instead of Rust https://bugs.ruby-lang.org/issues/21695#change-115267 * Author: fredlinhares (Frederico Linhares) * Status: Open ---------------------------------------- I am using ERB on top of C for a game I am making now. We can use the tool to improve the productivity, memory safety, and runtime speed for Ruby. It can also replace a Rust JIT compiler for better results. The only problem is that it requires some level of manual memory management, while Rust does it all for you. If I demonstrate that it is better than Rust in practice, would you be willing to incorporate it into the Ruby language? I want to know because making it more generic will require more effort from me; if you are not interested, I won���t make the tool public. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/