CloneArmyCommander has asked for the wisdom of the Perl Monks concerning the following question:

I have been working on a forum for my school and the prototype is written in Perl, but the guy who has root access to the school server has decided that Perl is bad and is having me rewrite my forum in Java. Does anyone know of a program that is similar to perl2exe that will translate my code into Java. It would make things easier, especially since I don't know Java. I appreciate your help :).

Replies are listed 'Best First'.
Re: Perl to Java
by Joost (Canon) on Aug 10, 2004 at 18:48 UTC
    AFAIK there's no such thing.

    Anyway, assuming "the guy who has root" on the machine is actually in charge of what gets installed, and he didn't just make up this "no perl" rule, you should have asked what the technical requirements for new software were before you started coding. In fact, you probably should have looked for existing software too.

Re: Perl to Java
by Aristotle (Chancellor) on Aug 10, 2004 at 18:28 UTC

    You ought to tell him he has decided that hammers are bad and screwdrivers should be used instead.

    For the record, I know of no such conversion tool and don't believe one can even feasibly be written.

    Makeshifts last the longest.

Re: Perl to Java
by Plankton (Vicar) on Aug 10, 2004 at 18:16 UTC
    You might want to try looking on Java Junkies. It is a java site run by some Perl monks.

    Plankton: 1% Evil, 99% Hot Gas.
      Thanks :). I've registered and feel at home with its look and feel of Perl Monks :). I didn't know that it existed (I stumbled across Perl Monks by accident :)).
Re: Perl to Java
by johnnywang (Priest) on Aug 10, 2004 at 19:47 UTC
    One way to cheat is to embed perl inside a simple java wraper using something like PLJava, and claim it to be a java program. (Disclaimer: I've never used PLJava.)
Re: Perl to Java
by revdiablo (Prior) on Aug 10, 2004 at 19:36 UTC
    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.

      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

Re: Perl to Java
by jacques (Priest) on Aug 10, 2004 at 18:18 UTC
    But I thought you were the Army Commander?

    I don't know of any program that does this. But why would you write your own forum when prewritten forums are readily available in Perl and Java?

      I would reccoment vbulletin or phpbb honestly for forum stuff.
      It was one of those things where I was asked to create it, and I knew how to accomplish the task quickly with Perl, and I didn't want to completely waste the code, no matter how short of a time it took to write :).