Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: There's Only One Way To Do It

by gmpassos (Priest)
on Apr 07, 2004 at 05:47 UTC ( [id://343197]=note: print w/replies, xml ) Need Help??


in reply to There's Only One Way To Do It

You are just saying that you think that Perl is better than Java.

Well, as a Java consultant, Perl is much better than Java when talking in production. Also Perl is better in performance too, since Java speed is just crap, yes it is, why to try to conform with the turtle of Java when we know that all the other languages are faster. Let's stop to dream, and let's see the reality.

The only problem with Perl is that it doesn't have the loby that Java has. Soo, the stupid guys will think that Java is better than Perl because it has certification, etc... Soo, they pay me to coordinate the Java production of project. But with all the respect, Perl is better than Java, since I have real comparations with the 2 teams that I have here, and the Perl team is 3 times faster, with much more resources in their softwares, and with less erros. But I only still use Java, since I can't tell them to not use Java, since the client want a system in Java, and because they pay me very well.

I just think how stupid is to do a Java algorithm. Our programmers spend much more time looking in the Java docs, and finding examples at java.sun.com, than really doing the program. Soo, why any resource in Java doesn't have an intuitive way to use. A good example is to work with hashes, specially from the point of view of a Perl programmer, that use a hash just when it want, and the Java programemr does everything to avoid a hash to not use another different object interface in their algorithm.

Other funny thing in Java is the convertion of it's basic types. Soo, they have, char, byte, short, int, long, float, double and string. Soo, how I convert, let's say, string to double, and double to string. Now how I convert int to double? It just doesn't have a common way to do that! In Perl, well, we just never have this problem, since we have something very intelligent, SCALAR! just to show you how stupid is that, here are the ways to convert this types, from a convertion class that we have created:

public static double Str2Double(String i) { if ( i.indexOf(".") >= 0 ) { int p = i.indexOf(".") ; i = i.substr +ing(0,p) ;} double o ; try { o = Double.parseDouble(i) ;} catch (Exception e) { o = 0 ;} return o ; } public static String Double2Str(double i) { String o ; try { o = Double.toString(i) ;} catch (Exception e) { o = "" ;} if ( o.indexOf(".0") == (o.length()-2) ) { o = o.substring(0, (o.l +ength()-2) ) ;} return o ; } public static double Int2Double(int i) { double o ; try { o = (double)i ;} catch (Exception e) { o = 0 ;} return o ; }
Soo, here we have a big static class, with all the convertion methods, what make our life easier. Also we have implemented the Scalar type in Java, what is even better. But why we don't have this resources that make life easier by default in Java? Why we need to develope them? Is simple, because they want that!

Other way to have a Perl programmer laughing is to compare the IO system of Java. For example, how we read a file in Java? Example:

import java.io.RandomAccessFile ; ... java.io.File file = new java.io.File( "/tmp/file" ) ; RandomAccessFile stream = new RandomAccessFile(file , "rw") ; int len = 1024 ; String buffer ; try { byte[] b = new byte[len] ; int n = stream.read(b , 0 , len) ; if (n > 0) { buffer = new String(b,0,n) ; } }
With Perl is just open() and read():
open(my $io,"/tmp/file") ; read($io, my $buffer , 1024) ;
The point is not the number of lines, is the number of resources that we need to learn and use to do this in Java. In Perl we need just to know the behavior of open() and read(). In Java, well, Is soo much thing that I just don't want to start to explain!

Other think that I don't understand is the Java "compilation". Everybody says that Java is "compiled". What a crap, the .class files are just bytecode. But we PerlMonks know that Perl also have it's own bytecode, very well parsed and optimized. Soo, why is sooooooo sloooowwww, to "compile" the .class files, and than why is sooooo slooowww to load and run a .class file?!!! All us know that the .class file is just operations for the Java VM, like a assembler code, that has nothing to do with the OO structure of a Java class. Actually we can have structured code for the Java VM machine, soo why is soo slow to run?

Well, the Java folks can try to defend Java, but what I say is just the reality show man! Java sux, but they pay. ;-P

Graciliano M. P.
"Creativity is the expression of the liberty".

Replies are listed 'Best First'.
Re: Re: There's Only One Way To Do It
by hardburn (Abbot) on Apr 07, 2004 at 13:13 UTC

    here are the ways to convert this types, from a convertion class that we have created:

    What's wrong with java.lang.Double.parseDouble()?

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      The point is not "java.lang.Double.parseDouble()", is all the different ways to do that and USE that:
      Double.parseDouble(i) ; Double.toString(i) ; (double)i ;
      Soo, for each basic type in Java we nee to use a class or object of a super type to can convert one type to other. And depending of the level of the origin type to the destiny type we can't use a static method of a class, we need to use type casting.

      Note that for each one we nee to catch exceptions. Is just not a simple thing2thing() call! And type convertion shouldn't be an issue, since this a language thing, not a algorithm stuf.

      Graciliano M. P.
      "Creativity is the expression of the liberty".

Re: Re: There's Only One Way To Do It
by Anonymous Monk on Apr 07, 2004 at 14:10 UTC
    How would you write a cross-platform multi-threaded GUI application in Perl??

      As for "cross-platform", it depends on what you mean by that. Currently Perl is supported on hundreds more platforms than Java. "Write once, run anywhere" is still a myth for Java, but practical reality for Perl.

      As for multi-threaded GUI application in Perl, there are (of course) many ways to do it. One good way that comes to mind is to use POE, which integrates very nicely with Tk. Cookbook example.

      I think you'll have to be a lot more creative if you're trying to come up with examples of applications that Can't Be Done In Perl.

      jdporter
      The 6th Rule of Perl Club is -- There is no Rule #6.

        Not that I'm a huge fan of Java as a language, but...

        Currently Perl is supported on hundreds more platforms than Java. "Write once, run anywhere" is still a myth for Java, but practical reality for Perl.

        This, of course, depends on what platforms you're interested in running your applications on. While Java runs on fewer platforms than Perl (although I don't think it would be hundreds fewer) it runs on several useful platforms that Perl doesn't run on at all (the opposite is of course also true).

        I think you'll have to be a lot more creative if you're trying to come up with examples of applications that Can't Be Done In Perl.

        How about anything running on the 100 million Java/Symbian devices that Nokia are going to be shipping this year :-)

      How about wxPerl?

      It's more portable that the Java+Swing that you say that is soo cross-platform. Note that wxWindows will work in much more platform than swing, and Perl, well, I just don't need to say anything.

      And I can't forgot to say that wxWindows is much more porwerfull and fast than swing, since wxWindows is based in the main GUI of each OS, soo, your app will looks like Windows on Windows and like Mac OS X on Mac OS X.

      Graciliano M. P.
      "Creativity is the expression of the liberty".

      I certainly won't use Java. Any GUI beyond a bouncing 2D ball in java is just to slow and klunky to use!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://343197]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-29 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found