In addition to the general challenges that the JVM presents inherent in its nature, there are also some challenges that are specific to porting Perl to the JVM. Perl is a unique language; Perl has both cultural and technical aspects that make it different from other programming languages. These issues create some specific challenges in porting Perl to the JVM.
First, parsing Perl is a particularly difficult problem. The Perl language is designed with lots of syntactic sugar and special cases. There are reasonable and laudable design goals (which are beyond the scope of this thesis) for this design. Regardless, though, this design makes Perl particularly difficult to parse. Currently, the only known full parser for Perl is the one that ships with the perl distribution, and it is infamously very complex.
There is also no formal specification for Perl. While this will likely change for the next major version of Perl, the current mantra of the Perl community is ``the implementation is the specification''--meaning that whatever perl does defines what the language Perl itself should always do. Implementing a new compiler, given that no specification exists, is particularly difficult.
Finally, Perl's native data types are particularly uncommon. While on the surface, the native data types (array, hash, and scalar) seem common, there are some frequently used special cases that introduce complexity for a compiler writer. For example, Perl's tie feature allows the programmer to arbitrarily make any variable in the language a full-fledged object, where arbitrary code is executed for any variable access. Figure 1.3 shows a simple example of a tied Perl scalar.
In this example, the scalar variable, $x, is tied to the package AlwaysOne. The example shows how the semantics of variable assignment and variable use are changed utterly by tie. The FETCH and STORE methods replace assignment and use of $x.
As can be seen through the example of tie, Perl's data types, while seemingly straight-forward at first glance, are actually quite advanced and complex. A JVM port of Perl must handle these special cases. Care must be taken so that the underlying data structures used to implement Perl's data types can support these advanced features.
Copyright © 2000, 2001 Bradley M. Kuhn.
Verbatim copying and distribution of this entire thesis is permitted in any medium, provided this notice is preserved.