Forum: Ruby using ruby in place of C

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris F. (Guest)
on 2007-01-15 13:43
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.
Robert H. (Guest)
on 2007-01-15 17:26
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 :)
Dido S. (Guest)
on 2007-01-19 17:29
(Received via mailing list)
On 1/15/07, Chris F. <removed_email_address@domain.invalid> 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.
Bira (Guest)
on 2007-01-19 17:30
(Received via mailing list)
On 1/15/07, Chris F. <removed_email_address@domain.invalid> 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.
This topic is locked and can not be replied to.