Skip to main content

Java and scripts and pipes

Posted by johnreynolds on March 24, 2005 at 8:16 AM PST

All the recent ramblings about Groovy and Jython makes me wonder:
What makes scripting so powerful?

Let's start with what a "script" is:

In a play a script tells the actors what to do. In a software environment a script tells preexisting components what to do.

Scripts aren't about creating actors or components, they're about orchestrating actors or components.

So why isn't Java a scripting language? After all, Java can be used to invoke preexisting components.

I think that shells and pipes are the answer. Scripting languages (such as bash) have interactive shells. The shell lets an author interactively develop and execute the scripted behavior of preexisting actors (components)... but it also places constraints on those components to enable the use of pipes.

Components that can be executed within a shell must have well defined text-based interfaces. Each component must be able to accept text-based input, and each component must return a text-based outcome. If non-text input or output parameters are necessary, they must be packaged in entities that can be referenced by a text string (such as a file or a stream). These interface constraints are what enables pipes, and the ability to pipe the outcome of one component to another is a big factor in what makes shell scripts so powerful.

I'm just thinking out loud here, but when I look at Groovy and Jython and compare them to bash, I get worried that the value of scripts and pipes might get lost in all the syntactic sugar.

Related Topics >>