If I take a ruby code
puts "Hello World!"
and rewrite it using the C API of Ruby
#include "ruby.h"
int main() {
ruby_init();
rb_funcall(Qnil, rb_intern("puts"), 1, rb_str_new2("Hello World!"));
ruby_finalize();
return 0;
}
and compile it, is this a way to compile Ruby code?
If I create a program that uses Ripper
to parse the Ruby code and rewrite it as C, can I call it as a "Ruby compiler"? There're some ruby code that can't be rewrited in Ruby in this way? Did someone tried to write this kind of "compiler" before?