[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Choosing a scripting language for scientific programming

deltaquattro

11/20/2007 1:08:00 PM

Hi,

I'm a Fortran scientific programmer, and recently I have had to write
a lot of shell scripts which let different codes communicate by means
of I/O files. Right now I'm using awk and (to a lesser extent) perl to
do this. However, I'd like to learn a newer scripting language and at
the same time learn OOP, so I'm choosing between Python and Ruby. The
applications I have in mind are:

1) (easy) automatic I/O files manipulation. Calculations, comparisons,
etc. among values contained in tables, and correspondent modfication
of the table entries;
2) (less easy) semi-automatic generation of graph, images, report,
etc., based on data in huge binary files (O(Gb));
3) (hard) create GUIs for scientifc codes, which could enable
unexperienced users to run the codes;

Which are the main differences between Ruby and Python? Which is
easier to learn? I've seen a lot of numerical libraries/extensions for
Python: does Ruby also support scientific programming? Thanks,

Best regards,

deltaquattro


14 Answers

Bil Kleb

11/20/2007 1:27:00 PM

0

deltaquattro wrote:
> Hi,

Hi.

> I'm a Fortran scientific programmer,

Me too, although not so much anymore. Ruby's ruined it for me. :)

> and recently I have had to write
> a lot of shell scripts which let different codes communicate by means
> of I/O files. Right now I'm using awk and (to a lesser extent) perl to
> do this.

Sounds like me in 1999.

> However, I'd like to learn a newer scripting language and at
> the same time learn OOP, so I'm choosing between Python and Ruby.

That was we did underneath our Exploring XP for Scientific Research
IEEE article: ieeexplore.ieee.org/iel5/52/26915/01196317.pdf

> 1) (easy) automatic I/O files manipulation. Calculations, comparisons,
> etc. among values contained in tables, and correspondent modfication
> of the table entries;

All the time; just cooked another one up a couple hours ago to check input
parameter distributions for a Monte Carlos sensitivity analysis of
flowfield radiation of a capsule re-entering Earth at 10.5 km/s.

> 2) (less easy) semi-automatic generation of graph, images, report,
> etc., based on data in huge binary files (O(Gb));

I've done at least 4 scientific papers with Ruby generated graphs,
images, reports, and tables based on data in huge binary files.
I've helped several other colleagues do the same.

> 3) (hard) create GUIs for scientifc codes, which could enable
> unexperienced users to run the codes;

I'm embarking on this journey by wrapping simulation codes
in a RESTful web service, currently with Rails. So one gains
both a "GUI" via a web browser, but there is also a RESTful back
door to enable one to glue together simulation tools from
disparate disciplines.

> Which are the main differences between Ruby and Python?

Ruby derives power from diversity; Python derives power from
the one true way. My brain best fit the former; YMMV.

I feel that creating a domain specific language is easier
in Ruby than Python, but my Python skills are /extremely/ weak.

> Which is easier to learn?

Yes.

> I've seen a lot of numerical libraries/extensions for
> Python: does Ruby also support scientific programming?

Yes; see for instance http://sciruby.codefor...

Regards,
--
Bil Kleb
http://fun3d.lar...
http://nasarb.rub...

Axel Etzold

11/20/2007 4:08:00 PM

0

Dear deltaquattro,


-------- Original-Nachricht --------
> Datum: Tue, 20 Nov 2007 22:10:07 +0900
> Von: deltaquattro <deltaquattro@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Choosing a scripting language for scientific programming

> Hi,
>
> I'm a Fortran scientific programmer, and recently I have had to write
> a lot of shell scripts which let different codes communicate by means
> of I/O files. Right now I'm using awk and (to a lesser extent) perl to
> do this. However, I'd like to learn a newer scripting language and at
> the same time learn OOP, so I'm choosing between Python and Ruby. The
> applications I have in mind are:

I don't know about Python, so I can't give you comparative information.
There is a guide to Ruby for programmers with hardly any prerequisites,
explaining the main features of the language, which you could go
through for the Ruby part of your comparison, to get a first impression
of that language and OOP:

http://pine.fm/Learn...

THE online reference to Ruby is the "Pickaxe book":

http://www.rubycentral.co... .

This mailing list is of course a little biased towards Ruby when
it comes to comparing it to other languages . :)


>
> 1) (easy) automatic I/O files manipulation. Calculations, comparisons,
> etc. among values contained in tables, and correspondent modfication
> of the table entries;

To do file I/O manipulation, look at rio:

http://rio.ruby... ,

if you want to read/write CSV data,

http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/..., may be of help.

You could also automate, say, Excel:

http://rubyonwindows.blogspot.com/2007/03/automating-excel-with-ruby-wor...

