Issue #21695 has been updated by fredlinhares (Frederico Linhares). Let me try to elaborate as much as I can. Rust is not as fast as C; it is as fast as the equivalent C. However, C allows us to use some valid memory management techniques that are impossible in Rust unless you use considerable amounts of ‘unsafe’ code, eliminating the purpose of using Rust. Proper C can be tremendously faster than Rust. I am using C++ in my game, but I realized that C++ has so many flaws that it is not worth it. So, I came up with a solution: I can use ERB to pre-process my C code, just as we usually do with many languages, such as SQL (for example, ActiveRecord), HTML (for example, ActiveView), CSS, and even Ruby itself. This is what we call meta-programming. The interesting thing is that with this process, I make my C code safer, just like when we use an ORM to prevent SQL injections. This code inside the gem is not much, but it allows me to implement template functionalities in C similar to those in the C++ STL. Unfortunately, I will not add to the gem the templates I made so far because they are specific to my game. But now I am currently working on a vector similar to STL vector, that instead of requesting memory from the heap, it requests from an arena. After I finish it, I make it public. This will make it easier to see what I am working on. ``` c #include <cstddef> #include <cstdint> #include <cstdlib> typedef struct { size_t num_elements; size_t capacity; <%= @struct_type %> *elements; } <%= @struct_name.capitalize %>Vector; uint32_t <%= @struct_name.capitalize %>Vector_constructor( <%= @struct_name.capitalize %>Vector *vector, size_t size); uint32_t <%= @struct_name.capitalize %>Vector_push( <%= @struct_name.capitalize %>Vector *vector, <%= @struct_type %> obj); void <%= @struct_name.capitalize %>Vector_destructor( <%= @struct_name.capitalize %>Vector *vector); ``` After finishing this layer of code, I can make a DSL on top of it and use it to write a JIT compiler. I will be using Ruby as a language to modify my game anyway, so making Ruby faster will also benefit me. And once the Ruby community likes the concept of a faster JIT, I will share everything. ---------------------------------------- Feature #21695: Optimizing Ruby performance with Ruby itself instead of Rust https://bugs.ruby-lang.org/issues/21695#change-116957 * 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/