Kind of longish post and probably off topic but if you read it and have
any comments (especially on using Ruby as a glue or interface
language) then please mail me.

On Mon, 17 Jul 2000, Aleksi Niemel wrote:

> I'm very interested to listen you when you've some insights to share about
> using Ruby as a prototype language (to get a basic desing "right", as you
> said, or maybe you didn't mean this). Especially the point when you convert
> part of the Ruby code to C(++/# :). I'm eager to see if you (have to) use
> your proto as a throw-away code or more as a hacked-together framework,
> which is then speeded up part by part.
> 
I'm not sure that we're talking about the same things here so let me try
to clarify what I've been doing:

1. I have a large number of Machine Learning (ML) components (algorithms,
combination schemes, dataset types etc.) written in various languages
(mostly C/C++ but also some exe for which I have no source but only the
docs for the CLI) that I want to work together. They have not been
developed to work together but I need them to do so some sort of
interface/glue code is needed.

2. I make a full OO design using Ruby's features (Mix-in etc.) for the
main types of components and how they should work together. This is a
language in which ML in general can be expressed.

3. Using Ruby's C/C++ interface I make Ruby wrapper classes for each ML
component from 1. It "emulates" the interface required by the Ruby
framework/design in 2 by converting Ruby calls to calls in the existing
code. For the components for which I have no source code the wrapper class
converts between the command-line interface of the exe and the interface
required by the design.

4. When performance is crucial I try to use Ruby classes implemented in
C/C++ extensions. This way I can extract the C/C++ structures and work
with them drectly. For example I use NArray (Ruby extension for numerical
arrays implemented as one chunk of mem in C) and align the data so that I
can directly use it in the existing C/C++ code.

The main benefits:

b1. When using the system one can work with a full OO framework and do not
need to remember all the specifics of each component. Principle of least
surprise / effort and other OO/Ruby features applies when using the
system.

b2. Can put together combinations of the components quickly in interactive
mode (very nice when doing research!) and later script them for
over-the-night processing on large data sets. This would have been harder
in C or C++.

b3. Leverage the existing source code by only having to write each
components interface to the framework.

b4. The performance penalty (compared to C++ impl) is not very large since
Ruby is mostly used to setup and control combinations of components and
send data between them.

b5. I can implement future ML components directly in Ruby using the
"language" of the framework. (I guess this comes closest to your
prototyping questions since, after testing, I could choose to implement
some of the Ruby-implemented funcs in C/C++. However, as of now I
haven't done this. Sorry if initial post was misleading)

Any comments, tips on tools/extension that might be useful or links to
related stuff in Ruby (Machine Learning/AI or other projects interfacing
existing code) are appreciated.

I guess most of the benefits are not Ruby-specific as opposed to Perl
or Python and you could argue that for example Python would give me
additional benefits (for example it can be compiled to native code). I
guess the elegance of Ruby (b1 above. I've previously used some
functional languages), the fact that I didn't know either of the languages
very well and my belief that most of Python's advantages over Ruby will
probably be overcome since Ruby is currently earlier in its 
development/evolution.

The Ruby features I'd love to see / things I'd love to find out:

* Being able to "freeze" an object and dump it to an exe that can be
executed stand-alone (without interpreter or external libs/exts) on a
non-Ruby aware machine. I distribute my jobs on a network of workstations
and it's not very nice to have to install Ruby on all of them prior to
execution.

* Native compilation for Wintel machines. Could add some extra boost to
performance-hungry applications?!

* Profiling Ruby code. Someone doing this today? How?

* I understand the basics of mix-in and single inheritance. But how should
you choose between them? I tend to use mix-in as much as possible since it
seems more flexible. Anyone got some rule-of-thumbs?

* Anyone actually doing GUI stuff on Wintel machines? Didn't put much
effort into it, but I couldn't get TK to work...

Regards,

Robert