ruby vs. java?

F

Franz Hartmann

Hello all,

just call me Franz. I study physic in Berlin, but i am from bavaria (that is
in the south of germany). sorry for my bad english but foreign languages are
not my strong point. i like more mathematic.

I want to do a physical model calculation about the dynamics of
incompressibel liquids. I am not sure which is the best programming language
for this. I think about visual basic, java and ruby. I know java quite good
and vb and ruby a bit. actually i wanted to do it in vb but its to powerful
for me. so i am looking for something easier.

can you tell me the essential differences between java and ruby? what can
you do in ruby that you cannot do in java? and what about jruby? can i
combine java and ruby?

Franz

ps. does ruby run on macintosh tiger?

_________________________________________________________________
MSN Hotmail. Anmelden und gewinnen! http://www.msn.de/email/webbased/ Ihre
Chance, eines von 10 T-Mobile MDA II zu gewinnen!
 
M

Michael Ulm

Franz said:
Hello all,
--snip--
I want to do a physical model calculation about the dynamics of
incompressibel liquids. I am not sure which is the best programming
language for this. I think about visual basic, java and ruby. I know
java quite good and vb and ruby a bit. actually i wanted to do it in vb
but its to powerful for me. so i am looking for something easier.

can you tell me the essential differences between java and ruby? what
can you do in ruby that you cannot do in java? and what about jruby? can
i combine java and ruby?

Sorry Franz, you are on a completely wrong track there. As much as
I hate to steer people away from Ruby, I don't think any of the
programming languages you mention are a good choice for numeric
simulations (if you would have to do it in one of those languages,
Ruby would be the best of the three for most applications).

I would recommend Octave as the best free choice for getting
solutions for (partial) differential equations. If you have money
to burn, you may want to look at Matlab or, depending on your
specific needs, Maple or Mathematica.

HTH,

Michael

P.S. do yourself a favour and forget that such a beast as vb exists.

--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: (e-mail address removed)
Visit our Website: www.isis-papyrus.com
 
J

Jaypee

Franz Hartmann a écrit :
Hello all,

just call me Franz. I study physic in Berlin, but i am from bavaria
(that is in the south of germany). sorry for my bad english but foreign
languages are not my strong point. i like more mathematic.

I want to do a physical model calculation about the dynamics of
incompressibel liquids. I am not sure which is the best programming
language for this. I think about visual basic, java and ruby. I know
java quite good and vb and ruby a bit. actually i wanted to do it in vb
but its to powerful for me. so i am looking for something easier.

can you tell me the essential differences between java and ruby? what
can you do in ruby that you cannot do in java? and what about jruby? can
i combine java and ruby?

Franz

ps. does ruby run on macintosh tiger?

_________________________________________________________________
MSN Hotmail. Anmelden und gewinnen! http://www.msn.de/email/webbased/
Ihre Chance, eines von 10 T-Mobile MDA II zu gewinnen!
I can answer to the PS: yes, the version 1.8.2 of ruby is a standard
part Tiger.
For the other points, may I suggest you to be specific about what you
are looking for in VB or in Java (GUI, ready to use libs etc) that you
did not find. It will help further answers.
J-P
 
R

Robert Klemme

Dear Franz,

Franz said:
Hello all,

just call me Franz. I study physic in Berlin, but i am from bavaria
(that is in the south of germany).

You sure wanted to say "Bavaria is the southern neighbour of Germany"...
:)))
(Sorry group, this is just some internal German joke.)
sorry for my bad english but
foreign languages are not my strong point. i like more mathematic.

I want to do a physical model calculation about the dynamics of
incompressibel liquids. I am not sure which is the best programming
language for this. I think about visual basic, java and ruby. I know
java quite good and vb and ruby a bit. actually i wanted to do it in
vb but its to powerful for me. so i am looking for something easier.

VB is too powerful? I've never heard that before...

I'm not really into physical calculations but I'm sure you need a fast
language as these things tend to involve a lot of number crunching. IMHO
that rules out VB, leaving Java and Ruby. For Ruby you might need a C
extension to do the math (depending on your requirements you will have to
write it on your own or you might find something useful on the RAA).
Plain Java can be quite fast if used properly.
can you tell me the essential differences between java and ruby? what
can you do in ruby that you cannot do in java? and what about jruby?
can i combine java and ruby?

