niceperl's Journal niceperl's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-02-09T13:10:35+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 niceperl's Journal fibonacci numbers <tt>I wrote a small script in Perl to calc the N first terms of Fibonacci serie:<br><br>#-- fibo script<br><br>sub fibo {<br>&nbsp; &nbsp; return 1 if( $_[0] &lt; 2 )<nobr> <wbr></nobr>;<br>&nbsp; &nbsp; return fibo($_[0]-1) + fibo($_[0]-2);<br>}<br><br>for($i=0; $i&lt;=40; $i++) {<br>&nbsp; &nbsp; $f = fibo($i);<br>&nbsp; &nbsp; print "$i : $f\n";<br>}<br><br>#-- eof<br><br>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.<br><br>A friend of me, advertised me that the similar Java version code, ran fast, so I tried:<br><br>// Java fibonnaci class<br><br>class&nbsp; fibo {<br><br>&nbsp; &nbsp; public static long calc(long x) {<br>&nbsp; &nbsp; &nbsp; &nbsp; if( x &lt; 2 ) return 1;<br>&nbsp; &nbsp; &nbsp; &nbsp; return calc(x-1) + calc(x-2);<br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp; public static void main(String s[]) {<br>&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i&lt;=40; i++) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(i + " : " + calc(i));<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<br>// EOF Java fibonnaci class<br><br>----------------------------<br>The results (40 terms calc):<br>1) Perl: 16 minutes<br>2) Java: 16 seconds (!)<br><br>I'm sure that Java does some kind of optimization at the Virtual Machine.<br>I hope that Parrot team will be able to make a very fast virtual machine...</tt> niceperl 2008-09-13T09:53:40+00:00 journal 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. <br> <br> I always ask myself why there is no equivalent PMS - Perl Message System in the Perl World. niceperl 2008-05-18T18:48:36+00:00 journal 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. <br> 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). <br> <br> DBI works well for us, perhaps ORM fails in this concrete scenario. niceperl 2008-05-11T06:44:56+00:00 journal 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. <br> <tt> print "my hello world!\n"; </tt> niceperl 2008-05-09T20:56:23+00:00 journal