In Jython, Each Line of Code Tends to Do More Than It Might in Another Language

In Jython, Each Line of Code Tends to Do More Than It Might in Another Language

Welcome to GKTCS IT Training .Consultancy . Software Development. Staffing 1 Surendra Panpaliya Director, GKTCS Innovations Pvt. Ltd, Pune. 13.5 + Years of Experience ( MCA, PGDCS, BSc. [Electronics] , CCNA) Director , GKTCS Innovations Pvt. Ltd. Pune [ Nov 2009 – Till date ] IT Manager and Consultant at Rolta India Ltd, Mumbai [ April 2007 – Oct 2009 ] Associate Professor at Sinhgad Institute , Pune [Jan 2002 – April 2007] Instructor , ITM Bangalore [ May 2000 – Jan 2002 ] Project Trainee, DSYS Software Group, Bangalore [ Jan 1999 to April 2000] Skills Python, Jython, Django, Android , PHP, LAMP Data Communication & Networking, CCNA UNIX /Linux Shell Scripting, System Programming CA Siteminder, Autosys, SSO, Service Desk, Service Delivery Author of 4 Books National Paper Presentation Awards at BARC Mumbai 2 ICE Breaking • Form a group of 2 or 3. • Listen to your colleague. • Appreciate everyone. • Know everyone skills and appreciate the same. • Learn in team. • Cooperate to each other • Please switch off / Silent your Mobile phone. 3 Jython Programming Surendra R. Panpaliya M:9975072320 [email protected] www.gktcs.com 2 November 2012 4 Agenda Day Module Topics Day 1 Module 1 Introduction to Jython Module 2 Simple Program Module 3 Basic Language Construct Module 4 Control Structure Module 5 Functions Module 6 Data Structure 2 November 2012 5 Module 1 Introduction to Jython 2 November 2012 6 Introduction to Jython • Botanists know that if you cross-pollinate two different strains of plants, you create a hybrid; a new plant that exhibits the strengths of both its parents. • Jython is a programming hybrid. It is an implementation of the Python scripting language written in 100% pure Java that runs under any compliant Java Virtual Machine (JVM). • 2 November 2012 7 Introduction to Jython • Using Jython, you can write Python programs that interact with any Java code. The Jython interpreter supports a number of shortcuts, which make using Java libraries as easy as using your own Python code. • Jython, then, combines a scripting language of unparalleled ease of development with an operating environment for which many powerful tools have been written. 2 November 2012 8 Introduction to Jython • The combination can be immensely valuable for programmers, enabling you to cut development time significantly while still retaining the ability to use existing Java tools, such as applets and servlets. • Just as Python was originally conceived as glue to bind together other programs, Jython acts as glue to help you get the most out of Java- based tools. 2 November 2012 9 Introduction to Jython • In particular, Jython excels at simplifying the use of complex Java programming libraries and APIs, such as the Swing graphical interface toolkit or the JDBC database connectivity API. 2 November 2012 10 Introduction to Jython • What is Jython? • Who Uses Jython? • Features of Jython • Why Jython 2 November 2012 11 What is Jython? • Jython is an interpreted, interactive, object oriented language. • It incorporates modules, exceptions, high level data types, dynamic typing and classes. • It has interfaces to system calls and libraries. • It is portable. 2 November 2012 12 What is Jython? • Jython is an implementation of Python written in the Java language and integrated with the Java platform. • Python is a scripting language often used in UNIX-based systems, including Linux. • Python was invented by Guido van Rossum and introduced to the developer community in 1991. 13 What is a scripting language? • Unlike the Java programming language, Jython is a scripting language. A scripting language is generally defined as follows: • Very easy to learn and code • Expressive and concise, yet powerful • Has minimal required structure to create a running "program" • Supports interactive (command-at-a-time) execution • Does not require a compile step • Supports reflective programming • Supports functional programming • Supports dynamic execution of source (that is, an eval function) • Runs external programs 14 What is a scripting language? • Scripting languages value programmer efficiency over machine efficiency and performance. • Jython is easy to learn and efficient to code. • Jython can also be described as an agile language. • Agile languages are generally thought of as being capable of performing a wide variety of tasks and useful for many different types of problems, easy-to- use and yet powerful and expressive. • They are also ideal rapid prototyping languages. 15 Brief History of Jython • Jython was initially created in late 1997 to replace C with Java for performance-intensive code accessed by Python programs. • The Python Software Foundation awarded a grant in January 2005. • Over this history, Jython had been developed successively by Jim Hugunin[1],Barry Warsaw, Samuele Pedroni, Brian Zimmer, and Frank Wierzbicki. • Jython 2.5 was released in June 2009.[ 16 Status and roadmap • The current release is Jython 2.5.3, available since August 13, 2012. • Jython 2.5.2 implements the same set of language features as CPython 2.5 • As of 2.5.0, Jython is able to run popular Python frameworks such as Django, Pylons, or SQLAlchemy. • March 05, 2012, it was announced that funding had been procured to produce a 2.7 version of Jython. 17 License terms • From version 2.2 on, Jython is released under the Python Software Foundation License (v2). • Older versions are covered by the Jython 2.0, 2.1 license and theJPython 1.1.x Software License. • The first two are permissive free software licenses. • The command line interpreter is available under the Apache Software License. 18 Usage • Jython is one of two scripting languages (with Jacl) used in WebSphere Application Server. • It is used in IBM Rational development tools, where Jython projects can be created using wizards. • It is used as the main programming language for the JHepWork data analysis framework. 19 Usability Features • Very clear syntax. • Obvious way to do most things. • Huge amount of free code and libraries. • Interactive. • Only innovative where innovation is really necessary. – Better to steal a good idea than invent a bad one! 20 The Benefits of Jython • To improve your productivity for a great number of project types that are currently performed in Java. • We'll also suggest some reasons why Jython might be a good addition to your toolkit even if you are already a CPython programmer. 21 The Benefits of Jython • For Java Programmers • Why you need another language to run under the JVM. Doesn't Java work just fine? • Java is great. But, by using Jython instead of Java, you'll probably find that the number of lines of code in your program has dropped by as much as 50%. • Many empirical studies of programming suggest that shorter programs have fewer bugs. 22 The Benefits of Jython • In addition, programmer productivity tends to be about the same for any number of lines of code even if, as in Jython, each line of code tends to do more than it might in another language. • In other words, an expert Jython programmer will likely produce programs faster, and with fewer bugs, than an expert Java programmer. 23 The Benefits of Jython • We don't mean to attack Java as a programming language. Java, like every programming language, is a tool, and it has its uses. • However, it's hard to use Java for any length of time and not realize that it is an exceptionally verbose and often inflexible language. After you've written lines of code such as the following, which includes a typecast that is there only to keep the compiler happy: • MyClass instance = (MyClass)list.get(2); • it becomes easier to see the benefits of just writing: • instance = list[2] 24 The Benefits of Jython • The difference between the Java and Python code emphasizes one of the main sources of the productivity advantage of Jython--dynamic typing. • In Python, you do not need to declare variables for use, nor do you need to tell the interpreter what the expected data type of a variable is. • It is important to note that despite being dynamically typed, Python also has strong typing. • This means that a line of code such as "1" + 1 is an error in Python (unlike many other scripting languages, which would quietly allow this). 25 The Benefits of Jython • In addition to dynamic typing, the Python scripting language used in Jython offers several other features that will improve your programming productivity: • Clean, easy-to-read syntax • Interactive interpreter • Module-based organization • High-level, built-in types • Simple object-oriented semantics • Operator overloading • Dynamic dispatch and polymorphism • No compile phase 26 The Benefits of Jython • First-class functions and classes • In Java: • import java.lang.reflect.*; • Class aClass = anInstance.getClass( ); • Method someFunc = aClass.getMethod("method", new Class[] {Integer, String}); • someFunc.invoke(anInstance, new Object[] {new Integer(3), "Fred"}); • In Python: • someFunc = anInstance.method • someFunc(3, "Fred") • Extensive included library 27 For Python Programmers • There seem to be at least three important gains. • Extended reach • The most notable examples of this are web-based--namely, the creation of applets that will be accepted by mainstream browsers, and the creation of servlets that can be run by Java servlet or J2EE servers. • Ease of distribution • Jython makes it easy to distribute your program as a cross- platform binary in .jar format. Although there are binary tools for CPython on different platforms, there is no similar cross- platform tool for CPython. 28 For Python Programmers • Tools and libraries • Although the Python standard library and available third-party tools are varied and wonderful, Java has benefited from a much larger pool of available tools, particularly enterprise- level tools. The Swing GUI toolkit is more complete and more cross-platform than any GUI toolkit available for CPython, and is arguably easier to use. Database tools are much more widely available and standardized in the Java world.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    176 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us