Back to index
Linguist is an unconventional programming system, written entirely in Java, that builds on Java to provide a highly customizable scripting environment for a wide range of applications or applets. You use it to create your own personalized scripting language, with the full power of Java available at any time. As with Java itself, the scripts are compiled, then interpreted at runtime. But because all the important functionality is written in Java there's little if any noticeable loss of performance compared to a regular Java program.
Summary of features
Why use a scripting language?
Java is without any doubt the environment of choice for creating reliable programs quickly. However, a great deal of planning is needed before coding can start, or the result is likely to be just as difficult to maintain as if it were written in C or Fortran. Scripting offers the ability to code right away, without much of the planning stage, but with less risk of creating bad code.
But the chief reason has to do with division of responsibilities. Imagine you are asked to program a conveyor system in a factory, carrying pallets of some arbitrary product. At the lowest level you have the inputs and outputs; the photo-electric cells that tell you where an item is in the system, the readers that identify which pallet is which, the manual override buttons and so on. The outputs are the solenoid-controlled gates and barriers that allow the pallets to progress.
And at the top level you have the logic of the system, that deals with input events and sequences the outputs according to the rules of the system.
Now the skills needed to deal with these two levels are not the same. You can employ a C programmer to write drivers for the hardware, but (s)he may be unfamiliar with the product that's being carried and the way it must be handled. Your production staff have all the experience of dealing with the product but don't know how to program in a language like C or Java.
When you use Linguist you're separating these two sets of skills and using a different type of person to deal with each. Your system programmer uses Linguist to create a scripting language that is customized to the job in hand, then the production engineer writes scripts to control the system, without ever needing to go near Java. As the programmer you still work entirely in Java, but the benefits to the customer are:
To illustrate how this works, how about an example. At one point on the conveyor, pallets must be stopped until a test has been completed, then allowed to continue. Ask the production person for an overview of how this works and the answer will be something like:
Now it seems to me a criminal waste of time and computer power to have to manually translate that into a language like C or Java. So let's rewrite it using a formal script:
This shouldn't need much explanation; the four lines at the top declare different types of variable, most of them specific to this language. The rest, which assumes some initialization has been done, manages the progress of the pallet through the test station. [Control engineers will be ready to point out the deficiencies of such a simple procedure, but we have to start somewhere.]
Linguist enables you to build your own scripting language that can compile and execute the above program directly, without the need to expensively create an equivalent Java version that cannot then be read (or checked) by the production engineer whose job is on the line.
Starting with Linguist
Linguist as supplied implements a core scripting language, to which you add your own specialized language keyword handlers. This is much simpler than it sounds. The core language has a small set of variable types - numeric variables and strings - and a collection of assignment statements, values, conditions and control operators. You can use it, without modification, as a command-line tool for doing arithmetic or string processing. It also comes with a fairly substantial - and growing - set of graphics and multimedia functions, including support for the Java Media Framework. This means you can use it to create interactive multimedia products simply by scripting, without any extra Java coding at all.
There are four different kinds of things you may want to add to the language, to make it suitable for your application:
Each of these items is treated slightly differently, but the process is much the same. First, you write a keyword handler (in Java) that parses the new language feature and extracts the important elements of it. Linguist has templates and built-in methods that make this a snap. The output of this stage is an instance of a new object that will encapsulate all the run-time functionality needed by the item. Then you take a standard handler template and write the extra run-time methods it needs to deal with the object type you just created. So you do in fact write the important part of your program in standard Java, and leave Linguist to provide an overall structure.
A full-blown scripting language based on Linguist will have many hundreds to several thousand classes, organized into maybe a dozen or more packages. This may seem daunting, but it reflects the highly modular nature of the system. Each class does a single job, and you'll hardly see a switch statement anywhere. Linguist provides a framework that demands a totally modular approach to program design, but the result is very reliable code. Most of the classes tend to occupy less than two pages of listing. In effect, Linguist trades lots of subroutines for lots of classes. Incidentally, Linguist would be very difficult to create using C++, and even Java 1.0 lacks important features - notably serialization - that make Linguist possible.
The Linguist development environment
Because Linguist is simply Java with knobs on, we don't supply a separate development environment. To develop your own language based on Linguist, the first thing you need is your favorite Java development environment. This can be Java Workshop, Visual Cafe, Visual J++, JBuilder - whatever tool you like best. Create a new project with the Linguist files and supporting classes and you're ready to go.
As you create new keyword and runtime handlers they are placed in predefined packages, where they will instantly be available to unlock their new capabilities. As each new feature is added a simple test script will verify its behavior.
Embedded scripts
Maybe you would like to add a scripting facility to some other Java product. When you start up Linguist you have the option of passing it an arbitrary data Object that can be accessed from the script. You create script handlers that read and write to this object, then as the script runs in its own thread the calling program can see the results. So your product instantly has an internal scripting language without very much coding on your part.