C / C ++ in Ruby code?

C / C ++ would be a good option for writing some critical aspects of a Ruby application. I know this is possible.

I would like to know how to add C / C ++ code to Ruby code; any other language for that matter.

Are there any practical applications you've noticed in open source projects, or else?

+4
source share
6 answers

Besides the Ruby Extension, here are two other resources:

  • README.EXT (extension.rdoc) - shows you more about how to create C. extensions. A good compliment is the “Ruby Extension”.
  • Ruby Inline is a library that tries to simplify the assembly of C extensions by calling methods in ruby ​​to compile C code.
+9
source

See the “Ruby Extension” section of Pickaxe's book:

http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

+5
source

you should look at SWIG - it allows you to create ruby ​​extensions in C / C ++.

+4
source

We use ffi in one of our projects.

Ruby-FFI is a ruby ​​extension for programmatically loading dynamic libraries, linking functions inside them, and calling these functions from Ruby code. In addition, the Ruby-FFI extension works unchanged on Ruby and JRuby.

It works very well.

+2
source

Compile your high-performance code into a system service / executable and call it from Ruby ...?

0
source

Looks like you need to read the Ruby Extension

0
source

Source: https://habr.com/ru/post/1315714/


All Articles