Saturday September 13, 2008
04:53 AM
fibonacci numbers
I wrote a small script in Perl to calc the N first terms of Fibonacci serie:
#-- fibo script
sub fibo {
return 1 if( $_[0] < 2 ) ;
return fibo($_[0]-1) + fibo($_[0]-2);
}
for($i=0; $i<=40; $i++) {
$f = fibo($i);
print "$i : $f\n";
}
#-- eof fibo.pl
I tried to calc the first 40 numbers, it tooks in my PC about 16 minutes. I weren't worried about writting a fast algoritm, just curious about the performance of a recursive call algorithm.
A friend of me, advertised me that the similar Java version code, ran fast, so I tried:
// Java fibonnaci class
class fibo {
public static long calc(long x) {
if( x < 2 ) return 1;
return calc(x-1) + calc(x-2);
}
public static void main(String s[]) {
for(int i=0; i<=40; i++) {
System.out.println(i + " : " + calc(i));
}
}
}
// EOF Java fibonnaci class
----------------------------
The results (40 terms calc):
1) Perl: 16 minutes
2) Java: 16 seconds (!)
I'm sure that Java does some kind of optimization at the Virtual Machine.
I hope that Parrot team will be able to make a very fast virtual machine...
Sunday May 18, 2008
01:48 PM
Perl Message System
I used JMS (Java Message System) in order to provide async message communication between applications. It supports other key features like persistence and transanctions.
I always ask myself why there is no equivalent PMS - Perl Message System in the Perl World.
Sunday May 11, 2008
01:44 AM
Perl ORM
I have used Perl DBI and sometimes SQL::Abstract for data-layer. I'd like start to use DBIx::Class or Rose::DB (not decided yet), but I'm not sure about the tunning facilities of this ORM's.
Sometimes, we have complex (very complex) querys writed with no standar SQL (i.e. Oracle rules for using concrete indexes, or PL/SQL calls, etc).
DBI works well for us, perhaps ORM fails in this concrete scenario.
Friday May 09, 2008
03:56 PM
First note
Hi, this is my first note at this journal. I use Perl every day at my work, it's great and nice. I hope next years our favourite language will add amazing new features, modules and frameworks; I'm sure if all of us help.
print "my hello world!\n";