tools of the trade

Editor: Diomidis Spinellis ■ Athens University of Economics and Business ■ [email protected]

Java Makes Scripting Languages Irrelevant?

Diomidis Spinellis

Simplicity does not precede complexity, but follows it. — Alan J. Perlis

n computing, we often solve a complex came up with Application Basic as its general- problem by adding another level of indi- purpose scripting language for all its office pro- rection. For example, in Unix file systems, ductivity applications. an index node, or inode, data structure lets Those early developments acquainted pro- I the operating system allocate files concur- grammers with the notion of customizing ap- rently and sparsely while still providing an plications through scripting and opened the efficient random-access capability. When we road for powerful, general-purpose scripting want to customize large, complex systems or languages such as , Python, and Ruby (see express fluid, rapidly changing John Ousterhout’s article, “Scripting: Higher- requirements, we frequently Level Programming for the 21st Century,” in add a scripting layer on top of Computer’s March 1998 issue). Scripting lan- the corresponding system. Back guages glued to applications serve an impor- in 1962 to 1963, Dan Murphy tant purpose: they greatly ease the application’s did this when he developed his configuration and customization and support TECO (text editor and correc- end-user programming by offering a safe and tor) editor on the Digital Equip- friendly development environment. Gone are ment Corp.’s PDP-1; its com- the intricacies of C’s memory management, the mand language also doubled as convoluted string manipulation, and the com- an arcane (to put it politely) plexity of the application’s internal data struc- macro language. tures. Instead, the scripting language typically Twenty years later, adding a scripting-lan- offers automatic memory management, a pow- guage interface to existing applications (often erful string data type, sophisticated data struc- written in C) was all the rage. Lotus 123 sup- tures, a rich repertoire of operations, and an in- ported macro commands, Framework had the tuitive API for manipulating application data and FRED (frame editor) language, and you could state. Additionally, by interpreting the scripting program AutoCAD and Emacs in a form of Lisp. language, the application can isolate itself from On the Unix platform, administrators wrote so- undesirable effects of the scripting code, such phisticated sendmail configuration files to bridge as crashes and data corruption. email networks—which were then disparate and My impression is that with the evolution of mutually incompatible. John Ousterhout com- Java and Microsoft’s .NET offerings (I’ll use the pleted the picture by developing Tcl/Tk as a term Java as a stand-in for both alternatives), general-purpose scripting language for integra- the niche occupied by scripting languages is tion with any system that could benefit from rapidly shrinking. We are approaching the end such a capability. A few years later, Microsoft of an era.

70 IEEE SOFTWARE Published by the IEEE Computer Society 0740-7459/05/$20.00 © 2005 IEEE TOOLS OF THE TRADE

Rumors of the death of anisms and its regular expression ex- a command language. Command-line in- scripting languages ... tension syntax or Python’s use of in- terfaces often offer a considerably more Java now offers most of the nice fea- dentation for grouping statements. expressive working medium than GUI tures that scripting languages provide These make some program elements a environments (I’ll expand on that in an- to applications: lot easier to read. As an example, vari- other column). Coupling a command- able substitution within Perl’s or the line interface with a scripting language ■ automatic memory management Unix shell’s double-quoted strings is by means that you can easily promote com- through garbage collection, far the most readable way to represent monly executed command sequences ■ a standard string data type, a program’s output. into automated scripts—a boon to us de- ■ collection interfaces implementing velopers. This coupling also encourages most useful data structures, and Less fuss about types. Most scripting an exploratory programming style, ■ a very rich language library. languages are typeless and therefore which many of us find very productive. I easier to write programs in. For exam- often code complex pipelines step by Additionally, in applications written ple, Perl makes writing a client or step, examining each step’s output, be- in Java, what we might consider an API server for an XML-based Web service a fore tacking another processing element already comes for free as part of the breeze, whereas in Java we have to go at the pipeline’s end. object-oriented design. You only need through numerous contortions to im- to allow an application to dynamically plement the same functionality. Of A shorter build cycle. For many sys- load user-specified classes, expose its course, the robustness and maintain- tems, a build cycle that provides time API by providing access to some of the ability of code written in a typeless lan- for an elaborate lunch is now sadly his- application’s objects, and limit the un- guage is a different question, as many tory. However, the tight feedback loop desirable couplings through the secu- of us who maintain production code permitted by the lack of a compilation rity manager and exception handlers, written in a scripting language later step in scripting languages allows for and the need for a separate scripting discover. rapid prototyping and exploratory language vanishes. changes, which can often occur hand- Many modern Java applications that A more aggressive use of reflection. Con- in-hand with the end user. This is a fea- support beans, plug-ins, and other ex- sider Perl’s eval construct and Python’s ture that those using agile development tension mechanisms follow exactly this object emulation features, which let pro- methodologies can surely appreciate. strategy—notably, Eclipse, Maven, Ant, grammers construct and execute code on Javadoc, ArgoUML, and Tomcat. Even the fly or dynamically change a class’s o, where do we stand now? The gap on resource-constrained embedded de- fields. In many cases, these features sim- S between system programming lan- vices—such as mobile phones, which are plify the construction of flexible and guages and scripting languages is still programmed in a system program- adaptable software systems. slowly closing. For example, some ming language—configuration and cus- scripting languages are capitalizing on tomization is moving in a Java direction. Viability as a command language. Many Java’s infrastructure by having their scripting languages (such as those in op- code compile into Java virtual machine ... are greatly exaggerated erating system shells) can also double as bytecode. However, a lot of ground in Does the trend of customizing appli- the middle is still up for grabs. New sys- cations through a Java interface make tem programming-language designs can scripting languages irrelevant? Yes and offer more of the advantages now avail- no. As an application configuration and able only through scripting. And script- extension mechanism, Java is probably ing languages are constantly benefiting the way to go. The cost of marshaling from hardware performance advances and unmarshaling data objects and that make their (real or perceived) effi- types between the application’s code ciency drawbacks less relevant. The is- written in Java and the conventions ex- Does the trend of sue of the result’s quality remains an pected by a different scripting language customizing applications open question on both fronts. is too high for the limited incremental We developers, as avid tool users, benefits that the scripting language through a Java interface can enjoy viewing the battle from on would offer. On the other hand, script- make scripting top and reap the benefits. ing languages still have an edge in a number of areas, offering us many dis- languages irrelevant? tinct advantages. Yes and no. Diomidis Spinellis is an associate professor in the De- partment of Management Science and Technology at the Athens University of Economics and Business and the author of Code A more flexible or imaginative syntax. Reading: The Open Source Perspective (Addison-Wesley, 2003). Think of Perl’s numerous quoting mech- Contact him at [email protected].

May/June 2005 IEEE SOFTWARE 71