Well, there are of course performance differences (depending on the
application at hand). Ruby is usually more concise and easier to read
(IMHO) because it needs less lines of code. Other than that I think you
can do pretty much the same with both.

Maybe it's more important which tools are around: is there a numerical
library capable of doing the kind of stuff you need? Are there IDE's
available that suit you? These kinds of questions.
Franz

ps. does ruby run on macintosh tiger?

Dunno.

Kind regards

robert
 
R

Ralf Müller

Hello all,

just call me Franz. I study physic in Berlin, but i am from bavaria (that is
in the south of germany). sorry for my bad english but foreign languages are
not my strong point. i like more mathematic.

I want to do a physical model calculation about the dynamics of
incompressibel liquids. I am not sure which is the best programming language
for this. I think about visual basic, java and ruby. I know java quite good
and vb and ruby a bit. actually i wanted to do it in vb but its to powerful
for me. so i am looking for something easier.

can you tell me the essential differences between java and ruby? what can
you do in ruby that you cannot do in java? and what about jruby? can i
combine java and ruby?

Well...

it depends on what you mean by 'the best programming language for this'?
Should it be fast? or have beautiful code? Should it be extensible? Do you want to rely on existing libraries?

I did some numerical analysis in geophysics and it took 1-7 days to get the results. So, you should keep in mind how expensive you number crunching will be. Maybe a week is to long for you.

btw: there is a 'Runge-Kutta Ruby Class' avaliable, search freshmeat

regards
ralf
 
F

Franz Hartmann

Hello Michael and all of you,
From: Michael Ulm <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 18:19:01 +0900



Sorry Franz, you are on a completely wrong track there. As much as
I hate to steer people away from Ruby, I don't think any of the
programming languages you mention are a good choice for numeric
simulations (if you would have to do it in one of those languages,
Ruby would be the best of the three for most applications).

Why are the programming languages i need not a good choice? Everyone says
that object oriented programming is much faster than normal. Java has more
object oriented feetures than ruby, or supports ruby interfaces and things
like that too? i have not found any thing about it but documentation is very
poor.
I would recommend Octave as the best free choice for getting
solutions for (partial) differential equations. If you have money
to burn, you may want to look at Matlab or, depending on your
specific needs, Maple or Mathematica.

i cannot use octave. SGI octave is a unix machine and i need windows
compatible, or best case macintosh, because i need use word & excel & power
point (& counterstrike *g* ). which programming languages run on octave?
thank you for the suggestion, i have already tried matlab but it is not good
to. I want to do object oriented programming because it is faster.

what means HTH?
Michael

P.S. do yourself a favour and forget that such a beast as vb exists.

Why that? VB is industry standard, a VERY powerful object oriented language.
All programmers i know write in VB, and excel, word etc also use VB. What is
wrong about it? (apart from that it is very difficult)
--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: (e-mail address removed)
Visit our Website: www.isis-papyrus.com

Nice website!

Franz

_________________________________________________________________
Die rote Karte für lästige E-Mails. MSN Hotmail mit Junk-Mail-Filter.
http://www.msn.de/antispam/prevention/junkmailfilter Jetzt kostenlos
anmelden!
 
F

Franz Hartmann

Hello Robert,
From: "Robert Klemme" <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 18:30:27 +0900

Dear Franz,



You sure wanted to say "Bavaria is the southern neighbour of Germany"...
:)))
(Sorry group, this is just some internal German joke.)

S**preiß damischer ;-) ! Wos wuisch? (<= Sorry to, but that is how we
bavarians react on other germans)
A Preiß is Nice, but a Bayer is Higher.
VB is too powerful? I've never heard that before...

there is not one vb book which is <1000 sides and everything goes like
this.object.has.another.property.than(the.other.object.which.we.talk.about)...
and you can program excel & word with it. thats what i think, maybe i should
use an excel sheet and do the programming with vb. or is their something
like ruby for excel?
I'm not really into physical calculations but I'm sure you need a fast
language as these things tend to involve a lot of number crunching. IMHO
that rules out VB, leaving Java and Ruby. For Ruby you might need a C
extension to do the math (depending on your requirements you will have to
write it on your own or you might find something useful on the RAA).
Plain Java can be quite fast if used properly.

