TechBookReport logo



Keywords: Scripting languages, Groovy, Java, Jython, Beanshell, JRuby

Title: Scripting In Java

Author: Dejan Bosanac

Publisher: Addison Wesley

ISBN: 0321321936

Media: Book

Level: Introductory

Verdict: A useful introduction to scripting languages on the Java platform

 

While Java the programming language may not be the hot topic it once was, Java the platform is coming increasingly to the fore. And, at the forefront of this are the dynamic languages that make full use of the Java Virtual Machine (JVM): Jython, JRuby, JavaScript, Groovy and the like, as well as the old stalwart and pioneer Beanshell (written by Pat Niemeyer of Learning Java fame). With dynamic JVM languages flowering all over the place, Scripting In Java is a timely little book for those hoping to get to grips with the topic.

The opening section of the book introduces the whole topic of scripting languages, starting with the thorny issue of how you actually define what is and what isn't a scripting language. This is no easy task, and the first chapter goes into detail about static versus dynamic typing, compilation versus interpretation and so on. For those new to the topic it's a solid introduction to the fundamentals of dynamic language features which underpin most of what are commonly called scripting languages. The following chapter goes further and looks at a number of scenarios where scripting languages make sense, including shell languages, application customisation and automation, prototyping and so on. This chapter gives a first glimpse at a range of scripting languages, from Unix shell scripting to Perl, Python and even VBA (Visual Basic for Applications).

The second part of the book changes focus from the general to the specifics of scripting languages and the Java platform. There's a chapter that briefly introduces a range of JVM languages: Beanshell, Jython (Python for the Java platform) and Rhino (JavaScript), with some mention of JRuby, Groovy, Judoscript, TCL/Java and ObjectScript. However, Groovy is a main focus of this book and it gets the next two chapters devoted to it.

For those who've never come across it, Groovy is a dynamic programming language that's designed from the ground up to be familiar to Java programmers and that makes it possible to mix and match classes from Java and Groovy together. The Groovy chapters provide a pretty good introductory tutorial, though it should be noted that Groovy In Action remains the definitive guide to the language and is still recommended for those who really want to get into it.

The Bean Scripting Framework rounds out the end of section two of the book. BSF is a Java framework that enables you to combine code from different scripting languages in one place.

Part three of the book moves into more advanced topics and looks at scripting in practice, mostly using Groovy or Beanshell for the examples. There is discussion of how you use scripting for unit testing, shell scripting, debugging and build automation (i.e. how to supercharge Ant). A chapter is also devoted to showing how you would use scripting languages to implement a range of software design patterns.

The final couple of chapters make up the fourth section of the book. The first of these looks at the Java Scripting API (JSR 223), which sets out to create a standardised platform for scripting languages, with particular reference to the web language PHP. This is still in development, but the chapter walks through both the motivations and the practicalities of how it works. This is followed by the tenth and final chapter, which looks at the Web Scripting Framework, which takes things even further and adds scripting language support to dynamic web pages (JSP).

To be honest the final part of the book could almost be considered an appendix, alongside the real appendices which cover Groovy installation, IDE support and installation of JSR 223. The core content of the book is in the first three sections, which really focus on the introduction to scripting and the more detailed examination of Groovy and, to a lesser extent, Beanshell.

The writing is a little on the dry side, with something of an academic tone at times, which is a pity because this is a topic that is dynamic, interesting and fun. For this reader at least, more emphasis on some of the other scripting languages, such as Jython and JRuby would have been preferable to the chapters on the Scripting API and the Web Scripting Framework. However, on the whole this is a good read, particularly for those readers who are coming to this for the first time.


Hit the 'back' key in your browser to return to subject index page

Return to home page

Contents © TechBookReport 2007. Published October 15 2007