May 2017 Archives

Perl5 to Java compiler - first release

This is the first release of the Perl5 to Java compiler.

https://github.com/fglock/Perlito/releases

In the github page there is a link to the "jar" file and the lib directories for JVM-specific Perl modules.

The "perlito5.jar" file provides a perl-like command line:

java -jar perlito5.jar -I src5/lib -e ' print "hello, World!\n" '

Note that you don't need to compile a Java file. Perlito5 now compiles the Perl code to JVM bytecode in memory and executes it. Also eval-string is executed as JVM bytecode - there is no interpreter.

Perlito5 is an implementation of the Perl5 language. It is work-in-progress. It provides an impressive coverage of Perl features, but it will not run most existing Perl programs due to platform differences.

More details in the GitHub Perlito5-Java page: https://github.com/fglock/Perlito/blob/master/README-perlito5-Java.md

Perl5 to Java compiler - week 100 - bootstrapping

It's been a 100 weeks since the Perl5 to Java compiler started.

The compiler is now "good enough" to translate itself to Java.

# grab a copy of the project
$ git clone git@github.com:fglock/Perlito.git ; cd Perlito

$ make clean

# create the "perlito5.java" file
$ perl perlito5.pl --bootstrapping -Isrc5/lib -Cjava src5/util/perlito5.pl > perlito5.java

# compile to ".class"
$ time javac -J-Xms2000m -J-Xmx2000m -J-Xss2000m -source 7 perlito5.java
[ scary warnings ]

# create the perlito5.jar file
$ jar -cfe perlito5.jar Main *.class

# quick check
$ java -jar perlito5.jar -v
This is Perlito5 9.021, an implementation of the Perl language.

# run a test
$ java -jar perlito5.jar --bootstrapping -Isrc5/lib -Cjava t5/unit/array.t > x.java ; javac -source 7 x.java ; java Main
[ scary warnings ]
1..35
ok 1 - create array
ok 2 - set element
...

# test the bootstrapping
$ java -jar perlito5.jar --bootstrapping -Isrc5/lib -Cjava src5/util/perlito5.pl > x.java
$ diff x.java perlito5.java
[ no differences ]

The "--bootstrapping" flag tells the compiler that eval-string is not available. Eval-string is not yet implemented.

About Flávio S. Glock

user-pic I blog about Perl.