Reputation: 679
I am looking for Perl implementation in Java. Something like Jython is for Python. I found PLJava but it needs both JVM and Perl compiler installed. I need something which does not need a Perl compiler.
I need to run some Perl code in a Java class.
UPDATES:
Upvotes: 11
Views: 5241
Reputation: 409
Update: There is another options that could be viable: Jerl. Jerl translates a micro-Perl interpreter into Java bycode using NestedVM. In this sense Jerl is almost a Java implementation of Perl. I haven't tested it though and it is reasonable to expect a loss in performances . Nonetheless it's a solution worth of investigation. Jerl is hosted here: https://code.google.com/p/jerl/.
Sadly not, at least not a complete and usable one. Perl is a difficult language to port to other VMs mainly because of its highly dynamic nature and for historical reasons related to how the language has been developed over the years; theoretical issues about perl parsability are, in my humble opinion, of secondary importance. Perl does not have an a formal specification nor an official grammar: Perl implementation is Perl's own formal specification. This means that to write an alternative implementation of Perl one has to know intimately the internals of the current one and this is obviously a big barrier to the development of such a project. Here lies the real difficulty in porting Perl to other VMs. Additionaly, the dynamic nature of Perl poses other technical problems related to an efficient implementation on the Java virtual machine that is engineered to support statically typed languages. There have been some efforts like this one for example: http://www.ebb.org/perljvm/. A newer one is cited here: http://use.perl.org/~Ovid/journal/38837. Both were abandoned at one point or another not because of infeasability but only because the effort required was too big for a research/hobby project. A new interesting alternative that is proceeding steadly is language-P by Mattia Barbon: http://search.cpan.org/dist/Language-P/. It is an implementation of Perl on the NET clr. The implementation is still incomplete but I know that the man behind the project is a very persistent one and that the project has been going forward slowly but steadily. Maybe Perl on the CLR will come first. :D
Upvotes: 6
Reputation: 2079
You can use par including modules (or even as an executable) if you don't have perl installed on the target platform: http://metacpan.org/pod/PAR
Upvotes: 1
Reputation: 1847
Rakudo is a JVM implementation of Perl 6 (which is quite different from standard Perl). Now there is Jerl (which runs in JVM but is compiled based on microperl). Both have their limitations but are solid contenders for most uses.
Upvotes: 1
Reputation: 134601
Look at Sleep
is a multi-paradigm scripting language for the Java Platform
easy to learn with Perl and Objective-C inspired syntax
executes scripts fast with a small package size (~250KB)
excels at data manipulation, component integration, and distributed communication
seamlessly uses Java objects and 3rd party libraries
Upvotes: 1
Reputation: 204718
Jython isn't fully compatible with CPython (or whatever you would rather call the original C++ Python interpreter), but wherever either differs from the language spec is a bug. Unfortunately, Perl 5 is much more complex and lacks any formal language specifications at all -- the language effectively being defined as "what does the perl
executable do" -- so there exists no other implementation of the Perl 5 language aside from the Perl 5 interpreter. Unfortunate, but that's history. Perl 6 does have a language spec and multiple (incomplete) implementations, but that's not likely to be useful to you.
PLJava was an attempt to do exactly what you want, call Perl from Java. It does so via JNI (stuffing native code into Java) linking to libperl
. However, it's not been updated since 2004 and I don't know how well it works.
I hadn't seen Inline::Java::PerlInterpreter before -- unfortunately it doesn't seem to work with my system Perl.
Upvotes: 6
Reputation: 614
It sounds to me like the problem you are having is that you do not have a Perl compiler/interpreter available, yet you need to execute some Perl code. Unfortunately, I don't think that there exists anything like Jython for Perl. The only projects that I know of that can do what you are asking is PLJava and JPL. Unfortunately, it looks like both projects are abandoned.
It would be a cool project though, as I believe there is a need for something like this.
Upvotes: 1
Reputation: 165242
If you are not going to use a Perl compiler, exactly what are you looking for?
What do you mean by a Perl implementation for Java? If you want to embed Perl in your Java programs, you are going to need a Perl compiler.
Upvotes: 1