or connect to databases, such as MySQl, Postgresql etc ...




> 2) (less easy) semi-automatic generation of graph, images, report,
> etc., based on data in huge binary files (O(Gb));

gd-graph (just do a search for library names on http://raa.ruby..., if you want to know what exists)

can generate graphs,
ruport can generate reports,
rmagick can manipulate images,

> 3) (hard) create GUIs for scientifc codes, which could enable
> unexperienced users to run the codes;
>

there are several GUI creation frameworks,
such as wxruby, fxruby, and others - there's just recently been
a discussion thread about pros and cons of those.

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/279564?279...

> Which are the main differences between Ruby and Python? Which is
> easier to learn? I've seen a lot of numerical libraries/extensions for
> Python: does Ruby also support scientific programming? Thanks,
>

There is a website http://sciruby.codeforpeople.com/sr.cgi/Interesti... collecting
some scientific projects.

Then, there are bindings to GSL

http://rb-gsl.ruby...

and to the R statistical language,

http://raa.ruby...project/rsruby/,

and others ...

An argument in favour of Ruby is its elegance and conceptual
versatility - I am much faster coding in Ruby than in other
languages I have used.
Yet, generally, Ruby tends to be slower when it comes to execution
times of algorithms than other scripting languages - if scripting
for you essentially means crunching huge amounts of numbers, it might
be worth considering extending Ruby right away with C via rubyinline

http://www.zenspider.com/ZSS/Products/R...

or with fortran - as you know it already :). This one could use
some of your help ;-)

http://blog.zenspider.com/archives/2006/10/inlinefortran_100_rel...

Best regards,

Axel


--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/s...

Corey Haines

11/20/2007 7:16:00 PM

0

have you looked at F#?

On 11/20/07, deltaquattro <deltaquattro@gmail.com> wrote:
> Hi,
>
> I'm a Fortran scientific programmer, and recently I have had to write
> a lot of shell scripts which let different codes communicate by means
> of I/O files. Right now I'm using awk and (to a lesser extent) perl to
> do this. However, I'd like to learn a newer scripting language and at
> the same time learn OOP, so I'm choosing between Python and Ruby. The
> applications I have in mind are:
>
> 1) (easy) automatic I/O files manipulation. Calculations, comparisons,
> etc. among values contained in tables, and correspondent modfication
> of the table entries;
> 2) (less easy) semi-automatic generation of graph, images, report,
> etc., based on data in huge binary files (O(Gb));
> 3) (hard) create GUIs for scientifc codes, which could enable
> unexperienced users to run the codes;
>
> Which are the main differences between Ruby and Python? Which is
> easier to learn? I've seen a lot of numerical libraries/extensions for
> Python: does Ruby also support scientific programming? Thanks,
>
> Best regards,
>
> deltaquattro
>
>
>
>


--
http://www.corey...

Bil Kleb

11/20/2007 7:24:00 PM

0

coreyhaines@gmail.com wrote:
> have you looked at F#?

Or http://fortress.sun... ?

Regards,
--
Bil Kleb
http://tufte-latex.goog...

Chris Lowis

11/21/2007 1:42:00 PM

0


> I've done at least 4 scientific papers with Ruby generated graphs,
> images, reports, and tables based on data in huge binary files.
> I've helped several other colleagues do the same.

I'd love to have some more information, or a little write-up off how you
do some of these things, Bil. I'm currently trying to ween myself off
Matlab for these tasks.

Chris
--
Posted via http://www.ruby-....

ara.t.howard

11/21/2007 3:42:00 PM

0


On Nov 21, 2007, at 6:42 AM, Chris Lowis wrote:

>
>> I've done at least 4 scientific papers with Ruby generated graphs,
>> images, reports, and tables based on data in huge binary files.
>> I've helped several other colleagues do the same.
>
> I'd love to have some more information, or a little write-up off
> how you
> do some of these things, Bil. I'm currently trying to ween myself off
> Matlab for these tasks.
>
> Chris
> --
> Posted via http://www.ruby-....
>


for plotting

http://tioga.ruby...

for huge binary files

http://narray.ruby...

for general purpose computing

http://rubyforge.org/projec...

note that the last is the second largest, closely behind rails,
project on rubyforge. it's very complete.

a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Paul Van Delst

11/21/2007 4:37:00 PM

0

