Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Welcome to the Monastery
 
PerlMonks  

Re: Perl to Java

by revdiablo (Prior)
on Aug 10, 2004 at 15:36 UTC ( [id://381724]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Perl to Java

Does anyone know of a program that is similar to perl2exe that will translate my code into Java.

Code translators are generally pretty dodgy to begin with, but trying to convert between two languages that are as different as Java and Perl is certainly fraught with problems. There are many things about Perl and Java that would foul up a mechanical translation: the type systems, the object systems, the amount of stricture, or even the subroutine argument passing semantics. These are all quite different, and simulating Perl's flexibility with Java would be quite a feat.

Even if those problems were worked out, the resulting Java could would almost undoubtedly be horrible. There are things easily accomplished in 1 line of Perl code that would take 10 lines of Java. And I think this type of mis-match is the rule, not the exception. Basically, the languages have irreconcilable differences. :-)

PS: This is not to say I don't like Java. I know many Monks -- and many Perl users in general -- will disagree with me here, but I like the silly language from Sun. Sure, the standard API may be sprawling, and the language may seem wordy and verbose at times, but I usually enjoy writing Java code.

Replies are listed 'Best First'.
Re^2: Perl to Java
by hv (Prior) on Aug 11, 2004 at 07:18 UTC

    Further, the languages are so different that it isn't just "idiomatic code" that changes, but also "idiomatic design" - an appropriate design for a Perl implementation probably won't be an appropriate design for a Java implementation.

    If you need Java code to perform similar functionality, put your Perl code to one side and start again. The knowledge gained when writing the Perl version will help you in some respects; the prejudices gained while writing the Perl version will hinder you in other respects.

    Learning to spot these helps and hindrances, and to grasp or avoid them - to approach the same problem from a genuinely fresh standpoint without throwing away everything you know - is a skill worth acquiring for any programmer.

    Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://381724]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.