Ruby and science ?


M

Michel Demazure

I am really puzzled.

I am a scientist and I have been using ruby for years. I like thinking
and programming in ruby, but feel more and more uneasy. I'll try to
express my feelings below (I am not a native English speaker).

The ruby language and the ruby ecosystem (and the wonderful ruby
community) fit perfectly with small applications, scripting, web
frameworks, and so on. When you come to science, it is another story.
Numerical computing, statistics, whatever, cannot be coded in pure ruby
and you have to rely on specialized libraries. There are tentative gems
(generally obsolete and not maintained) to connect ruby to these
librairies.

Take for instance 'linalg' for linear algebra. It is based on LAPACK.
You need a Fortran to c converter, but f2c was deprecated, was replaced
by g2c, and g2c is deprecated but not replaced, waiting for gfortran...
Moreover, the compilation chain uses uncompatible versions of the c
compiler (or even of ruby itself). Whether on Linux (Ubuntu Lucid) or on
Windows, I had to give up. I understand the situation is not different
on OSX.

The situation is quite similar when you try to connect to the R language
for statistics, or whatever similar. The web is full of old posts asking
for help in similar situations with zero answer.

Am I wrong ? Maybe I am too clumsy. But, after all, a programming
environment is a tool to do your job and deliver. My job is to deliver
science and I end spending my time compiling (I mean failing to compile)
libraries.

The advice I usually get is : shift to Python. A very sad perspective
indeed.

More generally, is there a future for ruby outside its present niches ?

_md
 
Ad

Advertisements

P

Phillip Gawlowski

Am I wrong ? Maybe I am too clumsy. But, after all, a programming
environment is a tool to do your job and deliver. My job is to deliver
science and I end spending my time compiling (I mean failing to compile)
libraries.

If you need the proper tools Right Now, then, well, you have to pick
another tool from your toolbox.
The advice I usually get is : shift to Python. A very sad perspective
indeed.

More generally, is there a future for ruby outside its present niches ?

Of course there is. However, the support (especially in the sciences)
requires two abilities: A solid understanding of the problem space,
and a solid understanding of programming to implement solutions that
fit the problem space.

IOW: scientific Ruby libraries need scientists who can write Ruby code
(and/or C code to wrap binaries or to provide Ruby interfaces to
tools).