Why is vb not a fast language? I have read statistics who say that you can
program in vb 10x as faster than in c/c++. i dont know, i cant c and i dont
like it too. /must/ i write an extension to do math in ruby?
how fast can java be? depends this not on the browser?
and what is RAA? i guess some archive but where can i find it?
Well, there are of course performance differences (depending on the
application at hand). Ruby is usually more concise and easier to read
(IMHO) because it needs less lines of code. Other than that I think you
can do pretty much the same with both.

Is this good? Can we say: Less code => run faster?
Maybe it's more important which tools are around: is there a numerical
library capable of doing the kind of stuff you need? Are there IDE's
available that suit you? These kinds of questions.

Oh, dont you worry about the library, i think i have all the necessary math
books on my shelf.
What is IDE?

I dont too, so there is at least one thing we have common. I think we will
be friends, if if you are a Preiß :) .
Kind regards

robert

Franz

_________________________________________________________________
Nicht lange suchen – finden! MSN Suche. http://search.msn.de/ Jetzt testen!
 
F

Franz Hartmann

Hello Jaypee,
From: Jaypee <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 18:25:27 +0900

Franz Hartmann a écrit :
I can answer to the PS: yes, the version 1.8.2 of ruby is a standard part
Tiger.

That is very good. Because i think to buy a macintosh perhaps. the G5 is now
at 2x2.7 ghz and i think this is just what i need. can ruby handle two
processors? (or do i need a c extension for that *g* ?)
btw, i know this is a ruby list but is their any way to run windows programs
on mac?
For the other points, may I suggest you to be specific about what you are
looking for in VB or in Java (GUI, ready to use libs etc) that you
did not find. It will help further answers.
J-P

yes you may but i myself dont know yet :) . i think windows and graphics
will be needed. 3d graphics would be super to present the results.
as i wrote before, going into libraries is not a problem, i have all the
books and documentations.

Thanks
Franz

_________________________________________________________________
Eine für alle. MSN Suche. http://search.msn.de Finden statt suchen!
 
M

Michael Ulm

Franz said:
Hello Michael and all of you,



Why are the programming languages i need not a good choice? Everyone
says that object oriented programming is much faster than normal. Java
has more object oriented feetures than ruby, or supports ruby interfaces
and things like that too? i have not found any thing about it but
documentation is very poor.

I do not say that object oriented programming is much faster than
normal, so not everyone is saying that :) From my experience, the
advantage of object oriented programming lies in better maintainability
of the code and (especially for Ruby) faster and cleaner design.
Java having more object oriented features than Ruby? Only if you
take Javas (slightly strange) definition of object oriented. However,
Java is a powerful language, with very good documentation - not the
worst choice for many things.
i cannot use octave. SGI octave is a unix machine and i need windows
compatible, or best case macintosh, because i need use word & excel &
power point (& counterstrike *g* ). which programming languages run on
octave?
thank you for the suggestion, i have already tried matlab but it is not
good to. I want to do object oriented programming because it is faster.

Object oriented programming has nothing to do with execution speed.

Trying to learn object oriented programming is a noble goal. If you
want fast and object oriented, use C++. If you want object oriented
and easy to program, use Ruby (be aware though, that Ruby is slow).
The best of both worlds would be Ruby with C++ extensions, but that
means you would have to learn a lot.

The reason I recommend Octave/Matlab is that there is already a lot
of infrastructure there for numerical computations. You would have
to write a lot of that yourself in most other languages.
what means HTH?

Hope That Helps
Why that? VB is industry standard, a VERY powerful object oriented
language. All programmers i know write in VB, and excel, word etc also
use VB. What is wrong about it? (apart from that it is very difficult)

vb is only available on one plattform. Microsoft itself wants to get
rid of it (so much for industry standard). The overall design is just
plain awful. It is by far the very worst scripting language I have ever
programed in.

HTH,

Michael


--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: (e-mail address removed)
Visit our Website: www.isis-papyrus.com
 
F

Franz Hartmann

From: Ralf Müller <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 18:42:47 +0900



Well...

it depends on what you mean by 'the best programming language for this'?
Should it be fast? or have beautiful code? Should it be extensible? Do you
want to rely on existing libraries?

