R
Ryan Davis
Ryan Davis wrote in post #968969:
Which means my problem was just finding where to look up !
gem install RubyInlineFortran
I haven't even looked at it in years.... but as far as I know, nasa uses it.
Ryan Davis wrote in post #968969:
Which means my problem was just finding where to look up !
This thread reminded me this nice blog post about the same topic -
http://allthingsprogress.com/posts/ruby-is-beautiful-but-im-moving-to-python
Unfortunately the author of that blog post seemed to end up switching
to Python. Maybe the author didn't/doesn't know also about the
possible libraries in Ruby.
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 JR= uby
which one could use to disallow altering methods on the core numeric type= s.
This would basically make Ruby math compile down to Java math. I imagine = most
scientific applications wouldn't care about altering the core numeric typ= es,
while most scientific applications would care about fast math.
About the only unintuitive thing I ever found was implementing a Java
interface, and while it's somewhat unintuitive, it's still trivial:
# singleton comparator
comp =3D Class.new {
=C2=A0include Comparator
=C2=A0def compare a,b
=C2=A0 =C2=A0a.to_s <=3D> b.to_s
=C2=A0end
}.new
pq =3D PriorityQueue.new 11, comp
Oracle's behavior lately is making me kind of iffy about the future of Ja= va as
a platform, but JRuby is just made of awesome.
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.
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.
of course JRuby is a fantastic tool for many use cases, but i've personal= ly
found science to be perhaps the worst possible application of it. =C2=A0t= hese
reasons are quite simple:
- speed. =C2=A0when you need something to be big or fast in science, gene= rally
even c won't cut it. =C2=A0fortran is still used in maybe 80% of big weat= her
systems for a reason: the compilers are generally doing faster floating
point ops than the equiv c compilers. =C2=A0one can bridge fortran -> c -=
ruby
quite easily (narray does this, gsl does this, etc) and it's =C2=A0place = where
JRuby actually makes the job much harder. =C2=A0Java, of course, isn't ev= en in
the ballpark.
- OS integration: the general approach to making ruby faster is to use
parallelism. =C2=A0the best way is to run lot's of processes. =C2=A0JRuby= 's interface
to the operating system level primitives for this (fork, et all) make thi= s
really really hard, close to impossible, to deal with simply. =C2=A0Mmap = is
another great example of something you want at your finger tips in
science... =C2=A0Interfaces to hardware boards connected to a research de= vice,
etc. =C2=A0I think any research based science makes getter close to the m= etal a
requirement.
- start up time. =C2=A0related to the above is the fact that science tend= s to
lead to many small programs running very often. =C2=A0map reduce jobs, cr= on jobs,
process pipe lines of related algorithims, toolkits made extensible via f= ile
based processing, tons of processing of stdin/stdout tend to be facts of
life when algorithm writers produce systems as a side effect. =C2=A0it's = not
pretty, but it is a fact i've seen repeated over and over.
i am definitely aware of some projects which make really heavy use of jav= a
and there, JRuby sure would be an awesome tool but my personal experience= is
that anything related to the JVM is a total non-starter. =C2=A0YMMV.
If you need to parallelize, processes are only one tool, and perhaps
the most blunt tool. In-process concurrency opens up many options that
are difficult or impossible with processes.
This is how you do parallel processing for your work. It's not the
only way, and being able to pass whole in-memory object graphs over to
another thread is distinctly more elegant than having to marshal it
through a memory-mapped file or IO pipe.
Perhaps you can't fork, but you can use real
concurrent threads, which are almost certainly easier (provided you
don't share mutable data, as with processes).
'gsl' was not in the toolbox, and (stupid me) I did not look in the RAANot 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.
Benjamin, you are moving the knife in the wound (translated from French,I totally understand the desire to have thse capabilities and the
elegance of ruby, but I think you'd find the science and engineering
community in the python world worth looking at in more detail.
Numpy, scipy, matplotlib, ipython mayavi2 are some buzzwords to look up
and then decide for yourself.
Regards,
Ben R.
Benjamin, you are moving the knife in the wound (translated from French,
do you say that in English ?)
"Twisting the knife" in English
martin
I totally understand the desire to have thse capabilities and the elegance of ruby, but I think you'd find the science and engineering community in the python world worth looking at in more detail.
Numpy, scipy, matplotlib, ipython mayavi2 are some buzzwords to look up and then decide for yourself.
Regards,
Ben R.
________________________________________
From: Michel Demazure [[email protected]]
Sent: Friday, December 17, 2010 12:56 AM
To: ruby-talk ML
Subject: Re: Ruby and science ?
Phillip Gawlowski wrote in post #969006:
'gsl' was not in the toolbox, and (stupid me) I did not look in the RAANot 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.
!
_md
ings, like manipulating processes in a POSIX environment. =C2=A0I don't use=Of course, like anything, there are tradeoffs and JRuby sucks at other th=
rrency in general. =C2=A0That "blunt tool" is pretty much the core of the U=All that said, I think you were pretty harsh on using processes for concu=
Threading is hard if you do it wrong. The problem is that it's easy to
do it wrong.
Follow these rules and threading is a very nice, very clean, very easy
way to do concurrency:
1. Don't share data
2. If you must share data, don't share immutable data
3. If you must share mutable data, guarantee ACID (atomicity,
consistency, isolation, durability)
Clojure is a perfect example of an environment that uses threads
heavily by defaulting to (2) and providing software transactional
memory for (3). Other than enforcing immutability, nothing Clojure
does for concurrency could not be done in Ruby. Anyone interested in
seeing concurrency done the Clojure way with JRuby can find many
examples online.
Threads "fail" in that none of these rules are enforced at any level.
They're a very sharp tool with many dangerous paths. But I prefer
sharp tools.
e plague when I was a younger programmer because everyone had me convinced =It bugs me that people are so harsh on fork(). =C2=A0I avoided it like th=
it was evil. =C2=A0I'm now far more dangerous because I took the time to le=
arn it and understand it. =C2=A0I strongly recommend all programmers do the=
same. =C2=A0(By the way, ara.t.howard taught me most of what I know about =
processes, directly and indirectly!)
I have no problem with fork. If JRuby could support fork on the JVM,
we would do so. We don't only because all mainstream JVMs spin up
multiple threads, which are not carried along to forked child
processes (and even if they could be restarted, it's a very
complicated transition that might defeat much of the benefit of
forking).
=C2=A0Processes are also not at all evil. =C2=A0Judge not lest ye be judged=So JRuby is good at threads and not so good at processes, in my opinion. =
=C2=A0
It might be more correct to say that the JVM is good at threads and
not so good at processes, nothing that JRuby makes it possible via FFI
to be nearly as good at processes as any POSIX application. We have
simply prioritized making JRuby work uniformly across platforms first,
while still providing the tools people need to opt out of portability
for lower-level behaviors and features.
- Charlie
I totally understand the desire to have thse capabilities and the elegance of ruby, but I think you'd find the science and engineering community in the python world worth looking at in more detail.
Numpy, scipy, matplotlib, ipython mayavi2 are some buzzwords to look up and then decide for yourself.
The JVM and the JDK APIs suck at process manipulation...not JRuby.
JRuby does the best job it can do cross-platform with the JDK APIs
provided for it. If you need to go outside those APIs, or if we "suck"
in how we utilize them, it's a trivial matter to bind native C
process-management logic via FFI and use that. It won't be as portable
as what we provide, but it will work.
Oh come now. If the JVM sucks at something, JRuby sucks at it too. Don't pass the buck.
If it were trivial, why aren't you shipping it (or at least pointing to a jruby supported gem that does)? You've espoused FFI as the C-API silver bullet time and again. I have doubts that it is that trivial as FFI itself seems non-portable.
Don't pass the buck.
=20
You couldn't be more wrong. It's understandable since you don't
actually know anything about JRuby's implementation.
Nice Ad Hominem. It's just that I don't need to know anything about =
jruby's implementation to identify someone passing the buck when they do =
it.
Or... are you claiming that JRuby doesn't suck at process manipulation =
and that JEG is wrong, or worse, a liar?
But JEG is right, it does suck. That's not a terrible thing. Sometimes =
your dogmatic "rah rah java/jruby" thing blinds you to simple truths: =
jruby being built on the jvm gives it a lot of strengths, but as JEG =
said (so succinctly), "like anything, there are tradeoffs and JRuby =
sucks at other things". That's not the end of the world, but just =
because you claim it isn't so, doesn't make it true.
What I'd really like to see are FFI-based wrappers around key science
and math libraries, rather than more blasted C extensions that can't
be run concurrently and aren't easily portable across impls. FFI works
incredibly well for these isolated libraries (as opposed to FFI for
kernel-level features, which can have many platofrm-specific
differences).
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.