Closed ccmywish closed 1 year ago
The reason for using Fiddle instead of Ruby-FFI for this project is not technical. It is because Fiddle is a Ruby standard library and is expected to work on almost all environments where Ruby is installed. I think Ruby-FFI is better than Fiddle in the technical aspects.
LibUI was created with school children in mind. Schools may not allow downloading or compiling of libraries. Ruby-FFI will only work if you can use libffi, compile C language extensions, and have an internet connection. Fiddle exchanging Ruby-FFI software with a friend on a USB stick would be easier. The idea of children programming in Ruby may sound strange today, but such a situation was possible in Japan until about 10 years ago.
In any case, Fiddle was chosen not because of technical reasons or my preference. It is because it works everywhere.
Also, I personally prefer Ruby-FFI, but the above comparison is not fair:
# FFI
attach_function :puts, [ :string ], :int
# Fiddle
extern "int puts(const char* s)"
Thank you very much for the detailed explanation.
The idea of children programming in Ruby is not strange at all, in fact, it's my wish too.
So my username is cc my wish
I create a code organization: https://gitee.com/RubyKids to solve some basic problems with using Ruby from China.
Thanks for letting me know the Fiddle
way: extern "int puts(const char* s)"
. It's convenient too.
I am glad to hear of such attempts.
About 2 years ago, I copied some of my work to Gitee, in case they lost access to GitHub from China and we might not have access to Chinese repositories either, LibUI is one of them. So you can get the LibUI source code from there if you need it. It may be a bit out of date.
Hi @kojix2
The
ffi
seems more idiomatic for Ruby, for example:As you can see, in
ffi
we write just symbols directly to represent C types.So, I suspect there might be some technical reasons for the use of
fiddle
rather thanffi
. What are them?