as i said before, i need no libraries. have all the books at hand.
should be fast. what do you call a beautiful language?
I did some numerical analysis in geophysics and it took 1-7 days to get the
results. So, you should keep in mind how expensive you number crunching
will be. Maybe a week is to long for you.

oh, it will not be expensive at all because i can use my own computer. or
maybe i will by me a mac, that costs less then €3000.
if i can get the programm written in a week i will be very happy.
btw: there is a 'Runge-Kutta Ruby Class' avaliable, search freshmeat

thanks for the hint, but i went to freshmeat.com and it did not found
anything: it just gave me "Popular Categories" and such stuff. I mean,
but not what i look for. WHere said:
regards
ralf

thanks,
Franz

_________________________________________________________________
Ungestört surfen. MSN Toolbar mit Pop-up-Blocker. http://toolbar.msn.de/
Jetzt kostenlos downloaden!
 
L

Logan Capaldo

On 5/11/05 said:
=20
i cannot use octave. SGI octave is a unix machine and i need windows
compatible, or best case macintosh, because i need use word & excel & pow= er
point (& counterstrike *g* ). which programming languages run on octave?
thank you for the suggestion, i have already tried matlab but it is not g= ood
to. I want to do object oriented programming because it is faster.
=20
=20

GNU Octave IS a programming language., designed for numerical
applications. It runs on Windows, Linux and OS X. Its website is here:
http://www.octave.org/
 
F

Franz Hartmann

From: Michael Ulm <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 19:30:33 +0900



I do not say that object oriented programming is much faster than
normal, so not everyone is saying that :)

Okay, everyone except for you, $\infty - 1$ :)
but in fact all the commercials are about speed. i remember turbo-pascal 5.5
where they introduced oo: "guilty of speeding" (there was a very funny
picture to of a flying pig) -- it was not so fast then because i had an
atari st running a dos emulator, norton factor ~ 0.1 :))
okay, commercials are commercials but i think xerox used smalltalk to
implement the first windows system on 1960s hardware. i dont know how fast
processors were than but i think they cannot have been much faster than the
good old apple 2 :) .
i dont know much about smalltalk but they say it is really similar to ruby?
From my experience, the
advantage of object oriented programming lies in better maintainability
of the code and (especially for Ruby) faster and cleaner design.

yes, now you yourself say it: fast and clean design.

*****
* *
*
*****
*
* *
*****

**
Java having more object oriented features than Ruby? Only if you
take Javas (slightly strange) definition of object oriented. However,
Java is a powerful language, with very good documentation - not the
worst choice for many things.


Object oriented programming has nothing to do with execution speed.

i may be a bavarian wood-head but i just dont understand. do your programs
run faster with oo or do they not? just before you said "fast (...) design".
Trying to learn object oriented programming is a noble goal. If you
want fast and object oriented, use C++.

Uuargh! must i?
If you want object oriented
and easy to program, use Ruby (be aware though, that Ruby is slow).

but why is it slow, when it is so much like smalltalk?
The best of both worlds would be Ruby with C++ extensions, but that
means you would have to learn a lot.

i will have to learn a lot anyway. but cant i rather do ruby with java
extensions? isnt that the idea behind jruby?
The reason I recommend Octave/Matlab is that there is already a lot
of infrastructure there for numerical computations. You would have
to write a lot of that yourself in most other languages.


Hope That Helps

yes it does!
vb is only available on one plattform. Microsoft itself wants to get
rid of it (so much for industry standard).

doesnt vb run on mac too? then i will keep my pentium box. because i have so
many vb macros for word & excel.
The overall design is just
plain awful. It is by far the very worst scripting language I have ever
programed in.

well its very difficult to handle all that functionaility (as i admit that
its too difficult for me), but why do you say "the overall design is awful"?

what means HTH?
just kidding :)))))
Michael


--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: (e-mail address removed)
Visit our Website: www.isis-papyrus.com

Franz

_________________________________________________________________
Nicht lange suchen – finden! MSN Suche. http://search.msn.de/ Jetzt testen!
 
J

Jaypee

Franz Hartmann a écrit :
Hello Jaypee,



That is very good. Because i think to buy a macintosh perhaps. the G5 is
now at 2x2.7 ghz and i think this is just what i need. can ruby handle
two processors? (or do i need a c extension for that *g* ?)
btw, i know this is a ruby list but is their any way to run windows
programs on mac?



