Using ruby in place of C

Hi all,
This may be silly question but:

There is a program that I want to use that says:
“there is a C interface provided so that user codes can be written in C
or C++.”

What I want to know is if I can write these “user codes” in ruby
instead?

Chris.

What are “user codes”?

Anyway, if you can EXTEND it in C, you can use Ruby-C as well as
easily, and afterwards use pure Ruby. Not sure if that will
work in your case, I dont know what “user codes” are :slight_smile:

On 1/15/07, Chris F. [email protected] wrote:

Hi all,
This may be silly question but:

There is a program that I want to use that says:
“there is a C interface provided so that user codes can be written in C
or C++.”

What I want to know is if I can write these “user codes” in ruby
instead?

But you will have to work at writing a Ruby extension in C that uses
the published C interface first. If you intend to use the program from
Ruby a lot, it will make a lot of sense to do so.

On 1/15/07, Chris F. [email protected] wrote:

Hi all,
This may be silly question but:

There is a program that I want to use that says:
“there is a C interface provided so that user codes can be written in C
or C++.”

What I want to know is if I can write these “user codes” in ruby
instead?

You can. There’s a program called SWIG that can “wrap” a C interface
so that it can be called from Ruby. You would have to do that first,
but then you could use this interface as if it were any other Ruby
library.