Wait ... what?!? What does Java have to do with DBI or Perl 6? A while back, Tim Bunce posted that the JDBC made a good model for the driver interface for DBI 2, so we might as well just use it. So, that's what's happening. We're starting with the java code for JDBC and writing software to automatically convert these java files to Perl 6. And then eventually, something like DBI wil be built on top of it all. But java2perl6 is the start.
Anyway, the java2perl6 README says
See the POD in java2perl6 (in the bin directory of the distribution) for information on how to use this module.Great. I know how to do this, I'll just type
perldoc bin/java2perl6and see what it takes to get started. Never mind that I only have passing familiarity with Java, I'll figure that out later. I know Perl 6 fairly well.
Oops! Perldoc had some problems:
Hey! The above document had some coding errors, which are explained below:
Around line 104:
’=end pod EOS’ is invalid. (Stack: =begin pod)
As it turns out, java2perl6 generates some POD as part of its output.
This POD is in a here-document which apparently confuses perldoc
since the directives that are part of the output are at the start of
lines. Aha! My first contribution to the java2perl6 project: making
java2perl6 accessible via perldoc.
Okay ... now what?
The documentation in java2perl6 gives me a good overview of the command line arguments, what the program is supposed to do, and some nice examples. So, after installing the dependencies, I do the usual
perl Makefile.PL && make && make testdance and everything looks okay. All tests successful. Now to attempt a conversion or two.
There's a directory called
testjavaswhich looks to contain some java code I can try this out on, so I do:
perl -Mblib blib/script/java2perl6 -j '-classpath testjavas' ClassTest
Since I haven't installed java2perl6, I invoke it from within the build directory and pass the
testjavasdirectory as an argument to javap. The name of the file that I'm converting to Perl 6 is ClassTest.java. The result of running the above command is that I now have a ClassTest.pm file with some Perl 6 code in it that hopefully mimics the class definition specified in ClassTest.java.
Looking at ClassTest.pm, it seems that java2perl6 doesn't generate the various data members defined in the .java file. That seems like something I could try to implement. But, as usual, I have far too little time to continue pursuing this and I'm feeling sleepy, so perhaps updating the generator is tomorrow night's task.
On a lark, I reran the above command with the
--checkoption to see what happened and it failed specatularly because it couldn't execute a perl6 binary in my path. That seems like something that's under-documented. Also, it would probably be nice to specify a particular location for the perl6 binary rather than relying on the
There seems to be a goodly amount of low-hanging fruit for participation for when I'm not so sleepy. Awesome. For now, I'm off to bed.