Introduction to Jython - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Introduction to Jython

Description:

May prompt the audience to give it a try if not already done it. Topics covered. What is Jython ? ... Java try{ File file = new File('foo'); f.setReadOnly ... – PowerPoint PPT presentation

Number of Views:558
Avg rating:3.0/5.0
Slides: 17
Provided by: deepa9
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Jython


1
Introduction to Jython
  • Deepak Ram
  • dram_at_india.hp.com

2
Scope
  • Not a tutorial
  • Gives high level picture
  • Not exhaustive
  • May prompt the audience to give it a try if not
    already done it.

3
Topics covered
  • What is Jython ?
  • Features
  • Code Examples
  • Pros and Cons
  • Where it can be used?
  • Conclusion

4
What is Jython ?
  • 100 pure Java Implementation of Python.
  • Dynamic compilation to Java byte codes
  • Seamless and smooth integration with java

5
Features
  • Interactive interpreter
  • gtgtgt from java.util import Random
  • gtgtgt r Random()
  • gtgtgt r.nextInt()
  • -790940041
  • Dynamic Variable Creation
  • Good High Level Built-In Data Structure
  • listOfString One,Two,Three
  • print listOfString0

6
Features (Contd.)
  • Dynamic Object Oriented Typing
  • Complete access to all java libraries
  • Embedded Scripting
  • Extend Java classes in Jython script
  • Optional static compilation
  • - allows creation of applets, servlets

7
Features (Contd.)
  • Bean Property Introspection
  • button.preferredSize (300, 50)
  • First class functions
  • Event Listener Introspection
  • def exit(event)
  • java.lang.System.exit(0)
  • button awt.Button("Close Me!",
    actionPerformedexit)

8
Examples (List Manipulation)
  • Jythongt a 1,2,5,hello Mixed List
  • Javagt ArrayList a new ArrayList()
  • a.add(new Integer(1))
  • a.add(new Integer(2))
  • a.add(new Integer(5))
  • a.add(hello)

9
Examples (File Handling)
  • Jython gt fopen(foo,r) line f.readLine()
  • Javagt try
  • File file new File(foo)
    f.setReadOnly()
  • BufferedInputSteam f null
  • f new BufferedInputStream(new
    FileInputSteam(file))
  • String data f.readLine()
  • catch (IOException e)

10
Examples (GUI)
  • Jythongtfrom javax.swing import
  • win Jframe(My Frame)
  • win.contentPane.add(JButton(Jython))
  • win.setSize(300,300)
  • win.setVisible(1)

11
Pros
  • Dynamic typing/High Level Data Structure
  • - Fewer Lines of code (2 10 times fewer
    compared to Java)
  • - Higher productivity.
  • - Fewer bugs.
  • - Better maintainability
  • Can make use of existing repository of java and
    Python code.

12
Pros (Contd.)
  • Platform independent
  • Interactive Experimentation
  • Simple and easy to learn syntax
  • Java skill not necessary for writing client
    programs for Java code.
  • No compilation necessary

13
Cons
  • C based extensions in Python not available
  • Lower performance compared to compiled Language.
  • No extensive documentation
  • Lack of awareness among Java Community

14
Where it can be used ?
  • Interactive Experimentation
  • Rapid Application Development
  • Prototyping.
  • Training Programmers on use of java libraries.
  • Client Programs and Test Drivers.
  • Automated Testing
  • - PyUnit/JUnit

15
Resources
  • http//www.jython.org
  • http//www.python.org
  • http//gnosis.cx/publish/programming/charming_pyth
    on_10.txt
  • Jython Essentials (Samuele Pedroni and Noel
    Rappin, O'Reilly, March 2002)

16
Questions ?
Write a Comment
User Comments (0)
About PowerShow.com