deltaquattro wrote:
> Hi,
>
> I'm a Fortran scientific programmer, and recently I have had to write
> a lot of shell scripts which let different codes communicate by means
> of I/O files. Right now I'm using awk and (to a lesser extent) perl to
> do this. However, I'd like to learn a newer scripting language and at
> the same time learn OOP, so I'm choosing between Python and Ruby. The
> applications I have in mind are:
>
> 1) (easy) automatic I/O files manipulation. Calculations, comparisons,
> etc. among values contained in tables, and correspondent modfication
> of the table entries;
> 2) (less easy) semi-automatic generation of graph, images, report,
> etc., based on data in huge binary files (O(Gb));
> 3) (hard) create GUIs for scientifc codes, which could enable
> unexperienced users to run the codes;
>
> Which are the main differences between Ruby and Python? Which is
> easier to learn? I've seen a lot of numerical libraries/extensions for
> Python: does Ruby also support scientific programming? Thanks,

Hello,

I use ruby to glue together a great deal of my Fortran executables. More importantly for
me, I also use ruby to generate a lot of boilerplate Fortran code. I've never used ruby
for graphing or GUIs since I have a large IDL library for the former (although the tioga
link is intriguing), and I'm not too interested in the latter (for my work stuff at least.
"Users? What users?" :o).

I started stone cold comparing Ruby and Python a couple years ago to teach myself about
OOP (in preparation for Fortran2003 compilers [still waiting!] that have OO-capabilities)
and settled on ruby because its basic technical premise is easy for me to grok:
"everything is an object". And Yukihiro Matsumoto's words in the Foreword to the "Pickaxe"
book made up my mind: "I believe that the purpose of life is, at least in part, to be
happy. Based on this belief, Ruby is designed to make programming not only easy but also fun."

Crikey. How can you argue with that?! :o)

cheers,

paulv

p.s. I'm sure this is true of other popular scripting languages but, being primarily a
Fortran95 coder, I am constantly amazed at the speed and quality of innovation in the ruby
community. It may be because I'm used to the glacial pace of Fortran language standard
updates, but it's amazing nonetheless.

ara.t.howard

11/21/2007 5:16:00 PM

0


On Nov 21, 2007, at 9:40 AM, Paul van Delst wrote:

>
> I use ruby to glue together a great deal of my Fortran executables.
> More importantly for me, I also use ruby to generate a lot of
> boilerplate Fortran code. I've never used ruby for graphing or GUIs
> since I have a large IDL library for the former (although the tioga
> link is intriguing), and I'm not too interested in the latter (for
> my work stuff at least. "Users? What users?" :o).

you might interesting in a few peices of code we use then:

session.rb : allows one to drive idl from ruby

idlrun: runs any idl routine from the command line using a special
syntax or yaml config file

yaml2idl: turns a yaml file into an idl declaration, we use this to
configure idl programs via yaml

regards.

a @ http://codeforp...
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama




lavigne.eric@gmail.com

11/21/2007 5:33:00 PM

0

> p.s. I'm sure this is true of other popular scripting languages but, being primarily a
> Fortran95 coder, I am constantly amazed at the speed and quality of innovation in the ruby
> community. It may be because I'm used to the glacial pace of Fortran language standard
> updates, but it's amazing nonetheless.

Ruby is one of the better ones, but yes this difference has more to do
with the glacial pace of Fortran development. I recommend trying OCaml
as a Fortran replacement. It fills the same niche as Fortran (high
performance computation and simulation) but is also well designed and
continues to improve at a brisk pace. OCaml and Ruby make an excellent
combination for scientific programming.

--
There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult.

- C.A.R. Hoare -

deltaquattro

11/23/2007 4:51:00 PM

0

On 20 Nov, 14:27, Bil Kleb <Bil.K...@NASA.gov> wrote:
> deltaquattrowrote:
> > Hi,
>
> Hi.
>

Hi, Bil,

sorry for not replying before to your very interesting post: I'm very
busy doing by hand all these marvelous things you do automatically
with Ruby :-) I'm astonished by the degree of automatization that you
reached with Ruby. Now I understand how it was possible that a U.S.
engineer at Boeing was able to 1) set up, 2) run, 3) postprocess a
complex CFD simulation and 4) write a detailed report, before I could
even get point 3) done for the same test case. Clearly he uses Ruby
(or Python :-)

> I've done at least 4 scientific papers with Ruby generated graphs,
> images, reports, and tables based on data in huge binary files.
> I've helped several other colleagues do the same.

This is great: your colleagues are very lucky to have you in their
team. May I ask you some more information on how you do this?
[..]

> > Which is easier to learn?
>
> Yes.

Pardon, I made a typo: I meant "Which one is easier to learn?". Do you
mean Ruby is easier to learn than Python?

> Regards,
> --
> Bil Klebhttp://fun3d.larc.nasa.govhttp://nasarb.rub...

Thanks for all the information: as soon as I have some more time I'd
like to contact you privately on the subject, if that's ok for you.
BTW, will you attend AIAA conference in Reno, in January?

Best regards,

deltaquattro