yes you may but i myself dont know yet :) . i think windows and
graphics will be needed. 3d graphics would be super to present the results.
as i wrote before, going into libraries is not a problem, i have all the
books and documentations.
....
Franz,
I have myself somehow tested this and unfortunately, ruby shall not take
advantage of the dual CPU. The example I used for this was the
calculation of the factorial of 100000. This is IMHO a good example to
discuss the performance question.
Especially in your case, where you master a domain where other people
are generally of little help, you need to be very autonomous and in that
regard, Ruby is very good, it helps you to really cope with some level
of complexity. In the example of the factorial. It takes 1 minute to
write in ruby and even if you deal with a very large integer, it's
ruby's business, not yours, and it takes 10 min or so to compute.

Or you may get the result in ten seconds after one day of laborious
coding in another language. Which language was best in that example?

Just my 2 cents (of Euro)
Jean-Pierre
PS: There are ruby-Tk, ruby-OpenGL, ruby-Fox (careful I did not test it
as thoroughly as it would be necessary), ruby-SVG, ruby-fltk ...
interfaces to best known graphical libraries or toolkit to make desktop
or web user front-ends.
 
F

Franz Hartmann

Hello Logan,
From: Logan Capaldo <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 19:35:41 +0900



GNU Octave IS a programming language., designed for numerical
applications. It runs on Windows, Linux and OS X. Its website is here:
http://www.octave.org/

that is strange, i always thought that octave was the name of the big sgi
box. havent these gnu guys been accused by sgi yet?
thank you for the link, but i dont like it. it is to much like fortran for
me. they say that when you know fortran you can learn octave in a few hours.
i think fortrans time is over. and besides, what shall my professor say when
i come up with a fortran program?

Franz

_________________________________________________________________
Nicht lange suchen – finden! MSN Suche. http://search.msn.de/ Jetzt testen!
 
R

Ralf Müller

as i said before, i need no libraries. have all the books at hand.
should be fast. what do you call a beautiful language?
I wrote beautiful code, i.e. code that is easy to read and to understand even if you look at it for the first time.
just ruby

If it should be fast, use a unix terminal at the physics deprtement und choose C or Fortran. 2D or 3D can be generated out of text-files with gnuplot
oh, it will not be expensive at all because i can use my own computer. or
maybe i will by me a mac, that costs less then _3000.
if i can get the programm written in a week i will be very happy.
Maybe 'expensive' was too ambiguous: I meant, how much time will it take to run you program on a given machine, i.e. you computer. 1 day?, 1 week?
thanks for the hint, but i went to freshmeat.com and it did not found
anything: it just gave me "Popular Categories" and such stuff. I mean,
<eiteitei>skin care is quite nice</eiteitei>, but not what i look for. WHere
must i look?
try http://freshmeat.net/projects/rk4/
 
M

Michael Ulm

Franz said:
i may be a bavarian wood-head but i just dont understand. do your
programs run faster with oo or do they not? just before you said "fast
(...) design".

Mia österreicher san oba a Stuaschädl.

You are confusing two concepts here: (i) Design/implementation speed,
the time it takes you to program the thing, and (ii) execution speed,
the time it takes the program to produce the output.

Object oriented programming may help in (i), but not in (ii). So far,
I was assuming you want fast execution speed for simulations of
physical processes (for nontrivial simulations execution times may
easily reach weeks or months). If this is your goal, then none of
the three scripting languages you described will be nearly fast enough.
Octave might be. C or C++ with the right software libraries would be
fastest.

If your goal is learning (object oriented) programming, and the
simulations are just for you to play around with, then Ruby is an
excellent choice (with the caveat, that you may have to implement
more "infrastructure" e.g. triangulations, discretisations...).

etaoin shrdlu,

Michael

--
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-219, fax: +43 2236 21081
e-mail: (e-mail address removed)
Visit our Website: www.isis-papyrus.com
 
F

Franz Hartmann

Hello Jaypee,
From: Jaypee <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 20:05:28 +0900

Franz Hartmann a écrit :
....
Franz,
I have myself somehow tested this and unfortunately, ruby shall not take
advantage of the dual CPU. The example I used for this was the calculation
of the factorial of 100000. This is IMHO a good example to discuss the
performance question.

