Server-side programs: overview

Which languages were used?

Perl was chosen as the language in which the server-side programs would be written. The reasons were:-

Program structure: design techniques

The initial approach was to split the task into logical parts and devote a program to each of these parts (see the seventh design principle: separation of concerns). A "junction" program would then be written to coordinate each program and pass info from one to another. This approach meant writing many small programs (see the first design principle: small is better than big). This meant that a technique had to be developed to pass information from one program to another. To do this involved the use of the Perl "qx" command (to pass info to another program) and the Perl ARGV construct (to get info from another program). An example would be as follows:-

What was the program structure?

The initial program structure looked like this:

One problem surfaced when it came to routes that were too long for one page. In this case the route had to be truncated and a link to generate the next part had to be included. Now, to generate the next part requires the untranslated route, so the structure had to be changed to:-

Using our Perl techniques and design principles, it became relatively straightforward to create programs to do these tasks, and they were:-

It should be noted that all the programs were written by the author with the sole exception of Planner. Planner was originally written by Oege DeMoor to handle Dijkstra’s algorithm and was heavily rewritten by the author (as per the fifth design principle: don’t keep a dog and bark for yourself) to handle the changes to the algorithm.

Where are these programs?

The programs can be found on the enclosed disk. Details of Planner and Dijkstra’s algorithm can be found in the chapter entitled "Calculation", and details of Translateintoenglish.cgi can be found in the "Parsing" chapter.

The technique: good or bad?

It should be pointed out that Perl programs aren’t normally written like this. Usually the smaller programs are written as subroutines and included within the junction program as .pl files. The technique does have the disadvantage of reduced portability (programs written this way in Unix won’t work in Windows, or vice versa) but does have the huge advantage that the programs are written as independent units and separately tested. This technique enables extraordinarily rapid development of smaller programs that are easier to understand, and is (in the author’s humble opinion), far better than the usual let’s-write-one-big-program technique. Most of the thesis programs were under one page long, had clearly defined input and output and were easily understandable. That’s good in anybody’s language.