I'd love to do my computations for EE in Ruby however, since there's
pretty much no support for the kinds of maths I need to use (linear
algebra, complex numbers), I'm pretty much stuck with Maple. And I
neither have the time, nor the skill, to implement this properly for
other people using Ruby. Unfortunately (though, a complex number
library shouldn't be too difficult to implement).


Though, I wonder:
Numerical computing, statistics, whatever, cannot be coded in pure ruby
and you have to rely on specialized libraries.

Why? Unless you need more accuracy than the IEEE float provides, you
should be fine in Ruby, unless performance is a major issue, where you
can drop down to C code, if need be (for example with Ruby Inline[0]).

Or is the data parsing / presentation / plotting the issue?

[0] http://www.zenspider.com/ZSS/Products/RubyInline/
--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
M

Michel Demazure

Phillip Gawlowski wrote in post #968809:
Numerical computing, statistics, whatever, cannot be coded in pure ruby
and you have to rely on specialized libraries.

Why? Unless you need more accuracy than the IEEE float provides, you
should be fine in Ruby, unless performance is a major issue, where you
can drop down to C code, if need be (for example with Ruby Inline[0]).

The issue is internal representation. For instance a matrix 1000 x
100000, even of small ints. You need an internal representation of
Fortran type. Actually, 'narray' does that perfectly, but is very
limited in scope (only one real method : LU decomposition). The good
answer seems an interface to the big tools : MathLab, SciLab,... This is
more or less what PyMaths is about, as I understand well.

More generally, bigs things with many indices cannot be really managed
with towers of enumerators...

_md
 
A

Ammar Ali

Take for instance 'linalg' for linear algebra. It is based on LAPACK.
You need a Fortran to c converter, but f2c was deprecated, was replaced
by g2c, and g2c is deprecated but not replaced, waiting for gfortran...
Moreover, the compilation chain uses uncompatible versions of the c
compiler (or even of ruby itself). Whether on Linux (Ubuntu Lucid) or on
Windows, I had to give up. I understand the situation is not different
on OSX.

Have you seen Ruby/GSL?

http://rb-gsl.rubyforge.org/

It just got a new release last month, and looks like it has decent
coverage of GSL.

Regards,
Ammar
 
P

Phillip Gawlowski

The issue is internal representation. For instance a matrix 1000 x
100000, even of small ints. You need an internal representation of
Fortran type. Actually, 'narray' does that perfectly, but is very
limited in scope (only one real method : LU decomposition). The good
answer seems an interface to the big tools : MathLab, SciLab,... This is
more or less what PyMaths is about, as I understand well.

More generally, bigs things with many indices cannot be really managed
with towers of enumerators...

That's true. But it's not like they are much more manageable in for
and while loops, either. But having to deal with enumerations, instead
of "just" using a method call, is cumbersome at best, error prone at
worst, especially when working on the code alone.

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
Ad

Advertisements

T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

Take for instance 'linalg' for linear algebra. It is based on LAPACK.
You need a Fortran to c converter, but f2c was deprecated, was replaced
by g2c, and g2c is deprecated but not replaced, waiting for gfortran...
Moreover, the compilation chain uses uncompatible versions of the c
compiler (or even of ruby itself). Whether on Linux (Ubuntu Lucid) or on
Windows, I had to give up. I understand the situation is not different
on OSX.


Have you considered trying to use a library like JAMA with JRuby?

http://math.nist.gov/javanumerics/jama/
 
C

Colin Bartlett

[Note: parts of this message were removed to make it a legal post.]

Tony Arcieri wrote in post #968904:

I am still reluctant to a jump to jruby. I'll first check GSL on MRI
(1.9.2).



Doing fairly intensive actuarial type calculations I've found:
1. JRuby is currently(?) and anecdotally somewhat slower than MRI 1.9, but
not so much slower as to be a problem.
2. Integration with Java seems to be easy: I'm not a Java programmer, but
I've found it easy to write Java code to do the number crunching, and mostly
easy to integrate the "compiled" Java code with JRuby. (I say mostly because
at the start I couldn't find a way to compile the Java code in a way that
would reliably work with JRuby, but that was essentially me not
understanding how Java packages really worked. I still don't understand how
Java packages really work, but I've found a way to compile that reliably
works for me with JRuby!) That's a big plus because I definitely don't
understand at the moment how to compile C code and integrate that with MRI
Ruby.
 
Ad

Advertisements

D

David Masover

Doing fairly intensive actuarial type calculations I've found:
1. JRuby is currently(?) and anecdotally somewhat slower than MRI 1.9, but
not so much slower as to be a problem.

And JRuby is getting faster all the time. It's not clear whether one will
necessarily beat the other.

In particular, I remember hearing discussions of a commandline flag in JRuby
which one could use to disallow altering methods on the core numeric types.
This would basically make Ruby math compile down to Java math. I imagine most
scientific applications wouldn't care about altering the core numeric types,
while most scientific applications would care about fast math.
2. Integration with Java seems to be easy: I'm not a Java programmer,

I am, and it is _trivial_. Every now and then I open up irb and pull in some
Java things, just for fun:

require 'java'
import java.util.ArrayList
a = ArrayList.new
a << 5
a << 'ten'
a.each{|x| puts x}

Basically, you think "How would I want this to work?" And then you "require
'java'" and do it, and it works. It's beautiful.

About the only unintuitive thing I ever found was implementing a Java
interface, and while it's somewhat unintuitive, it's still trivial:


require 'java'
import java.util.PriorityQueue
import java.util.Comparator

# singleton comparator
comp = Class.new {
include Comparator
def compare a,b
a.to_s <=> b.to_s
end
}.new

pq = PriorityQueue.new 11, comp
pq << 2
pq << 3
pq << 10
pq.remove # => 10
pq.remove # => 2
pq.remove # => 3


Aside from that, connecting to a Java class from Ruby is pretty much: Read the
Javadoc, open up irb, try to use it, watch it do exactly what you think it
should.

Oracle's behavior lately is making me kind of iffy about the future of Java as
a platform, but JRuby is just made of awesome.
That's a big plus because I definitely don't
understand at the moment how to compile C code and integrate that with MRI
Ruby.

ruby-inline is very cool, but it's still not quite as easy as being able to
write a Java class, pretend it's a Ruby class, and have it work.

I'd say, give it a spin. Worst thing that happens is you make the core of your
project portable among Ruby implementations.
 
M

Michel Demazure

Ryan Davis wrote in post #968969:
And thanks to Rocket Scientists, it does Fortran too!

Which means my problem was just finding where to look up !

Actually, is there a place, with a FAQ like : if you want to do this
with ruby, then use that ?

_md
 
P

Phillip Gawlowski

Actually, is there a place, with a FAQ like : if you want to do this
with ruby, then use that ?

Not quite, but have a look at ruby-toolbox.com (IIRC), which gives an
overview of what's available fir what. And there's the Ruby
Application Archive, of course.

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
M

Michel Demazure

Phillip Gawlowski wrote in post #969006:
Not quite, but have a look at ruby-toolbox.com (IIRC), which gives an
overview of what's available fir what. And there's the Ruby
Application Archive, of course.
'gsl' was not in the toolbox, and (stupid me) I did not look in the RAA
!
_md
 
J

Jiqiang Niu

How to unsubscribe ?

-----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6-----
=E5=8F=91=E4=BB=B6=E4=BA=BA: Michel Demazure =
[mailto:[email protected]]=20
=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: =
2010=E5=B9=B412=E6=9C=8817=E6=97=A5 16:57
=E6=94=B6=E4=BB=B6=E4=BA=BA: ruby-talk ML
=E4=B8=BB=E9=A2=98: Re: Ruby and science ?

Phillip Gawlowski wrote in post #969006:
Not quite, but have a look at ruby-toolbox.com (IIRC), which gives an
overview of what's available fir what. And there's the Ruby
Application Archive, of course.
'gsl' was not in the toolbox, and (stupid me) I did not look in the RAA=20
!
_md

--=20
Posted via http://www.ruby-forum.com/.
 
Ad

Advertisements

K

Kent R. Spillner

Howdy-=0A=0A> How to unsubscribe ?=0A=0AYou can't; the Ruby mailing lists a=
re broken and the mailing list owner is unresponsive.=0A=0AI've been trying=
unsuccessfully to unsubscribe for years. Just setup filters on your end a=
nd curse under your breath every time a message (like yours) slips through.=
=0A=0ABest,=0AKent=0A
 
P

Phillip Gawlowski

Howdy-


You can't; the Ruby mailing lists are broken and the mailing list owner i= s unresponsive.

I've been trying unsuccessfully to unsubscribe for years. =A0Just setup f=
ilters on your end and curse under your breath every time a message (like y=
ours) slips through.

Or: You look at the source of the email, find the List-Unsubscribe
header, and find out that you can mail to (e-mail address removed)
with a body of "unsubscribe", will generate automatic cancellation of
the subscription.

Alternatively, you can go to
http://www.ruby-lang.org/en/community/mailing-lists/ and use the
"Unsubscribe" option from the form's Action dropdown.

Just saying.

--=20
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
K

Kent R. Spillner

Howdy-=0A=0A=0A>> You can't; the Ruby mailing lists are broken and the mail=
ing list owner is=0A>> unresponsive.=0A=0A[SNIP]=0A=0A> That is not true. Y=
ou can unsubscribe by sending your unsubscribe=0A> email to [email protected]=
uby-lang.org instead of=0A> (e-mail address removed). You can also unsubscri=
be from:=0A> =0A> http://www.ruby-lang.org/en/community/mailing-lists/=0A=
=0A=0ANo, it is true (or was ~9 months ago, when I last tried to unsubscrib=
e). The automated list manager at (e-mail address removed) is broken; t=
he web interface, too. =0A=0AWhen you send an unsubscribe request to ruby-=
(e-mail address removed) you receive a confirmation message, but when you rep=
ly to that confirmation message nothing ever happens. When you try to unsu=
bscribe through the web interface, you receive a confirmation email saying =
you've been unsubscribed, but you're not actually removed from the list.=0A=
=0AAnd when I email [email protected] I never receive a response.=0A=0ABest,=
=0AKent=0A
 
Ad

Advertisements

P

Phillip Gawlowski

Howdy-



No, it is true (or was ~9 months ago, when I last tried to unsubscribe). =
=A0The automated list manager at (e-mail address removed) is broken; the=
web interface, too.

Did you try to send an email with "help" in the subject to
[email protected] ? I just did, and the list server was kind enough to
send me the help file.

So, try again, and see if it works, before working with data that's 9
months old. ;)

--=20
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top