Updates
Latest Tweet
What's New?
Check out for latest innovation, a computer based training video collection
Like this Page
Jython for Java Programmers Review by calvinnme
Great book on Jython if you already know Java
This book is designed for those who know Java or are learning Java. The Java-specific meaning of terms such as classpath, garbage collection, and interface appear without explanation, but no more than rudimentary Java knowledge is required. Specifically, Java developers desiring accelerated development, embedded interpreters, and increased flexibility will most appreciate this book. Although Jython is a complete programming language, it is unique in its ability to complement Java development rather than appear as an alternative to Java.
Chapter 1, "Jython Syntax, Statements, and Comments," introduces syntax and statements. Python's syntax is an essential part of what constitutes the coined word pythonic, an important descriptor of those details that make Python and Jython code clear, simple, and distinct. Python's use of indentation to delimit code blocks and newlines to delimit statements is new to most programmers, and Chapter 1 details the rules that apply to indentation, newlines, and statements. Additionally, Chapter 1 introduces the interactive interpreter, a Jython mode that immediately evaluates statements as you enter them. This chapter applies to Python in general with no references to material unique to Jython.
Chapter 2, "Operators, Types, and Built-In Functions," covers Jython's data object, operators, and built-in functions. Data objects, or types, are especially interesting because of Jython's ability to use both Python and Java objects. The Python language specification defines Python's, and therefore Jython's types, but types are where Jython-specific details emerge. One such detail is the conversion between Jython and Java types. Chapter 2 also defines Jython's built-in functions, which are those functions that are available without any import statements and that account for a sizable portion of Jython's functionality.
Jython's errors, exceptions, and warnings appear in Chapter 3, "Errors and Exceptions." Chapter 3 contains the definitions of Jython's built-in exceptions as well as a detailed look at the try/except and try/finally statements used to handle exceptions. Working with exceptions is of course important to Jython, but it is also an important step to working with Java classes and the exceptions they may raise.
Java does not have functions, but they are an important part of Jython. Chapter 4, "User-Defined Functions and Variable Scoping," shows how to define and use Jython functions and how to use Jython's functional programming tools. Functions are callable objects not defined within a class, but functional programming has a less succinct definition. Functional programming revolves around finding the results of an expression. Jython supplies all the tools required to learn and use functional programming, and these tools appear in Chapter 2.
Jython has modules, another unit that Java does not have, and Chapter 5, "Modules and Packages," describes Jython's modules. Jython also has packages, as does Java, but Jython packages differ from the Java counterpart as Chapter 5 explains. With Jython packages, modules, and classes as well as Java packages and classes, the details of the import statement quickly become important. Chapter 5 clarifies the import statement along with modules and packages.
Chapter 6, "Classes, Instances, and Inheritance," introduces the definition and use of Jython classes. This includes the subclassing of Java classes, the use of Java interfaces and Java abstract classes, and the implications of Java's access modifiers such as public, private, and protected. Jython classes do differ from Java classes, however, and Chapter 6 clarifies these differences.
Chapter 7, "Advanced Classes," extends the information on Jython classes to include Jython's special class attributes. Special attributes in Jython are those that follow a special naming convention and provide specific functionality. These special attributes let you customize a class's behavior and makes creating advanced classes relatively easy.
Chapter 8, "Compiling Jython with jythonc jythonc," details Jython's complicated jythonc tool. jythonc compiles Jython code to Java byte-code. jythonc lets you use classes written in Jython within Java frameworks, and even lets you create class files that you can import and use from within Java.
Chapter 9, "Embedding and Extending Jython in Java," describes how to embed a Jython interpreter. Compiling Jython to Java byte-code is extremely useful, but embedding a Jython interpreter within Java applications has many advantages. Embedding gives you total control over Jython's system state and allows you to use all of Jython's features and modules within a Java application. The amazing part is how simple it is to embed a Jython interpreter. A basic embedded interpreter requires only two lines of Java code, and adding additional configuration to an embedded interpreter is equally easy. An embedded interpreter allows you to write Jython modules to extend or implement features of Java applications without having to compile modules with jythonc. It is my impression that embedding Jython is the foremost advantage of Jython. It allows multi-level language development, leverages all that is good in Java and Python within a single application, and allows rapid development and extensibility. There is already a number of projects that embed Jython, and the trend to do so will likely continue.
Chapter 10, "GUI Development," describes how to develop graphical applications with Jython. The focus is on Java's Abstract Windowing Toolkit (AWT) and Swing application programmer's interface. Jython allows rapid development of graphical applications because of its addition of automatic bean properties and events. Chapter 10 covers the details of automatic bean properties and events, but the basic idea is that Jython automatically searches a component for these features and adds shortcuts to establishing properties and event handlers. The shortcuts leverage Jython syntax features to simplify and accelerate development. Chapter 10 also includes information on creating Java applets with Jython.
Java has become very prominent in database programming, and Jython is able to leverage all of Java's success in this area while adding its own advantages. Chapter 11, "Database Programming," introduces the use of Jython in database programming. Chapter 11 includes information on hashed database files as well as the MySQL and PostgreSQL relation database management systems (object-relation for PostgreSQL). Jython also has the advantage of being able to use Java's JDBC database connectivity or the Python database application programmer's interface implemented with zxJDBC. Chapter 11 discusses both of these APIs.
Chapter 12, "Server-Side Web Programming," describes web programming with Jython. For Jython, this means servlets, Java Server Pages (JSP), and taglibs. In other words, server-side web development with Jython coincides with the popular (standard) Java web development paradigm. Chapter 12 addresses using jythonc -compiled classes as servlets as well as an embedded Jython Servlet mapping and IBM's bean scripting framework (BSF).
Java programmers wishing to add a high-level language as a tool in their existing arsenal is the primary audience for this book, but is equally applicable to those seeking an alternative to Java, yet bound to an organization dedicated to Java-based technology. A secondary audience is those beginning Python programmers wishing to extent their Python facility within Java frameworks. Because this book assumes some knowledge of Java basics, this secondary audience may require an additional source for Java fundamentals. If you have no interest in Java, or you are already an advanced Python programmer, then this book is probably not for you.