Java from Perl; Perl from Java

From JmPm

(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
== Perl - Java  Similarities==
== Perl - Java  Similarities==
-
 
+
* Interpreted languages
-
Interpreted languages
+
* Platform independent (write once run anywhere)
-
 
+
* Similar syntax (procedural languages)
-
Platform independent ( write once run anywhere )
+
* Garbage collector
-
 
+
* Modules and packages structure
-
Similar syntax ( procedural languages )
+
-
 
+
-
Garbage collector
+
-
 
+
-
Modules and packages structure
+
-
 
+
-
 
+
== Differences ==
== Differences ==
-
 
+
* Java 100% object oriented, in Perl OO is optional (function overloading does not exist)
-
Java 100% object oriented , in Perl OO is optional ( function overloading does not exist )
+
* Java requires compilation, Perl doesn’t
-
 
+
* Java does not allow multiple inheritance, Perl does. (Object == UNIVERSAL)
-
Java requires compilation , Perl doesn’t
+
* Java has strong typing ( requires variable declaration ), Perl has not – variable gets it type after first assignment.
-
 
+
* autoload mechanism  
-
Java does not allow multiple inheritance , Perl does. ( Object == UNIVERSAL )
+
* Do we need strong typing? (strong testing ?)
-
 
+
* Java is rigid, Perl has many ways to say same thing
-
Java has strong typing ( requires variable declaration ), Perl has not – variable gets it type after first assignment.
+
* Perl has many shell like features (variable interpolation, file test operators). Java has none.
-
 
+
* In Java execution starts in main(), Perl has no main, (__DATA__ feature)
-
autoload mechanism  
+
* Perl is much FASTER in development and execution
-
 
+
-
Do we need strong typing ? ( strong testing ? )
+
-
 
+
-
Java is rigid , Perl has many ways to say same thing
+
-
 
+
-
Perl has many shell like features ( variable interpolation , file test operators ). Java has none.
+
-
 
+
-
In Java execution starts in main(), Perl has no main , ( __DATA__ feature )
+
-
 
+
-
Perl is much FASTER in development and execution
+
-
 
+
== Why do we need it ? ==
== Why do we need it ? ==
-
 
+
* Legacy components access
-
Legacy components access
+
* Code transition from some language to perl
-
 
+
* Speed (C , not Java)
-
Code transition from some language to perl
+
* Component exist in other language and we want to use it in Perl
-
 
+
-
Speed ( C , not Java )
+
-
 
+
-
Component exist in other language and we want to use it in Perl
+
-
 
+
== Inline ==
== Inline ==
-
 
+
* Inline, Inline::Java
-
Inline , Inline::Java
+
* Easy installation
-
 
+
* Short learning curve
-
Easy installation
+
* Hides all details (compilation, glue files)
-
 
+
* Inline has extension to many other languages – C , C++ , Python ...
-
Short learning curve
+
* Older tools XS, SWIG.
-
 
+
• Manual steps, long learning curve, only perl to XXX direction
-
Hides all details ( compilation , glue files )
+
-
 
+
-
Inline has extension to many other languages – C , C++ , Python
+
-
 
+
-
Older tools XS , SWIG.
+
-
 
+
-
• Manual steps, long learning curve , only perl to XXX direction
+
-
 
+
== Perl2Java ==
== Perl2Java ==
-
 
+
* Methods invocation ( regular and static )
-
Methods invocation ( regular and static )
+
* Member variables access
-
 
+
* Study
-
Member variables access
+
* Script or package code layout
-
 
+
-
Study
+
-
 
+
-
Script or package code layout
+
-
 
+
== inline::java steps ==
== inline::java steps ==
-
 
+
* Creates java source file from the embedded code ( Hi.java )
-
Creates java source file from the embedded code ( Hi.java )
+
* Compiles java class ( Hi.java -> Hi.class )
-
 
+
* Extracts the methods signatures to Hi.jdat file
-
Compiles java class ( Hi.java -> Hi.class )
+
-
 
+
-
Extracts the methods signatures to Hi.jdat file
+
-
 
+
-
 
+
== Java2Perl ==
== Java2Perl ==
-
 
+
* Implemented by Inline::Java::PerlInterpreter
-
Implemented by Inline::Java::PerlInterpreter
+
* Alternative implementation based on
-
 
+
** JNI  defines a standard naming and calling convention so the Java virtual machine can locate and invoke native methods  
-
Alternative implementation based on
+
** perl from C invocation , modified examples code from O’Reilly Advanced Perl Programming
-
 
+
* Two basic problems :
-
–     JNI  defines a standard naming and calling convention so the Java virtual machine can locate and invoke native methods  
+
** Functions in perl can be called with variable number of parameters and output variable number of values
-
 
+
** Parameters can have different types
-
–     perl from C invocation , modified examples code from O’Reilly Advanced Perl Programming
+
-
 
+
-
Two basic problems :
+
-
 
+
-
–   Functions in perl can be called with variable number of parameters and output variable number of values
+
-
–   Parameters can have different types
+

Current revision as of 07:25, 16 July 2007

Contents

Perl - Java Similarities

  • Interpreted languages
  • Platform independent (write once run anywhere)
  • Similar syntax (procedural languages)
  • Garbage collector
  • Modules and packages structure

Differences

  • Java 100% object oriented, in Perl OO is optional (function overloading does not exist)
  • Java requires compilation, Perl doesn’t
  • Java does not allow multiple inheritance, Perl does. (Object == UNIVERSAL)
  • Java has strong typing ( requires variable declaration ), Perl has not – variable gets it type after first assignment.
  • autoload mechanism
  • Do we need strong typing? (strong testing ?)
  • Java is rigid, Perl has many ways to say same thing
  • Perl has many shell like features (variable interpolation, file test operators). Java has none.
  • In Java execution starts in main(), Perl has no main, (__DATA__ feature)
  • Perl is much FASTER in development and execution

Why do we need it ?

  • Legacy components access
  • Code transition from some language to perl
  • Speed (C , not Java)
  • Component exist in other language and we want to use it in Perl

Inline

  • Inline, Inline::Java
  • Easy installation
  • Short learning curve
  • Hides all details (compilation, glue files)
  • Inline has extension to many other languages – C , C++ , Python ...
  • Older tools XS, SWIG.

• Manual steps, long learning curve, only perl to XXX direction

Perl2Java

  • Methods invocation ( regular and static )
  • Member variables access
  • Study
  • Script or package code layout

inline::java steps

  • Creates java source file from the embedded code ( Hi.java )
  • Compiles java class ( Hi.java -> Hi.class )
  • Extracts the methods signatures to Hi.jdat file

Java2Perl

  • Implemented by Inline::Java::PerlInterpreter
  • Alternative implementation based on
    • JNI defines a standard naming and calling convention so the Java virtual machine can locate and invoke native methods
    • perl from C invocation , modified examples code from O’Reilly Advanced Perl Programming
  • Two basic problems :
    • Functions in perl can be called with variable number of parameters and output variable number of values
    • Parameters can have different types
Personal tools