Scripting languages lack the formal semantics of conventional languages like Java. They are loosely typed and highly dynamic, two features which make them ideal for noncritical project tasks.
The main features of a scripting language include
Over the years, the software industry has spawned a large number of languages that exhibit these features, a testimony to the benefits of scripting languages. There are many well-known and highly regarded examples:
The biggest question facing a J2EE project team is which language to choose. The following lists some points to consider when making the choice. Does the language
In addition to these points, characteristics such as the language's maturity, performance, and quality must also be considered.
With a number of languages to choose from, looking to assess the expertise of members of the team with a particular scripting language is an important consideration. Although offering powerful language constructs and informal semantics, scripting languages are not easy to learn. They employ many concepts that are not available in Java, meaning training time must be set aside to bring a developer up to speed.
If the team is skilled in a language such as Python, then adopting Jython, the Java equivalent, is one way of leveraging that previous Python experience.
Investment in the education of a team in a particular scripting language should be part of a company's wider adaptive foundation for rapid development. Standardization on a common scripting language across project teams allows the sharing of scripts and modules between groups. Staff will also be available in a mentoring role for projects using the scripting language for the first time.
Not all of the main scripting languages are crossplatform. Scripts can be migrated between machines with different operating systems and architectures only if an interpreter for the language exists for the target platform.
Java offers crossplatform support, and it would be preferable if a scripting language were available that offered the same capability. Language builders have addressed this problem by developing scripting languages that execute under a Java Virtual Machine (JVM). Thus, the language is supported on any platform that can host a JVM.
Several languages are available that fall into this category. Table 9-1 lists some of the open source offerings.
Several of the JVM scripting languages are implementations of popular scripting languages; for example, Jython brings Python to the Java platform, and JRuby is a Ruby implementation. Other languages, such as Groovy, have been created specifically for the Java platform.
Integration with Java Classes
For tasks such as writing ad hoc reports, producing automated test cases, or building user-interface prototypes, the scripting language must have the ability to work directly with Java objects.
This is the main reason for choosing a Java-based scripting language over one of the established languages. Without Java integration, many common scripting tasks are far more cumbersome, thereby negating the use of the scripting language.
To appreciate the relationship between scripting language and Java, the next section introduces Jython, a scripting language that is tightly integrated with the Java platform.