Yes, and i am schocked... i have a pentium 3 box (900 mhz) which give me
1800 mips and it needs 14 min 43 secfor the calculation of 100000
multiplications.
14 x 60 + 43 sec = 883 sec
100000 operations / 883 sec = 113 flops???
c64 basic calculated 10000 sqrts within less than 20 minutes, that amount to
10000 / 1200 = 8 flops. at 0.9 mhz, that is 1/1000.
(8 / 113) / (0.9 / 900) = 70.8
Does this mean that ruby is 70 (seventy) times slower than c64 basic, not
counting the advantages of 32 vs 8 bit????
Or did i just make some very stupid error? Here's the program:


def fac( n )
f = 1
(1..n).each { |x| f *= x }
return f
end

print "%d\n" % fac( ARGV[0].to_i )

Especially in your case, where you master a domain where other people are
generally of little help, you need to be very autonomous

That's what our professors always tell us to. :-(
and in that regard, Ruby is very good, it helps you to really cope with
some level of complexity. In the example of the factorial. It takes 1
minute to write in ruby and even if you deal with a very large integer,
it's ruby's business, not yours, and it takes 10 min or so to compute.

Or you may get the result in ten seconds after one day of laborious coding
in another language. Which language was best in that example?

The one where it takes me 1 min to write and 10 sec to run. why is their no
such thing?
Just my 2 cents (of Euro)
Jean-Pierre
PS: There are ruby-Tk, ruby-OpenGL, ruby-Fox (careful I did not test it as
thoroughly as it would be necessary), ruby-SVG, ruby-fltk ... interfaces to
best known graphical libraries or toolkit to make desktop or web user
front-ends.

thanks, i'll have a look.

Franz

_________________________________________________________________
Die rote Karte für lästige E-Mails. MSN Hotmail mit Junk-Mail-Filter.
http://www.msn.de/antispam/prevention/junkmailfilter Jetzt kostenlos
anmelden!
 
F

Franz Hartmann

From: Nikolai Weibull <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (ruby-talk ML)
Subject: Re: ruby vs. java?
Date: Wed, 11 May 2005 20:42:16 +0900

Franz Hartmann, May 11:


Why would we call you anything else?,
nikolai

well i don't know why you would. thats why i make sure. :)

Franz

_________________________________________________________________
So einfach geht das. MSN Toolbar mit Pop-up-Blocker. http://toolbar.msn.de/
Jetzt kostenlos downloaden und gut ist!
 
J

Jim Freeze

* Franz Hartmann said:
1800 mips and it needs 14 min 43 secfor the calculation of 100000
multiplications.
14 x 60 + 43 sec = 883 sec
100000 operations / 883 sec = 113 flops???
c64 basic calculated 10000 sqrts within less than 20 minutes, that amount
to 10000 / 1200 = 8 flops. at 0.9 mhz, that is 1/1000.
(8 / 113) / (0.9 / 900) = 70.8
Does this mean that ruby is 70 (seventy) times slower than c64 basic, not
counting the advantages of 32 vs 8 bit????
Or did i just make some very stupid error? Here's the program:


def fac( n )
f = 1
(1..n).each { |x| f *= x }
return f
end

print "%d\n" % fac( ARGV[0].to_i )

I can't answer your question exactly, but there are faster
ways to write the code. (BTW, did c64 basic support
arbitrarily large numbers and their math?)

And one other thing, I removed printing from the timing since
it can take some time to print out such a large number.

% ruby fac 7500
0.498884
0.337408
0.283017 # this is faster than #2
% ruby fac 17500
2.375539
2.075047
2.111601 # looks like a GC happened. Used to be faster.
% ruby fac 27500
5.997851
5.749802
5.797634

% cat fac
def fac1( n )
f = 1
(1..n).each { |x| f *= x }
return f
end

def fac2( n )
f = 1
(1..n).each { |x| f *= x }
end

def fac3( n )
(1..n).inject(1) { |f,x| f * x }
end

start = Time.now
fac1( ARGV[0].to_i )
puts Time.now - start

start = Time.now
fac2( ARGV[0].to_i )
puts Time.now - start

start = Time.now
fac3( ARGV[0].to_i )
puts Time.now - start
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,129
Latest member
FastBurnketo
Top