Monitor No. 8 -- April 1997




Editorial - Joining Java?

Many years ago, when Pascal seemed like a rather good idea, the structured programming paradigm shift was, over a period of years, adopted as the educational model by the majority of higher education computing departments. This was accomplished for very sound and well understood pedagogic reasons. It resulted in the widespread adoption of Pascal as a first language, though not as a base language, in the majority of institutions. In time Pascal was replaced with other structured languages such as Ada or Modula 2 although, even today, there is evidence [McCauley 97] that Pascal still retains its pre-eminence.

Several years ago, when Object Orientation seemed like a rather good idea, many departments adopted C++ as a first language. This was despite the compelling evidence and overwhelming opinion that C, and hence C++, was totally unsuitable for novice developers. The impression was left that these departments had followed this path in pursuance of C++'s commercial importance. This impression was confirmed when it emerged [Culwin 95] that these courses were overwhelmingly procedural with a very minor consideration of Object Orientation tagged on at the end.

This year, in the wake of the World Wide Web, Java might seem to be a rather good idea. The rate at which Java has generated interest, both in academia and in commerce, is unprecedented and the reasons underlying this interest have yet to be fully understood. It was against this background that the "Java in the Computing Curriculum" conference was held at South Bank University: London under the aegis of CTI Computing in February 1997.

If there is any common theme to the papers collected from this conference in this journal it is that the paradigm shift in educational practice towards Object Orientation, which should have been caused by the adoption of C++, will be forced by the adoption of Java. Hence, although there was no keynote paper I would commend Phil McLaughlin's paper 'Oh, by the way, Java is Object Oriented ...' to this position. However a fundamental understanding of Java, particularly of the ways in which it differs from C++, is still required for many people and Barry Cornelius's tutorial 'A Taste of Java' is an excellent introduction to the language.

Two previous software development environments, Apple's Hypercard and Microsoft's Visual Basic, have had an impact somewhat comparable to that of Java though, in retrospect, much more muted. Both of these products rapidly gained a reputation for allowing, or even encouraging, the hacking together of applications with a Graphical User Interface whose functionality was flawed and whose usability was underwhelming. There is no guarantee that developers using Java will not fall into a similar trap; but Tim Ball's paper 'Interfacing with the AWT', subtitled 'Software Engineering and the Abstract Window Toolkit' provides a rigorous approach to the engineering of GUIs which should be required reading for all Java developers.

Experience gained from actually using Java in the classroom was, at the time of the conference, very thin on the ground. The paper by Roger Garside, 'Teaching Java at Lancaster' presents the experience of using Java as a first language in the 1996/7 session. The paper from Alan Battersby, 'Initial experience of using Java in a Distributed Computing Module', probably portends a large number of papers which describe Java's advantages in various area's of curriculum. Finally the paper by Chris Wallace, Peter Martin and Bob Lang, 'Not whether Java but how Java', returns to the theme of Java as a first language and advocates a careful introduction of procedural concepts before considering object orientation. The final paper in this Journal, by Fintan Culwin, presents the results of an opinion sampling workshop on Java held at the 4th Dublin conference which resulted in the Java conference being called.

We live in interesting times and in the computing industry in very interesting times. For good reasons or bad the C style of syntax has become the lingua franca of the computing industry and, as with mediaeval academics and Latin, a working knowledge of C syntax is essential to participate in the software development industry. Latin existed, and exists, in many forms and dialects ranging from pig Latin, through ecclesiastical Latin through to classical Latin. The academic advantages of learning Latin were, and are, related only to classical Latin because of the purity of its structure and the influence which it had upon the English language.

I would contend that, if for no other reason, Java, by removing some of the syntactic absurdities of C++ should replace C++ as the dominant language of undergraduate software development education. The side effects of this transition will be to enable the paradigm shift from structured to object oriented programming, which is already long overdue. A further consequence of this, as Alan Battersby's paper presages, will be to de-obsfucate many arcane areas of instruction. The educational use of Java is still in its infancy and many of the pitfalls have yet to be discovered, accordingly we hope to reconvene the Java conference early in 1998 when, hopefully, many more educators will be able to report upon practical experience.

Fintan Culwin
South Bank University
fintan@sbu.ac.uk

[McCauley 97] Renιe McCauley & Bill Manaris,
Report on the Anual Survey of Departments Offering CSCA/CSAB-Accredited Computer Science Degree Programs.

[Culwin 95] Fintan Culwin,
Object oriented software development education: evolution or revolution?,
SEDA Report 91, pp 111-9, 1995, ISBN 0- 946815-04-6


Contents

Interfacing with the Java AWT: Some Software Engineering Issues
Tim Balls, Leeds Metropolitan University

Initial Experience with Java in a Distributed Computing Module
Alan Battersby, Nottingham Trent University

A Taste of Java
Barry Cornelius, University of Durham

Teaching Java at Lancaster
Roger Garside, University of Lancaster

"Oh, by the way, Java is Object Oriented..."
Phil McLaughlin, Staffordshire University

Not whether Java but how Java
Chris Wallace, Peter Martin and Bob Lang

Java as a First Language?! (JFL) -
Report on the workshop held at the 4th All Ireland conference on the Teaching of Computing
Fintan Culwin, South Bank University

[Return to How to get Monitor]

Interfacing with the Java AWT : Some Software Engineering Issues

Tim Balls
Faculty of Information and Engineering Systems, Leeds Metropolitan University, The Grange, Beckett Park, Leeds LS6 3QS
E-mail : T.Balls@lmu.ac.uk


1. Introduction

The Java programming language offers a number of features that make it attractive as a teaching vehicle:

a clean and mostly consistent object model
simple and understandable libraries for:
graphics
user interface implementation
event processing
network communication
multithreaded programs
error handling through exceptions
garbage collection of deleted objects

Many of the programs that are to be found in current Java books are based on the production of applets for spicing up web pages. As such they contain compromises and are not necessarily good examples to follow for the teaching of software engineering.

In this article I wish to outline how a relatively simple program, implemented in Java, can be used to illustrate a number of software engineering principles. Within the confines of a few pages it is not possible to cover much detail. A fuller version of this document is available on the Internet. (see references) In particular that document shows how the program to be discussed can be developed in a series of steps.

The application to be developed is a simple StopClock (or one-second timer) that shows minutes and seconds and may be started, stopped and reset. A screen shot of the clock in action appears below:

Three buttons control the clock and the permissible operation(s) are indicated by "greying out" the legend on the buttons that are not available. The clock runs in the windowed environment that supports the Java system e.g. Win95 or Motif.

2. An Object Model

Good object-oriented design would suggest that there should be a separation of responsibilities between appropriate objects. The Model-View-Controller paradigm described by Krasner and Pope is an appropriate framework here.

An object model for the application might be shown as:

A Clock object is controlled by a Control Panel object which, in turn, contains three button objects. The Clock object has access to a Display Panel object which contains some kind of fields for displaying the minutes and seconds. In this implementation the display is essentially passive - the Clock object causes the updates to occur.

The user interface will implement a state model and provide visible feedback to the user through appropriate shading of the buttons:

3. The Clock object

The basic Clock object is responsible for counting one-second (or shorter) pulses and causing them to be displayed. A number of strategies are possible for implementing this object and the one taken here is actually to create two coupled objects: a main Clock object and related ClockMechanism. The ClockMechanism is responsible for calling a single function in the Clock object at one-second intervals.

So in ClockMechanism we have:

private Timed myOwner;
public void run()
{

while( true )
{
myOwner.tick();
try
{
sleep( 1000 );
}
catch(InterruptedException e)
{}
}
}

where the object myOwner is the main Clock object and in Clock we have:

private int sec = 0;
private int min = 0;
public void tick()
{

sec++;
if( sec == 60 )
{
sec = 0;
min++;
}
display.displayTime( min, sec );
}

where the displayTime() message invokes an appropriate method in the screen display object.

The ClockMechanism runs in its own thread of control. The sleep(1000) method causes the thread to suspend its execution for at least 1000mS. (This clock will run slow!)

4. Linking the objects

We now have two objects - a Clock and a ClockMechanism that each need to know about the other in order to request services:

the Clock will need to start the ClockMechansim going - and stop and restart it too

the ClockMechanism needs to be able to call the tick() method in Clock.

We can achieve this by making sure that each object has a suitable reference to the other. However it might not be appropriate for the ClockMechanism, for example, to have access to all of the public interface of a Clock object. In Java there is a language construct called interface that allows us to limit the visibility of methods in an object.

The ClockMechanism object could have been written as:

private Clock myOwner;
public void run()
{

while( true )
{
myOwner.tick();

… … … …

but the decision was taken to use an interface such that only the tick() method was available. The interface is called Timed and it is defined as:

public interface Timed
{

public void tick();
}

An interface is used to define the methods that can be called - in a sense it defines a new type - certainly as far as the Java compiler is concerned. The Clock class implements this interface:

public class Clock implements Timed

This is a good way of implementing the equivalent of "call- back" functions in Java. The Clock object creates a ClockMechanism object and passes it a reference to itself:

public class Clock implements Timed
{

ClockMechanism clock = new
ClockMechanism( this );
public Clock()
{
clock.start();
}
public void tick() .. .. .. etc

The ClockMechanism is itself derived from the built- in Thread class and in its constructor it stores the reference to the Clock object it is to control:

public class ClockMechanism extends Thread
{

public ClockMechanism( Timed owner )
{
myOwner = owner;
}
private Timed myOwner;
public void run() … … … … …

The entry point for the Java application is a function in the Clock class:

public static void main(String[] args)

{
new Clock()
}

This function create a new instance of Clock which, in turn, creates its own ClockMechanism. Each of these objects will stay in existence until one of them is destroyed because of the mutual references - the garbage collector will leave them alone. The call to clock.start() in the Clock() constructor will cause the ClockMechansim to execute its run() method. (Both run() and start() are methods defined in Thread and we override run() to provide the required functionality of our thread.)

5. Software engineering issues

1. the separate tasks of generating and counting the pulses have been placed into
separate classes - the pulse generator is likely to be a reusable element

2. the Java interface construction has provided a way of limiting access to an
object's public methods. This is a good way of enforcing encapsulation.

6. The Abstract Windowing Toolkit (AWT)

The core of the model part of the MVC is now finished but it needs a public (inter)face - an on-screen presence.

The Java AWT provides classes that allow us both to create screen output and also to capture events.

To produce a visible window, decorated by the system's own window manager, it is necessary to create a Frame object - i.e. an object derived from the class java.awt.Frame.

For the clock program there are, at least, three strategies open:

1. derive a Clock object from Frame

2. create a Frame object as a part of the Clock object

3. create a separate Display object derived from Frame and provide a suitable link to the
Clock

Both of the options 1 and 2 suffer from the same kind of problem. A Frame object contains over 75 methods in its public interface and all the code in the Clock object has unrestricted access to them - probably not a good idea. Even worse - a Clock derived from a Frame has these functions in its public interface too! It is attractive in that it is easier to handle events as they can all be captured by the Frame object. As indicated above it would make sense for the user-interface code (view and controller) to be separate from the model code. Many of the example Java programs to be found in current textbooks take one of these two routes - generally deriving an application from Frame. For an example Clock program see pp 535-539 of the excellent SunSoft publication "Core Java" by Cornell and Horstmann.

Taking the third approach we will follow a similar route to that taken when creating the ClockMechanism. The user interface class will be derived from Frame but implement a much more limited interface called TimeDisplay, which is all that will be seen by the Clock. The Clock object should only be responsible for pulse counting and should be able to call upon a suitable display object to carry out the work necessary to present the result on screen. The interface object also needs to process user events and call appropriate methods in the Clock object to start, stop and reset the time.

7. The user interface (GUI) object

This object will act as a container for both the view and controller objects. It must itself be derived from the awt.Frame object so that it can appear on screen. It will implement the TimeDisplay interface so that the Clock object can talk to it:

public class GUI extends Frame

implements TimeDisplay
{
private DisplayPanel displayPanel
= new DisplayPanel();
private ControlPanel controlPanel
=new ControlPanel();
private Controllable theClock;

public GUI( Controllable it )
{

theClock = it;
setTitle( "GUIClock" );
add( "North", displayPanel );
add( "South", controlPanel );
pack();
show();
} … … … … … … …

The GUI object contains two sub-objects, a DisplayPanel and a ControlPanel and also a reference to the Clock object it is to control. This reference is via a Java interface:

public interface Controllable
{

public void start();
public void stop();
public void reset();
public void kill();
}

This interface makes accessible only those methods that are appropriate to a controller. In particular, a controller cannot see, and therefore cannot use, the tick() method. In the same way, the ClockMechanism object cannot see or access the methods start(), stop() etc.

The two sub-objects are both derived from awt.Panel. The displayPanel constitutes the upper section of the screen display holding the time output. The ControlPanel holds the "Start","Stop" and "Reset" buttons.

Looking briefly at the code of the constructor for a GUI object:

setTitle( "GUIClock" ) - this sets the text that will appear in the border of the visible window.

add( "North", displayPanel ) - and the similar line underneath it are responsible for positioning the sub- objects within the window - the actual position is the responsibility of a LayoutManager see below.

pack() and show() cause the Frame to first resize itself so that it accommodates its sub-objects correctly and then to become visible on screen.

8. LayoutManager classes

The Java awt expects that programmers describe how a visible window is to look in terms of "positioning rules" rather than requiring that each object be placed at a prescribed pixel position. This relieves the programmer of the need to interrogate the system to find out the screen resolution etc and it is necessary to make platform independence simpler.

For a Frame object, the default layout is called a BorderLayout. It permits 5 sub-objects to be positioned thus:

The "North" and "South" areas will resize to the maximum width of the Frame but will be no deeper than necessary to hold their components, the "East" and "West" areas expand vertically and the "Center" will expand in both directions.

The Panel objects use a simpler FlowLayout where sub-objects are inserted and centred on a line by line basis. The constructor for the DisplayPanel illustrates this:

public class DisplayPanel extends Panel

implements TimeDisplay
{
private TextField minField =
new TextField( "000" );
private TextField secField =
new TextField( "000" );

public DisplayPanel()
{

minField.setEditable( false );
secField.setEditable( false );
setLayout( new FlowLayout() );
add( new Label( "Min" ) );
add( minField );
add( new Label( "Sec" ) );
add( secField );
} … … … …

Here the four sub-objects, two Label and two TextField objects are added and will appear in the order they were inserted. Resizing the panel (on-screen) so that it is narrow but taller will cause the objects to appear in more than one line. The layout of the ControlPanel is similar.

9. Implementing the GUI functionality

The functionality of the display object is achieved through the single method:

public void displayTime( int min, int sec )

{
if( min < 10 )
minField.setText( "0" + min );
else
minField.setText( "" + min );
if( sec < 10 )
secField.setText( "0" + sec );
else
secField.setText( "" + sec );
}

and the GUI object simply passes its values to this method.

The controller object is rather more complicated and requires the processing of events generated by the user.

10. AWT Events

Events are generated either by a user's action or from the operating system. Pressing a key, moving the mouse, clicking a mouse button, uncovering a window can all cause events to be generated. The system always considers a particular awt component to be the legitimate target of the event and it is to this object that the event is sent first. In Java, all events are instances of the class Event and there are a number of public fields of an Event object including:

A method receiving an event can interrogate these fields and decide how to process the event.

10. How do events get to objects?

The simple answer is that a handleEvent( Event e ) method is called with the Event passed as a parameter. However, if the event is not handled in the handleEvent method then a "convenience method" is called for specific classes of event - action(), mouseEnter(), keyDown() .. and so on. Appropriate parameters are passed to these methods. Most component objects are located within AWT containers and, if the component does not handle the event, the container will eventually receive the event - first via handleEvent() then through an appropriate convenience method. Frames and panels are such containers objects.

In the example under consideration, the GUI object is responsible for interacting with the Clock. It is necessary that the processing of the WINDOW_DESTROY event takes place here as it is the object that will first receive the event - when the user closes the window. The following method must therefore be a member of the GUI class:

public boolean handleEvent( Event event )
{

if( event.id == Event.WINDOW_DESTROY )
theClock.kill();
return super.handleEvent( event );
}

IT IS ESSENTIAL that this method calls the over-ridden method of the parent Frame object otherwise the convenience methods will not be called. The action() method is used to process the responses from buttons as far as interacting with the Clock object is concerned:

public boolean action( Event event,

Object argument )
{
if( argument.equals( "Start" ) )
{
theClock.start();
return true;
}
if( argument.equals( "Stop" ) )
{
theClock.stop();
return true;
} … … … … …

The argument parameter is, in the case of a Button object, a string containing the button label. The required functionality is provided within the Clock object itself by the following methods:

public void start()
{

clock.resume();
}

public void stop()
{

clock.suspend();
}

public void reset()
{

min = 0;
sec = 0;
gui.displayTime( min, sec );
}

public void kill()
{

System.exit( 0 );
}

There are now two threads of control running - the one running the ClockMechanism and one running the awt components. It is possible that the user could reset the clock just as a time update was taking place. Java provides mechanisms for preventing this type of problem which are outside the scope of this article. However it is possible to provide a guaranteed solution by not allowing reset to occur if the clock is running. The state model presented earlier shows how this could be achieved. It is implemented in the ControlPanel object.

11. Implementing the state model

The ControlPanel object can capture the button events and respond to them before passing them on to the GUI.

The ControlPanel object uses methods available on a button to enable or disable it - which show as black/grey labels. The full code for the ControlPanel is:

public class ControlPanel extends Panel
{

Button startButton = new Button("Start");
Button stopButton = new Button("Stop");
Button resetButton = new Button("Reset");

public ControlPanel()
{
add( startButton );
add( stopButton );
add( resetButton );
stopButton.disable();
resetButton.disable();
}

public boolean action( Event event,
Object argument )
{
if( argument.equals( "Start" ) )
{
startButton.disable();
stopButton.enable();
resetButton.disable();
return false;
}
if( argument.equals( "Stop" ) )
{
stopButton.disable();
startButton.enable();
resetButton.enable();
return false;
}
if( argument.equals( "Reset" ) )
{
resetButton.disable();
return false;
}
return super.action(event, argument);
}
}

Note: how the action() method returns false even when it has handled a button press. Returning true would prevent the event from reaching the outer Frame object.

12. Software Engineering Issues

By using a number of classes it has been possible to distribute the intelligence around the system - a guideline for object-oriented design (see p64 of Wirfs-Brock ):

the implementation of the model-view-controller paradigm produces a clear separation of
the responsibilities of the objects in the system

the Clock object is just that - a controllable one-second counter/timer

the GUI object encapsulates the display and the controller

the controller implements the state model of the user- interface and provides appropriate
visible feedback

in this simple case, possible thread interaction problems are prevented by the user interface

the use of the Java interface construction allows objects to be created that have restricted
public interfaces - the Clock object is seen as Timed by a ClockMechanism
and as Controllable by a GUI.

13. Conclusion

The Java language is an attractive proposition for software engineering education. It offers a number of important facilities including object-orientation, multi- threaded programming, events, socket-based communication and so on. It is possible to use it to illustrate many of the principles that we, as academics, would like our students to experience. It is important, however, that we realise that many of the "advanced" features may impinge upon otherwise simple programs. (e.g. exceptions must be handled, several threads are always present) The language is also changing. Under the new release (the JDK1.1), the event handling described in this article would be implemented differently although the main architecture of the application would remain essentially unchanged.

References

The full text of the presentation given at the "Java in the Computing Curriculum" meeting together with source code for a set of example programs that further develop the theme of this article sareto be found at the following URL:

http://www.lmu.ac.uk/ ies/comp/staff/iestjb/CTI-Java/CTI- Java.html

Cornell G. and Horstmann C.S.,
"Core Java",
SunSoft Java Series (1996) ISBN 0-13-56575-5

Krasner G.E. and Pope S.T. (1988),
"A cookbook for using the Model-View-Controller user interface paradigm in Smalltalk-80",
Journal of Object-Oriented Progrmming, 1(3).

Wirfs-Brock R., Wilkerson B. and Wiener L.,
"Designing Object-Oriented Software",
Prentice-Hall (1990) ISBN 0-13-629825-7


Please Click Here to Return to Index at the Top of This Page

Initial Experience with Java in a Distributed Computing Module

Alan Battersby
Department of Computing, Nottingham Trent University, Burton Street, Nottingham NG1 4BU
E-mail : abat@doc.ntu.ac.uk


1. Introduction

The Distributed Computing module is one of the second level modules offered by the Computing Department in its undergraduate programme. The module aims are twofold: to introduce computer networks and to provide some experience of programming simple distributed applications. Assessment is by examination and course-work with each component carrying an equal weight. The workload consists of roughly eighty hours of work delivered over a twelve week period. Contact time is a one hour lecture reinforced by a one hour laboratory session; the remaining time is private study. Material pertinent to the course (with relevant exercises) is available on-line at an internal departmental web site. The course is split into two halves the first half emphasises the structure of computer networks and has no programming content; the second part is to introduce client/server systems, and to demonstrate their implementation. It is this second half of the course that is the subject of the rest of this paper.

2. Course Content

A previous version of the module had used C/C++ as the implementation language. The intention was to build upon the skills acquired in the first level C++ programming modules. The characteristics of Client/Server systems were described starting with simple one-shot clients and ending with concurrent servers. The laboratory work was presented at two levels of abstraction. The lowest level required that the student acquire : a knowledge of UNIX (SunOs 4.1.3) sockets[1] and their strengths and weaknesses, plus an appreciation of forking processes and/or using lightweight threads and semaphores. The higher level of abstraction involved familiarity with remote procedure calls (rpc) [2] and the use of rpcgen.

Examination results indicated that students did obtain a useful overview of these topics in the time available, because the set questions were generally answered satisfactorily. The laboratory exercises however proved to be far more difficult. Many students did not get beyond the initial simple problems. Relative inexperience, plus the general pressures on time, ensured that only the brightest and most dedicated students progressed to the more interesting problems. Many found their C++ experience did little to equip them for the general messiness of using processes, threads and semaphores in a UNIX system. Often they completed the module with a sense of dissatisfaction at being unable to progress to the more interesting problems. It became obvious that the laboratory exercises were not achieving their aim of reinforcing the material presented in the lectures. It had been anticipated that several of the low level programming requirements would prove difficult for weaker students. However, the feedback received at the end of the course led to the reconsideration of the laboratory work in its entirety.

3. The case for using Java

Examination of socket based examples provided in several texts [3][4][5], led to the consideration of Java as a possible substitute for C++. It became apparent that Java was a language offering several advantages over C/C++ for programming network based applications of the type covered by the laboratory exercises.

As a platform independent language Java sweeps all operating system idiosyncrasies out of sight, and provides a cleanly defined, often simple, interface to all major language features. Happily, all features required for the laboratory exercises: sockets, threads, and mutually exclusive access to shared resources, were included as part of the Java language.

Socket support comprises two classes Socket and ServerSocket. These classes elegantly capture the fundamental asymmetry between socket use in client and server programs, and help enforce this difference in usage. Several low level operations (for example, the establishment of a connection) are performed internally and become transparent to the programmer, resulting in a simplification of the program code. A selection of socket constructors provides added functionality enabling the specification of the network host as either an Internet address or a string that is transparently converted to an Internet addresses (by performing a DNS lookup). Sockets come equipped with easily accessible streams making the task of writing or reading data to or from processes straightforward. The result of this thoughtfulness in the implementation of the socket class is to reduce the code required to create and support a connection between client and server. The resulting programs are clean and simple. Figure 1 presents a fragment of code to illustrate the principle.

Concurrent processing using threads is elegantly supported. Classes are executable as threads, either by creating them as an extension of the base Thread class, or by creating them as an implementation of the Runnable interface. An interface presents a list of methods that must be implemented by a class. Those classes implementing the Runnable interface must contain a single method called run() which executes when a thread containing a reference to the Runnable class starts. Using threads, one can write a concurrent server in only a few lines of code using a single ancillary class to handle communication with the client process. Whenever the server accepts a client connection it creates a thread to handle all further communication with that client. The code to provide this functionality is quite simple (see figure 2). Encapsulating shared data in a class and providing synchronized methods to access the data enforces exclusive access to shared resources. The programmer simply needs to add the keyword synchronized in the method definition. An example definition heading would be public synchronized int getData(). Java handles synchronisation using hidden internal monitors. If two threads attempt to access a synchronised method simultaneously, one will be blocked until the other completes.

Making a decision to use Java instead of C/C++ as the language of choice is really only swapping one set of constraints for another. One has to weigh the simplicity of the Java code against the problems inherent in learning a new language in the brief time allocated for practical exercises. Whilst Java is syntactically quite similar to C++ it nevertheless differs in significant areas. I/O is often a problem in any language. Unfortunately, stream based I/O in Java is significantly different from that in C++. Therefore, I/O was one area where one could expect there to be problems and misunderstandings. Another potential problem might occur because Java is a diverse language with many pre-defined classes. Java is not a "lean" language. It comes with wide ranging support in many areas and with many built in classes. Some might find the sheer diversity initially overwhelming.

On the positive side, four other modules offered on the course had already introduced the concept of object-oriented programming. Students were familiar with classes and inheritance albeit from a C++ viewpoint.

Figure 2 - Concurrent Server Code

4. The new course

It was decided to trial the use of Java in this module. The expectations were that the simplicity of the Java code would allow most students to be more productive than in C or C++, and that the laboratory exercises would again become a reinforcement of the lecture material and less of a encumbrance. The significance of the burden placed on the student in learning Java was unknown. The expectation was that the simplification in code would make the exercises easier, thus promoting a sense of achievement which would carry students through the learning curve resulting in a sense of satisfaction instead of one of underachievement. Focusing attention to a restricted subset of Java ought to flatten the learning curve. Therefore, the topics covered would be confined to: classes, sockets, threads, exception handling, synchronised shared objects, and stand-alone programs, with emphasis placed on those aspects syntactically quite similar to C++. Topics such as Packages, interfaces, threadgroups and the Abstract Windows Interface(AWT) would not be covered.

The introduction of a higher level of abstraction, as represented by RPC in the previous course, was problematic. The equivalent of RPC, remote method invocation or RMI, was then only at a development stage and so it was not really practical to cover this topic. However, it was also impracticable to cover RPC because this would require a switch back to C after only two to three weeks of Java programming. Regretfully, the RPC material was replaced by new material covering the world wide web and three-tier architectures. The new course syllabus was:

introduction to distributed algorithms, review of networks, TCP/IP and protocols;

characteristics of Client/Server applications, functionality, ports, addresses and sockets,
example Java code;

concurrent Servers and threads;

access to shared resources, three-tier architectures;

World Wide Web, Applets as clients, security.

The laboratory exercises associated with the module were:

an introduction to UNIX, compiling and running simple Java programs;

to compile and Test simple one-shot client/server programs running on different
machines. One of the client/server combinations disagreed on protocol and deadlocked;
the students had to explain the resultant behaviour and correct the code. Implement several
client/server combinations adhering to simple given of protocols;

run and amend several thread based programs then write and test a simple concurrent
server, only code fragments were described in the lecture;

to complete and test a more complex stock-server simulation using several concurrent
clients;

to run a demonstration of a three tier architecture for the stock-server using Web based
Applets as clients.

5. Evaluation of the course

Java was used as the implementation language for the Distributed Systems module which ran in the first semester of the 1996-1997 academic year and was taken by over two hundred students. One immediately noticeable outcome was that the course really did run more smoothly. The number of requests for help were significantly fewer than the previous year. The switch from C++ classes to Java classes, with its attendant change in syntax, seemed to pass almost unnoticed, even threads did not cause any undue concern. All managed the initial exercises and were able to write and test a simple concurrent server. The initial practical exercises were automatically assessed; however the student stock- server solution had to be demonstrated. For example, the ability to write a network client was assessed by requiring the student to write their client so it would implement a randomly generated protocol assigned to them. They had to connect their client to a testing server on a given port. If their client successfully implemented the protocol, a unique random key value was returned. To gain the marks associated with this task, the student had then to fill in a form on a web-page to submit their key to an on-line database administrator. The simple servers were tested in a similar manner.

The problems encountered were mainly concerned with I/O and the use of parsers to read numbers from a stream. Several explanatory example programs had to be given as examples and the point covered during lecture time. Some students had to be persuaded that a different language did not necessarily mean that a radically different syntax was being used (for example that a for loop had the same syntax in Java as in C++).

One unexpected bonus was the interest generated simply because Java was the language used. The fact that Applets and the AWT were not being covered did little to affect this enthusiasm. Attendance at laboratory sessions was consistently high with many students asking how they could put Java on their own machines at home.

Feedback at the conclusion of the module was very positive and very supportive of the use of Java on this course. This feedback was substantiated in the examination at the end of the module with over 40% of students attempting both and over 70% at least one of the questions associated with this part of the course. Some comments are listed below:

"Java content is excellent, I'd also prefer to receive more direction and less actual code in
practicals, in order that I would have to write more code myself, (but I can
see that this is a more personal desire than would suit the whole course)".

"Although the Java was both interesting and relevant, not enough time was provided to
do it in".

"A lot of exercises to cover in the practicals for the duration of the course. Java was
interesting to learn(could have gone through it in a bit more depth)".

There was concern about the short time allocated to labs, and it was certainly the case that
the work could not be achieved in the single hour set for laboratory work. However, this
was never the intention, students were expected to work around five hours per
week on top of the laboratory time.

A colleague in an associated college, who was also presenting this module, did prepare the ground a little better by replacing the last couple of labs in the first half of the course with an introduction to Java. This effectively replaced the first Java exercise and allowed a longer acclimatisation time before the client/server exercises. He reported very few problems in changing to Java. This model will be followed in the presentation of the module.

6. Conclusions

Java proved to be an ideal language for use in this module. Its features support the implementation of client/server systems in a clean, logical and simple way. The simplicity of its code meant that most students quickly produced working programs which gave them the confidence to attempt the later examples. The course ran more smoothly and with fewer problems than in previous years where C++ was used.

References

R.Stevens,
"UNIX Network Programming",
Prentice Hall

J. Bloomer,
"Power Programming with RPC",
O'Reilly & Associates 1992

M. Daconta,
"Java for C/C++ programmers",
J. Wiley 1996

G. Vanderburg,
"Tricks of the Java Programming Gurus",
Sams Publishing 1996


Please Click Here to Return to Index at the Top of This Page

A Taste of Java

Barry Cornelius
IT Service, University of Durham, DURHAM DH1 3LE
E-mail : Barry.Cornelius@durham.ac.uk
URL :
http://www.dur.ac.uk/~dcl0bjc/Java/


1. Introduction

1.1 What is Java?

Java is an object-oriented programming language developed by Sun Microsystems. It has: strong-typing, garbage collection, multithreading, exception handling and no architecture- dependent constructs. It does not have: structs, unions, pointer arithmetic, operator-overloading and multiple inheritance. It is accompanied by many packages (collections of classes) including one for building GUIs.

1.2 How is it executed?

Unlike most programming languages, Java source code is not compiled into native code. Instead, a Java compiler translates Java source code into an architecturally-neutral intermediate form known as bytecode. Instructions in this bytecode are interpreted by a Java interpreter.

Sun's Java Developers Kit (JDK) includes a compiler and interpreter. They provide (free of charge) versions for Solaris 2.x (both sparc and x86), for Windows 95, for Windows NT and for MacOS System 7 (and above). Currently, the version of the JDK that most people use is JDK 1.0.2. However, the final release of JDK 1.1 is now available. The next release (JDK 1.1.1) will be a bug-fix release. Both JDK 1.0.2 and JDK 1.1 can be downloaded from:

http://www.javasoft.com/nav/download/index.html

1.3 What are Java applications?

A Java application is a conventional program. It must have a method called main.

Suppose that the file HWTion.java contains the Java application:

public class HWTion {

public static void main(String[ ] args) {
System.out.println("Hello World!");
}
}

It can be compiled by using the Unix/MS-DOS command:

javac HWTion.java

This command produces a file of bytecodes in the file HWTion.class. This file can then be interpreted (i.e., executed) by using the command:

java HWTion

1.4 What are Java applets?

A Java applet is Java source code whose bytecodes will be executed as part of viewing a WWW page. The applet's author compiles the Java source code into bytecodes. These bytecodes will be downloaded from their author's site by a WWW browser when the WWW page is visited. So, the browser needs to have a Java interpreter to interpret the bytecodes. This is true for WWW browsers that are Java-aware, e.g., Sun's HotJava, Microsoft's Internet Explorer or Netscape's Navigator.

Until recently, Netscape Navigator for Windows 3.1 did not support Java. However, a beta version is now available. For more details, see:

http://home.netscape.com/comprod/products/navigator/version_ 3.0/winjava.html

There is also a version of Internet Explorer (3.0a) that supports Java on Windows 3.1:

http://www.microsoft.com/ie/product/win31/java16.htm

Sun's JDK includes an appletviewer that can be used if you do not have a Java-aware WWW browser.

Suppose the file HWLet.java contains the Java applet:

import java.awt.Graphics;
import java.applet.Applet;
public class HWLet extends Applet {

public void paint(Graphics rGraphics) {
rGraphics.drawString("Hello World!",
50,25);
}
}

It can be compiled by using the command:

javac HWLet.java

This command produces the file HWLet.class.

When a browser reads the WWW page given below, it finds that it has to retrieve the file HWLet.class. When the bytecodes in this file arrive, it can interpret them.

HTML>
HEAD>
TITLE> HWLet example /TITLE>
/HEAD>
BODY>
Before the output from the applet.
APPLET CODE="HWLet.class" WIDTH=150 HEIGHT=25>
/APPLET>
After the output from the applet.
/BODY>
/HTML>

* Please note that a number of less than symbols are missing from the above code so that the code can be viewed by you.

You can access a WWW page containing the above HTML instructions by using the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/HWLet.html

1.5 Some real examples of applications

One of the first large applications was the WWW browser produced by Sun called HotJava. So, all of the code of HotJava is written in the Java programming language. For more details, see:

http://www.javasoft.com/HotJava/

Sun has produced an IDE (Integrated Development Environment) for Java written in Java called Java Workshop:

http://www.sun.com/developer-products/java/

Borland's AppExpert and Debugger for Java are written in Java:

http://www.borland.com/jbuilder/introguide/java1_1.html

Two groups have produced WWW servers written in Java. Sun has produced Java Web Server (formerly known as Jeeves) at:

http://www.javasoft.com/products/java-server/index.html

and the World Wide Web Consortium has produced Jigsaw at:

http://www.w3.org/pub/WWW/Jigsaw/

1.6 Some real examples of applets

A pre-beta release of Corel Office for Java, a suite of office productivity applications (including Quattro Pro and WordPerfect) written entirely in Java, is obtainable from:

http://officeforjava.corel.com

Applix's product Anyware Office is a complete suite of applications (written in Java) including a WYSIWYG word processor, a 3-D GUI spreadsheet, business graphics and an e-mail client. The same applications can be executed on "Webtops, NCs, Windows 95, NT and UNIX desktops and servers". It costs $295 per concurrent user. See:

http://www.applix.com

1.7 A digression: what is JavaScript?

Here is a WWW page that includes some source code written in JavaScript:

HTML> HEAD> TITLE> Square demo /TITLE> /HEAD>
BODY>
P> Start. /P>
SCRIPT LANGUAGE="JavaScript">
!— hide this script from some browsers
function mysquare(myarg) {

document.write("P>Hello again/P>");
document.write("P> code>myarg /code> is",
myarg, "/P>");
return myarg*myarg;
} ;
document.write("P>Value returned is: ",
mysquare(7), "/P>");
// end of hide —>
/SCRIPT>
P> Finish. /P>
/BODY> /HTML>

* Please note that a number of less than symbols are missing from the above code so that the code can be viewed by you.

JavaScript is another programming language. You put JavaScript code in HTML documents with a <SCRIPT> tag. The JavaScript code is not compiled: instead, it is interpreted by a JavaScript-aware WWW browser. Netscape Navigator (including the Windows 3.x version) understands JavaScript.

You can access a WWW page containing the above HTML instructions by using the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/squa re.html

JavaScript has most of Java's expression syntax and basic control flow constructs, but it does not have Java's strong type checking and static typing. You cannot write your own classes. So, JavaScript is not as powerful as Java. It is confusing for Java to be included as part of the name JavaScript.

2. The Java language

2.1 What's been taken out from C/C++?

#define, typedef, enum, union, struct, sizeof, goto, pointer arithmetic

most uses of const: some uses renamed as final

global variables - every variable has to belong to a class (or is a local variable)

standalone functions - every function has to be a method of a class

optional arguments, operator overloading, templates

friend functions - however, by default everything in a package is a friend of everything else
in the package

multiple inheritance - however, some uses can be replaced by interfaces

2.2 What's left?

Java's primitive data types have specified ranges:

boolean (1 bit), char (2 bytes, Unicode),

byte (1 byte), short (2 bytes),

int (4 bytes), long (8 bytes),

float (4 bytes, IEEE 754),

double (8 bytes, IEEE 754)

Java also has arrays, which can be multi-dimensional.

Java contains C's if, else, for, while, do while and switch statements. However, all conditions must return a boolean. So, some of the more obscure conditions of C are prohibited.

2.3 What's new? (a) Garbage collection

People sometimes write Pascal/C/C++ code that inadvertently dispose/free/delete objects which are still in use:

var p, q:^integer;
int *p, *q;
new(p);
p = malloc(sizeof(int));
p^ := 27;
*p = 27;
q := p;
q = p;
dispose(p);
free(p);
writeln(q^);
printf("%d\n", *q);

In Pascal/C/C++, programs often cause memory leaks by not using dispose/free/delete on objects no longer in use.

In Java, you do not delete objects: instead, Java has garbage collection. The garbage collector detects objects no longer in use, and reuses their space. You also do not have to provide destructors for classes.

2.4 What's new? (b) Multithreading

In Java, you can easily start more than one thread of execution.

If a variable is accessed by two (or more) methods which are called from different threads, you can ensure that the variable is accessed properly by using synchronized:

public class Store {

private int i; ...
public synchronized int get() {
... return i;
}
public synchronized void put(int v) {
i = v; ...
}
}

2.5 An example of a class

In Java, it is possible to use a class declaration to define your own type. Suppose that it is necessary to manipulate some dates in a program. Here is a rather primitive class declaration:

public class Date {

public int day, month, year;
public void display() {
System.out.println(day + "-" + month
+ "-" + year);
}
}
public class UseDate {
public static void main(String[ ] args) {
Date noel = new Date();
noel.day = 25;
noel.month = 12;
noel.year = 1996;
noel.display();
}
}

2.6 A better version of the class Date

A private modifier can be used to hide the representation:

public class BetterDate {

private int day, month, year;
BetterDate (int d, int m, int y) {
day = d; month = m; year = y;
}
public void display() {
System.out.println(day + "-" + month
+ "-" + year);
}
}
public class UseBetterDate {
public static void main(String[ ] args) {
BetterDate noel =
new BetterDate(25, 12, 1996);
noel.display();
}
}

If necessary, other methods can be provided to access the hidden fields or to update them.

2.7 An example of inheritance

Inheritance can be used when a class is a more specialized form of another class:

import java.util.Vector;
public class Stack extends Vector {

public Stack() { super(); }
public void push(Object item) {
addElement(item);
}
public Object pop() {
int s = size();
Object item = elementAt(s - 1);
removeElementAt(s - 1);
return item;
}
}

A Java application that uses the Stack class is at the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/UseS tack.java

2.8 Exception handling: (a) throwing

If a method detects that some untoward event has occurred, it can use a throw statement to signify that an exception has occurred:

import java.util.Vector;
public class BetterStack extends Vector {

public BetterStack() { super(); }
public void push(Object item) {
addElement(item);
}
public Object pop()
throws BetterStackException {
int s = size();
if ( s == 0 )
throw new BetterStackException();
Object item = elementAt(s - 1);
removeElementAt(s - 1);
return item;
}
}
public class BetterStackException
extends Exception {
public BetterStackException() {
super();
}
}

If a method throws an exception, this must be documented in the heading of the method by a throws cause.

2.9 Exception handling: (b) catching

In Java, a try statement with one or more exception handlers (each introduced by the keyword catch) is used to indicate that a piece of code wishes to handle exceptions.

If a throw statement is executed, control is transferred to the exception handler of the most-recently-entered try statement containing an appropriate exception handler:

BetterStack s = new BetterStack();
try {

System.out.println(s.pop().toString());
}
catch( BetterStackException e ) {
System.out.println("empty stack");
}

A complete Java application that uses the BetterStack class is at the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/UseB etterStack.java

2.10 Package declarations

In Java, a package is a collection of classes. You can indicate that a class belongs to a particular package by a package declaration at the start of the file:

package myutils;

It is possible for Java source code to refer to classes in different packages even if they have the same name. For example, suppose some code requires to use both the class Stack from the package java.util and the class Stack from the package myutils. It can do this using the names java.util.Stack and myutils.Stack.

Java specifies a convention for generating globally unique names, e.g., UK.ac.dur.dcl0bjc.myutils.Stack.

3. Java's packages

3.1 Packages of the Core API

In order to support programming in Java, many packages have already been constructed. Here is a list of the packages that belong to the Core API of JDK 1.0.2:

java.applet is used to support the writing of applets

java.awt is the Abstract Window Toolkit (AWT) which allows a GUI to be written without regard to the platform(s) on which the program will be executed

java.io is for reading/writing streams, files, pipes

java.lang defines the classes Object, Class, Thread, Boolean, Character, Integer, Float, Double, Math and String

java.net is used to support network programming

java.util includes the classes BitSet, Date, Dictionary, HashTable, Random, Stack and Vector

The packages are documented at:

http://www.javasoft.com/products/JDK/1.0.2/api/

This URL gives the Core API for JDK 1.0.2. However, the Core API of JDK 1.1 has many other APIs. For details, see:

http://www.javasoft.com/products/JDK/1.1/docs/relnotes/featu res.html

3.2 Handling strings

In the package java.lang, there are two classes that store and manipulate character data: String is used for immutable strings and StringBuffer is used for mutable strings. Objects of the class String are usually more efficiently handled than StringBuffers, and they can be shared.

String includes the following methods:

length, charAt, toLowerCase, toUpperCase, equals, equalsIgnoreCase, compareTo, startsWith, endsWith, indexOf, lastIndexOf, substring, trim, concat, replace

StringBuffer includes the following methods:

length, capacity, charAt, setCharAt, insert, append, toString

3.3 An example of processing a string

Here is a method (called reverse) that uses the classes String and StringBuffer:

public class StringExtras {

public static String
reverse(String source) {
int charNum;
int numChars = source.length();
StringBuffer temp =
new StringBuffer(numChars);
for (charNum = (numChars-1);
charNum>=0; charNum—) {
temp.append(source.charAt(charNum));
}
return temp.toString();
}
...
}

3.4 Providing a GUI

The package java.awt consists of many classes forming the Abstract Window Toolkit. It provides GUI components such as: buttons, checkboxes, lists, menus and text areas. It also includes containers (such as windows and menu bars), and higher-level components (such as dialog boxes, including dialog boxes for opening or saving files). There are also classes for basic drawing operations, and for manipulating images, fonts and colours, and for handling events such as mouse clicks.

3.5 An example of providing a GUI

Suppose we want to construct a Java applet that has a button and a textfield such that each time the button is pressed the textfield is updated to show the current date and time.

With JDK 1.0.x, we can override the method handleEvent of the class java.awt.Component:

import java.applet.Applet;
import java.awt.*;
import java.util.Date;
public class ButtonClock extends Applet {

private TextField tTextField =
new TextField("hello", 35);
private Button tButton =
new Button("get date and time");
public void init() {
add(tButton); add(tTextField);
}
public boolean handleEvent(Event rEvent){
if (rEvent.target.equals(tButton) &&
rEvent.id == Event.ACTION_EVENT) {
Date tDate = new Date();
tTextField.setText(tDate.toString());
return true;
}
return false;
}
}

JDK 1.1 has a better way of handling events. Here is a better version of ButtonClock:

import java.applet.Applet;
import java.awt.*;
import java.util.Date;
import java.awt.event.*;
public class ButtonClock11 extends Applet

implements ActionListener {
private TextField tTextField =
new TextField("hello", 35);
private Button tButton =
new Button("get date and time");
public void init() {
tButton.addActionListener(this);
add(tButton); add(tTextField);
}
public void actionPerformed
(ActionEvent rActionEvent) {
Date tDate = new Date();
tTextField.setText(tDate.toString());
}
}

For more details about converting programs from using the AWT API of JDK 1.0.x to that of JDK 1.1, see:

http://www.javasoft.com/products/JDK/1.1/docs/guide/awt/HowT oUpgrade.html

3.6 More information about ButtonClock

With an appropriate Java-aware WWW browser, you can execute the above applets from the URLs:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/Butt onClock.html

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/Butt onClock11.html

A more involved example of Java source code that creates a user interface can be displayed by using the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/SAT. java

Because of the way in which it has been written, this source code can be executed either as a Java applet or as a Java application. You can execute the SAT applet through the URL:

http://www.dur.ac.uk/~dcl0bjc/Java/a.taste.of.java/code/SAT. html

3.7 JDK 1.1

The final release of JDK 1.1 is now available for Windows 95/NT and Solaris (sparc and x86). A version of JDK 1.1 for the Mac is planned for Q2 1997. The next release (JDK 1.1.1) will be a bug-fix release. For more details about JDK 1.1, see:

http://www.javasoft.com/products/JDK/1.1/index.html

The new features of JDK 1.1 include: internationalization, improved security, signed Applets, AWT enhancements, JavaBeans API, networking enhancements, IO enhancements, JAR (Java ARchive), Remote Method Invocation, object serialization, reflection, JDBC (Java DataBase Connectivity), inner classes, a new native method interface, Byte, Short, Void, BigInteger and BigDecimal classes, and performance enhancements. For more details, see:

http://www.javasoft.com/products/JDK/1.1/docs/relnotes/featu res.html

Here are some compatibility issues:

1.0.x bytecode files can be executed by the JDK 1.1 interpreter;

1.0.x Java programs can be compiled by the JDK 1.1 compiler;

1.1 bytecode files are not yet understood by Netscape Navigator.

3.8 Microsoft's Application Foundation Class

Microsoft has announced its intention to release an API called the Application Foundation Class (AFC). Written in Java and built in terms of the AWT, it will include GUI components such as toolbars, tabbed dialog boxes and tree controls.

Microsoft say that the AFC may be redistributed free by application developers with their products on any Java- capable platform.

The AFC is not currently available for download. Its first beta will be in Q1 1997 and the final release is scheduled for later in the year. This is the same schedule as Internet Explorer 4.0.

For more details about the AFC, see:

http://www.microsoft.com/java/

3.9 Information about other APIs

Besides the Core API, Sun is also defining and publishing Standard Extensions. A broad overview of the current and forthcoming APIs for Java, both for Core libraries and for Standard Extension libraries, can be seen at:

http://www.javasoft.com/products/api-overview.html

4. Other points

4.1 Security issues

Java ensures some problems do not arise: no pointer arithmetic, restricted forms of casting, no indexing outside arrays, no heap and stack overflows. A Java application has unrestricted access to local files, to the network, and to system calls. However, the environment of an applet is controlled by the WWW browser: there is no access to local files in Netscape Navigator, whereas HotJava users can configure read and write access.

Security is a moving target as loopholes get discovered and fixed. For more details, see:

http://www.javasoft.com/sfaq/

For other papers on security, see:

http://www.javasoft.com/security/

The Open Software Foundation has several papers on Java including one entitled Security Features of Java and HotJava:

http://www.osf.org/mall/web/java_rpt.htm

Princeton University's Department of Computer Science has detected many of Java's security problems. See the News and Frequently Asked Questions items at:

http://www.cs.princeton.edu/sip/

David Hopwood of Oxford University has detected other bugs.

For details about the book Java Security: Hostile Applets, Holes and Antidotes written by Gary McGraw and Edward Felten (Wiley, ISBN 0-471-17842-X, $19.95), see:

http://www.rstcorp.com/java-security.html

4.2 Other ports of the JDK

HP has ported JDK 1.0.2 to HP-UX 10.01, 10.10 and 10.20 for the HP 9000 systems:

http://www.hp.com/gsyinternet/hpjdk/

HP has also begun a port of the JDK to MPE/iX for the HP 3000 systems:

http://www.hp.com/ibpprogs/csy/advisor/sept96/news/java.html

For details of how to obtain the port of the JDK to Linux, see:

http://www.blackdown.org/java-linux.html

This WWW page also contains a Java-Linux HOWTO and details about how to execute HotJava, Java Workshop, Jeeves and the JDBC with the Linux port.

IBM has released ports of the JDK for OS/2, OS/390, AIX and Windows 3.1, and work continues on a port to OS/400. The port to Windows 3.1 is called ADK for Win 3.1:

http://ncc.hursley.ibm.com/javainfo/hurindex.html

See also:

http://www.ibm.com/Java/

The Open Software Foundation has ported JDK 1.0.2 to seven platforms:

http://www.gr.osf.org/java/

4.3 Cloning the JDK

One clone of the JDK is Kaffe from Tim Wilkinson. Kaffe currently interprets bytecodes on Intel, SPARC, the PowerPC, Motorola's 68K, MIPS and Alpha. Supported OS include SunOS 4.1.x, Solaris 2.x, Irix, Linux, Windows 95 and AmigaOS. On Pentiums and Sparcs, Kaffe also has a just- in-time (JIT) compilation system which translates the bytecode to native machine code on a method-by-method basis as the application is executed. "This has demonstrated speedups of 10 times that of Sun's JDK, and is general[ly] about half the speed of optimised C code." See:

http://www.tjwassoc.demon.co.uk/kaffe/kaffe.htm

Another clone of the JDK is guavac produced by Effective Edge Technologies. Written in C++, release 0.2.5 "has been tested under Solaris 2.x, SunOS 4.x, Iris 5.3, HP/UX 9, and Linux 1.x using gcc-2.7.2 and libg++-2.7.1 and binutils-2.6, but other operating systems should work without any major changes". For more details, see:

http://www.cs.berkeley.edu/~engberg/guavac/

Andreas Krall has released version 0.1 of CACAO, a 64 bit JIT system for an Alpha running Linux or Digital Unix. See:

http://www.complang.tuwien.ac.at/java/cacao/

4.4 Tools to support Java

A Java mode for emacs is in the directory:

ftp://sunsite.doc.ic.ac.uk/packages/java/pub/java/contrib/em acs

A debugger (jdb) and a documentation tool (javadoc) form part of Sun's JDK.

Sun's Java Workshop includes: Project Manager, Visual Java (a GUI builder), Source Editor, Build Manager, Debugger, Source Browser, Project Tester, Portfolio Manager. For more details (including a free 30-day trial offer), see:

http://www.sun.com/sunsoft/Developer-products/java/

Until 31st March 1997, the list price is reduced from $295 to $99. In the UK last year, there was an educational offer of £810 for a 25-user pack.

4.5 Integrated Development Environments

Borland C++ 5.0 includes Java development tools such as AppExpert, a visual debugger, a project manager and AppAccelerator (a just-in-time compiler). Borland is producing a complete product called JBuilder (previously called Latte). Borland intend to release a beta which complies with JDK 1.1 in Q1 1997. See:

http://www.borland.com/jbuilder/

Symantec has released Cafι for Windows 95/NT and the Macintosh. Based in part on the Symantec C++ 7.2 IDDE, it includes a Java compiler, browser, Java-aware editor, class editor, hierarchy editor and debugger. More recently, they have released for the same platforms "a complete Rapid Application Development (RAD) environment for Java" called Visual Cafι. For Windows 95/NT, there is also a Pro version which provides support for database servers. See:

http://cafe.symantec.com

Rogue Wave has an IDE called JFactory. It is available for Windows 95/NT, Solaris 2.x (sparc), HP-UX 10.x and OS/2. See:

http://www.roguewave.com/products/java.html

Metrowerks has support for Java in their development environment CodeWarrior for Windows 95/NT and the Macintosh. See:

http://www.metrowerks.com/products/java/

Asymetrix has an IDE for Windows 95/NT called SuperCede. They claim to have "the fastest and easiest-to-use" IDE. It is available free for 15 days and then costs $99.95. The compiler can also generate x86 code. See:

http://www.supercede.com

Microsoft has a product for Windows 95/NT called Visual J++. Version 1.0 costs $99; claims to compile at over 10,000 lines per second; and includes wizards to help developers reuse existing ActiveX controls and to create new ones. See:

http://www.microsoft.com/visualj/

On March 19th, Microsoft plan to release Visual Studio 97 (previously known as Boston) containing new versions of Visual Basic (5.0), Visual C++ (5.0), Visual J++ (1.1), Visual FoxPro (5.0) and Visual InterDev (1.0). The Java, C++ and InterDev products will all share the common development environment called Developer Studio. See:

http://www.microsoft.com/vstudio/

Marimba has produced Bongo. It costs $495. See:

http://www.marimba.com/products/

For Windows 95/NT, Penumbra has produced Mojo. See:

http://www.PenumbraSoftware.com/mojos.htm

For the Macintosh, Roaster Technologies has produced Roaster. See:

http://www.roaster.com

Visix Software is developing a product called Vibe. Beta versions are available free for Windows 95/NT, Solaris 2.5, Linux, AIX and Irix. See:

http://www.visix.com/products/vibe/

Sybase has released a second beta of Jato (previously known as Starbuck) with a final release planned for mid-1997. This is a RAD Java development tool that includes JavaBeans and ActiveX component integration. Jato also includes jdbcConnect which offers direct access to databases and a Visual SQL query editor. See:

http://www.powersoft.com

IBM are developing a RAD environment for Java called VisualAge for Java with a beta release due out in April and support for Windows 95/NT, OS/2, AIX, AS/400 and MVS:

http://www.software.ibm.com/ad/vajava

4.6 Compiling other languages into bytecodes

Intermetrics is producing AppletMagic, an Ada95 compiler that generates bytecodes. There are versions for Windows 95/NT, Windows 3.1 + Win32S, MacOS, SunOS 4.x and Solaris 2.x:

http://www.appletmagic.com

ObjectAda for Windows (a GUI Builder) produces bytecodes and is available for Windows 95/NT and Windows 3.1 + Win32S. See:

http://www.thomsoft.com/Products/Ada/factsht.html

GNAT (the Ada95 compiler from New York University) may be re-targetted to generate bytecodes. See:

http://www.adahome.com/Resources/Languages/gnatjava.html

A tutorial on creating "Java programs" in Ada95 is at:

http://www.adahome.com/Tutorials/Lovelace/java.htm

NetRexx is derived from an earlier language called Rexx. It is claimed that by using NetRexx you can create programs and applets for the Java environment faster and more easily than by programming in Java. NetRexx source code is currently translated into Java source code. The NetRexx compiler executes on any Java platform. See:

http://www2.hursley.ibm.com/netrexx/

4.7 Books on Java

A detailed list of the large number of Java books being written is at:

http://lightyear.ncsa.uiuc.edu/~srp/java/javabooks.html

It includes a list of the books whose texts appear on the WWW. Other lists of books are at:

http://www.statenislandonline.com/java/

http://sunsite.unc.edu/javafaq/books.html

http://www.javasoft.com/nav/read/books.html

Although the book Teach Yourself Java in 21 Days by Laura Lemay and Charles L. Perkins has had numerous errors, it is quite a good book for getting started with Java. See:

http://www.mcp.com/samsnet/books/030-4/030-4.html

For my list of errors in an earlier printing of this book, see:

http://www.dur.ac.uk/~dcl0bjc/Java/

Java in a Nutshell: A Desktop Quick Reference for Java Programmers by David Flanagan (from O'Reilly and Associates) is excellent for those who know C++ (or possibly just C). Costing just £14.95 or $19.95, it includes useful summaries of various aspects of the language and the packages. See:

http://www.ora.com/catalog/javanut/

Its ISBN is 1-56592-183-6. They are releasing a second edition for JDK 1.1 as soon as possible. For other books on Java from O'Reilly, see:

http://www.ora.com/publishing/java/products.htm

SunSoft Press has published some books on Java. See:

http://www.sun.com/smi/ssoftpress/

Addison-Wesley has published several books in their Java series. The most important ones are The Java Language Specification (ISBN 0-201-63451-1) and The Java Class Libraries: An Annotated Reference Specification (ISBN 0- 201-63458-9):

http://www.aw.com/cp/javaseries.html

The texts of some of these books are available through the WWW at the URLs given later and some form part of Microsoft's Visual J++ product.

4.8 Primary resources on Java

The most important URL for information about Java is:

http://www.javasoft.com

In particular, Sun's Java documentation is at:

http://www.javasoft.com/nav/read/docindex.html

A definition of the 1.0 language is at:

http://www.javasoft.com/doc/language_specification.html

A definition of the 1.0.2 API is at:

http://www.javasoft.com/doc/api_documentation.html

A definition of the 1.1 API is at:

http://www.javasoft.com/products/jdk/1.1/docs/api/packages.h tml

A Java tutorial is at:

http://www.javasoft.com/nav/read/tutorial.html

To download the JDK, use:

http://www.javasoft.com/nav/download/index.html

During Summer 1996, Sun had a forum for discussing Java at:

http://www.javasoft.com/forum/

Sun has produced a list of Java FAQs at:

http://www.javasoft.com/nav/read/faqindex.html

4.9 Other resources on Java

Another Java FAQ is at:

http://sunsite.unc.edu/javafaq/javafaq.html

A set of How Do I pages is available from:

http://www.digitalfocus.com/digitalfocus/faq

Some useful papers on Java from ICON Computing are at:

http://www.iconcomp.com/papers/

Cafe Au Lait contains news about Java. It is updated daily:

http://sunsite.unc.edu/javafaq/

Mentor Software Solutions has a weekly summary of Java news called DigitalEspresso at:

http://www.io.org/~mentor/phpl.cgi?DigitalEspresso.html

There is a weekly Java tutorial at:

http://netday.iworld.com/devforum/javajolt.html

IDG's monthly magazine about Java is available at:

http://www.javaworld.com

A list of press reports is at:

http://www.javaworld.com/javaworld/netnews/netnews.index.htm

There are lists of Java resources at:

http://www.gamelan.com

http://www.java.co.uk

http://www.december.com/works/java/info.html

http://www.rssi.com/info/java-info.html

The Usenet News newsgroups on Java are:

comp.lang.java.advocacy,
comp.lang.java.api,
comp.lang.java.announce,
comp.lang.java.misc,
comp.lang.java.programmer,
comp.lang.java.security,
comp.lang.java.setup and
comp.lang.java.tech.

A group called iJUGGL, the Independent Java Users Group for Greater London, has a WWW page at:

http://www.ijuggl.org.uk

The programming languages subcommittee of ISO has formed a Java Study Group. For more details, see:

http://www.dkuug.dk/JTC1/SC22/JSG/

4.10 Not just a programming language

Sun Microelectronics is producing a chip that can process Java bytecodes: picoJAVA. It will be suitable for cellular phones, printers and other consumer and peripheral markets. The microJAVA and ultraJAVA chips will be more advanced, e.g., handling graphics and multi- media. For more details, see:

http://www.sun.com/sparc/java/

Sun has produced JavaOS which provides a standalone Java environment, i.e., a processor does not need an operating system (other than JavaOS) in order to execute Java applications. It is currently available for sparc, x86 and ARM processors. See:

http://www.javasoft.com/products/javaos/

Sun has produced a network computer called a JavaStation. This is a disc-less machine that understands Java. So, it has no disc drives, no floppy, no CD-ROM, no slots and no jumpers. For more details, see:

http://www.sun.com/javastation/

The way in which Java is being deployed by companies such as BT is given at:

http://www.sun.com/javastation/customersuccesses/

5. Conclusions

It is nice to have a programming language that supports object-oriented programming, exception handling and concurrency.

Also, it is easy to build GUIs.

Many of the problems with the C++ language are avoided.

Programs are instantly portable across platforms.

The text of this paper is updated from time to time. The latest version is available at:

http://www.dur.ac.uk/~dcl0bjc/Java/

This WWW page also contains a tutorial (38 pages) on how to write Java programs.


Please Click Here to Return to Index at the Top of This Page

Teaching Java at Lancaster

Roger Garside
Department of Computing, University of Lancaster, Lancaster LA1 4YW
E-mail : rgg@comp.lancs.ac.uk


1. Introduction

The Department of Computing at Lancaster University decided to change its first year programming language to Java in the current academic year (1996-97), one of the first British Universities to do so. We are currently something like two- thirds of the way through the new course. This paper describes the structure of the course, and our experience with teaching the Java language.

The Computer Science degree at Lancaster is divided into Part I in the first year and Part II in the second and third year. It is a broad course in the central areas of computer science. In the first year, students intending to major in Computer Science study three subjects, one of which is "Computer Science 110". For their two other subjects they study a variety of disciplines, the most common being Mathematics, Engineering, Physics, and various Management courses. For the Computer Science 110 course students have three lectures a week over 25 weeks, together with a two- hour practical class and a one-hour tutorial each week. The lectures are:

a 25-lecture course (one per week) on programming, the subject of this paper

a 25-lecture course (one per week) on software design - this covers such topics as the software life-cycle, algorithms and data structures, efficiency of algorithms, abstract data types and object-oriented design, computability and formal languages. The course is designed as a more formal look at some of the topics covered from a practical viewpoint in the programming course. It was taken over by a new member of staff this year, so that it was re-designed from scratch to complement the introduction of Java.

a 20-lecture course (one per week in the first two terms) on computer systems - this is an introduction to basic computer architecture, microcode, machine code, language compilation, operating systems, input/output and communications.

a 5-lecture course on the applications and implications of computers in society.

2. Choosing a Programming Language

Over the years there have been a number of different choices for the introductory programming language at Lancaster, although it has up to now always been a language in the imperative tradition. Early choices were Algol 60 and then Pascal, with another language introduced in the second year such as Pop2 or Algol68. A change was made to Ada in the academic year 1990-91, the other possibility at the time being Modula 2. In the second year of the course C was taught in the computer systems architecture stream, and either Prolog or Lisp in the information and knowledge processing stream.

There were a number of reasons for changing over to Java in 1996-97. There was felt to be a need to make the change from Ada to another language more in the C tradition, to allow an easier transition to the use of C in the second year and because we had always had difficulty "selling" Ada to the students as an appropriate language in which to learn programming. There was pressure to change to C++, probably in the academic year 1997-98.

However, with the interest from 1995 in Java, we decided (in the early summer of 1996) to change to this as the introductory programming language, and to make this change immediately rather than wait to follow other Computer Science departments. The main reasons for making the change are:

the basic Java language is elegant and well-designed, and therefore well-suited as a vehicle for introducing programming concepts.

Java is object-oriented, so we would be able to introduce our students to object-oriented programming techniques right from the beginning of the course, but without the complexities of (say) C++.

Java provides the grounding in a C-like language, but "done right" with such things as strong typing, etc. We felt that this grounding would be useful in later parts of the course, and when students move into industry.

we hoped that the use of Java would engender enthusiasm among students, as it provides support for such things as graphics and what some students think computing is all about, namely the World Wide Web.

given Java's support for graphical user interfaces, network programming, multi-threading, etc., we envisaged that Java could provide support and a unifying element for many of the courses in the second and third years.

3. The Structure of the Course

The aim of the course is to develop the student's programming and problem-solving skills, and to introduce them to object-oriented programming and design. We wanted the students to start using object-oriented concepts right for the beginning of the course, so it was structured into five parts, each one approximately five weeks/lectures long:

using objects

writing objects

more advanced object features

more on using objects

object-oriented design.

The first part of the course introduced the basic ideas of programming in an object-oriented environment. Initially the students were given a Web browser, and encouraged to use it to explore the use of applets over the Web. This was followed by an introduction to object-oriented concepts and terminology, as far as possible using real-world examples. The first use of Java proper was for the student to manipulate a "Person" class which modelled simple facts about an individual, declaring instances of this class and calling methods to manipulate or extract the attributes of an instance. This was followed by the introduction of the basic selection (if, switch) and repetition (for, while) mechanisms in the language, using further manipulation of instances of the "Person" class as examples. Some of the Java primitive data types need to be introduced in an ad hoc way during this period, for example an "int" as a counting variable in a "for" loop, but they were then looked at in a more systematic way, contrasting features of the use of these primitive data types with the equivalent features of the use of objects.

In the second part of the course we started to discuss the internals of a class, by opening up the "Person" class which students had been using for several weeks. We introduced the basic ideas of instance fields, methods (including constructor methods), and class constants, also mentioning class (static) fields and methods. Up to this point all the instance fields had been either primitive data types or strings. At this point we introduced the idea of arrays, and then the possibility of an object containing an instance of another class (as an instance field, an argument or a return value), leading on to topics such as deep and shallow copying. The final section of this part was an example to illustrate how the various topics fitted together in defining and then using a class (a simple priority queue data structure, implemented with an array).

The third part discussed more advanced ideas of object- oriented programming, mainly the rather difficult and important idea of inheritance. This was followed by a brief discussion of abstract classes and interfaces; we had considered omitting the latter topic, but there are aspects of the Java class structure (such as for input and output) which require some understanding of this concept. The last section of this part of the course was an introduction to the Abstract Windowing Toolkit (AWT), which enables students to start to create their own graphical user interfaces with buttons, text and drawing areas, etc. This is a large subject (there are something like 40 to 50 classes in the AWT), so we gave only an introduction to some simple concepts and practical examples in this area. The AWT is also a practical examples of inheritance, from classes such as "Frame" and "Canvas".

The fourth part is a selection of topics covering more advanced use of objects in Java. We started with a discussion of how to create linked data structures, using as an example a re-implementation of the priority queue considered at the end of the second part. This was followed by a discussion of recursion; of input and output, going behind the local i/o classes they had been using up till that time; and an example of an applet with some simple HTML, linking back to the first examples they saw of Java programs. At the end we briefly considered the Vector and other data structures provided by Java, and the concept of threads. We do not attempt to get our students to a position where they are able to write multi-threaded programs at this point, but the concept is so central to Java that we felt that they should be aware that this topic exists (they will also have seen error messages from their programs which mention threads).

The final part is on object-oriented design. This is still being developed, but we plan to illustrate it with the development and then implementation of a reasonable-sized, realistic real-world example such as an electronic diary system.

4. Support for the Course

Because of the current financial constraints on university spending, we had to provide a hardware platform for the course which would be relatively cheap. The Ada practical course was run with a laboratory equipped with 18 or 19 PCs running MSDos and the Meridian Ada compiler. We utilised this basic hardware, but arranged for the PCs to boot up as Linux machines, connected directly to a Unix server machine in the Information Systems Services building. On this Unix server we run the Java Development Kit (JDK) version 1.0.2. This has a fairly rudimentary command-line interface, but it was all that was readily available at the beginning of the course. We will be investigating alternative development software for the next academic year. Many students nowadays have their own machines, and the department wished to encourage this use, so copies of the JDK and locally-written classes were made available on CDRom in the University library for students to borrow.

In order to get the students started we implemented a number of local classes:

the "Person" class mentioned above, as a simple example of data modelling

a class to provide methods to read the primitive data types from the keyboard, as this is too difficult in Java for the beginner.

a similar class to allow reading data from a file, so that reasonable sets of test data can be constructed and used early in the course.

a class to allow the student to specify the drawing of simple graphical shapes on the screen (without having to understand the full details of the AWT). This allows simple problems to be set involving selection or repetition to draw a sequence of boxes, or a series of concentric circles, with immediate visual feedback as to whether the arguments supplied are valid. We found this to be a successful scheme, and plan to extend it next year.

We provided on-line documentation for both the standard classes and those specially written at Lancaster, by providing links to a local copy of the Sun API and to a local API created with the "javadoc" program from the above classes. Students access this documentation with the browser, to which they were introduced in the first week of the course.

In the first term the students followed a series of graded exercises closely tied to the topics being covered in the lectures and tutorials. In the second term the students have a series of more general problems to implement, rather less closely tied to the topics being covered in the lectures, but covering inheritance, the AWT, the implementation of data structures, and so on. We plan that a similar series of problems will be set for the summer term, culminating in a group project (with three or four students to a group) to create a rather larger program, probably an applet of some sort.

As supporting material we are writing an introductory programming text for Java ("Java: First Contact" by Roger Garside and John Mariani: International Thomson Computer Press, due to appear Summer 1997), and have been giving out sections of this to the students every five weeks as the basic reference text. There are a number of other books on Java to which we have referred students for an alternative view, but they all tend to assume some background in programming.

5. Java as an Introductory Programming Language

We have found the Java language to be a good one to use as a first programming language, although it has a number of flaws. For example, the lack of enumerated types goes against the design principles we want to instil in the students, and Java inherits from C the flaws of the "switch" statement and the lack of a clear distinction between situations which call for use of the "for" statement and those which call for the use of the "while" statement. In later parts of the course there is a problem with lack of "genericity" in Java, so that, for example, elements extracted from a Vector have to be cast back to the appropriate class.

The second year of the course is being revised for the academic year 1997-98, and the opportunity is being taken to use Java as a unifying element, including for example:

programming with streams and sockets, in the communications and distributed systems stream

programming with graphical user interfaces, in the software engineering stream

advanced data structures and algorithms, in the fundamentals of computer science stream

We expect other language paradigms (Prolog, and perhaps a functional language) to be introduced during the second year to complement this use of Java.

We believe that the introduction of object-oriented programming from the beginning has been a success; students have perhaps taken longer to grasp the concepts than the equivalent structuring principles in languages taught in earlier years, because the concepts run right through the language, but have ultimately done so. The use of objects has allowed us to improve the examples of some of the early concepts, such as looping structures. The transition from considering only objects to considering the primitive data types as well has perhaps raised some difficulties, and will be reconsidered for the next offering of the course. We also expect to expand the number of different examples of objects and the concepts they model.

At the beginning of the course there were a number of teething troubles which are to be expected with the introduction of a new system. There is certainly greater student enthusiasm for the language, and a number of students have obtained copies of the JDK for their own machines.

We had to work to a number of tight deadlines for the introduction of Java as a new programming language for first year students, but we now feel that this has generally been a good experience and one which we can built on in later years.


Please Click Here to Return to Index at the Top of This Page

"Oh, by the way, Java is Object Oriented..."

Phil McLaughlin
School of Computing, Staffordshire University, College Road, Stoke-on-Trent ST4 2DE
E-mail: cmtpm@mail.soc.staffs.ac.uk


This article is based on the notes submitted to the CTI one day conference on 'Java in the computing curriculum'. The opinions expressed within are my own and not necessarily those of Staffordshire University. Any omissions or factual inaccuracies are also my own.

The Java phenomenon of the last 18 months has affected every part of the IT industry including education. It is clear that Java is an excellent OO programming language designed to incorporate the best features of many other OO languages and do away with the worst. Yet for all this some sections of industry and academia appear to be adopting Java in haste and the fact that Java is an OBJECT ORIENTED language and should be approached in a pure object oriented manner appears to have been overlooked.

It is my opinion that this attitude - unless corrected - could lead to serious problems. In common with several colleagues at several other UK universities I have been teaching OO as an independent subject for several years. I have taught OO at the Stoke site of Staffordshire University since 1992 using the Smalltalk environment which is significant for its 'pure object' approach which has also been adopted for Java. This experience has been valuable and has lead to a number of publications at conferences such as ECOOP and OOPSLA. In common with my UK and international colleagues I have come to see the teaching of an Object Oriented approach of paramount importance - considerably more significant than the implementation technology adopted, and yet Java as a programming language is just that - an implementation technology.

As recently as last year, Chandler and Hand (1996) reported on the current uptake of OO in UK universities reporting that only 27 out of 100 computing departments had responded to a survey asking about such issues. It is to be expected that many more are now contemplating adopting Java in some form or other. At the time this article was originally submitted I did not know of a UK institution that has adopted Java as its main programming language but I believed that this may well soon be happening and as it turns out more than one University has already made the switch and some have even been teaching it in academic year 1996/97.

What then of the rest of the computing curriculum ? It would be disastrous to teach structured methods of analysis and design at the same time as an object oriented programming language and yet this appears to be a realistic (from the point of view that it is actually happening ) option. This is an issue which must be addressed urgently. It is my belief that several UK institutions will be teaching Java as an introductory programming language form 1997 onwards, but what about the concepts and principles of object technology ?

I have long been an advocate of OO curricula such as Carlton in Canada where Smalltalk is taught as an OO approach in the first level and structured methods are then taught afterwards as a specialisation of certain aspects of the OO approach. I have been attempting to migrate the curriculum of my own institution towards OO as far as I could.

One of the fears I have is that a great deal of experience in teaching OO gained the hard way will be lost or ignored as there will suddenly be a large number of Java programmers teaching Java ' and after all as Java is an OOPL we must be teaching OOP'. Re-use (in this case of OO teaching strategies), will be neglected in favour of experience of the most fashionable language in the marketplace. There is currently a great deal of courseware appearing on web pages all over the world but it is very difficult to determine the effectiveness or the quality of the teaching materials and contradiction appears likely.

It is my opinion that if Java is to be used as an introductory programming language then object technology must be taught as a core theme in order to provide a theoretical underpinning. Failure to do so will lead to the worst of all worlds - teaching a procedural approach with an OO language . The best that could be hoped for is that students would be able to develop cute, dancing web appletts but at the same time lack full understanding of either the procedural or OO approach (not to mention good principles of software engineering). Opinion is considerably divided on this issue. Some maintain that OO should not be taught until students have some mastery of structured techniques and programming. I suspect that this concern is less significant than the need to teach a set of core OO skills if the students are expected to become competent with an OO language used in the core computer science and software engineering subjects.

If Java becomes the core language then OO must be taught as the central theme of the development curriculum covering all of the traditional areas addressed by software engineering education. It is clear that this could be done, however how many staff in computing departments are themselves fully conversant with the OO approach ? who will train them ? when will they have time to learn ? more importantly will they believe that the change is required or will they resist ? What about accreditation from bodies such as the BCS ? What about all of the non OO and hybrid systems and vendors ? How will existing sponsors of computing departments react ? What tools should be used and how much will they cost ? These are but some of the issues involved. They seem numerous but adopting Java - an OO programming language - as the core theme of UK undergraduate software development education will require momentous changes.

The worst scenario I can personally think of is the institution that adopts Java on the basis of its so far good press (and free availability) , ignoring potential clouds on the horizon, in the hope that students will be attracted to their institution because they are offering the latest technology (regardless of all the other institutions doing the same thing). It may happen that Java is thus adopted but that structured methods are still taught in analysis and design leading to considerable difficulties for the students. A simple example of the type of problem to be addressed come in teaching texts. Most of the current books describe Java 1.02. There are significant changes for Java 1.1 and yet if a University commits resources to book purchases early on, how will they be affected by future releases of the JDK ? One of the reasons for adopting an OO approach is to increase re-use - not having to make major revisions to texts and other materials every three months or so.

Rushing to adopt Java is in my opinion a poor move. Deciding to adopt a fully OO curriculum would be a much better move. This would not be easy (see for example McLaughlin et al 1995) but would at least allow for integration with and re-use of the considerable experience in teaching a 'pure objects' approach built up by those UK Universities who have so far amassed it. Such an initiative would be far more 'future proof' than the current curriculum allows but this is opinion again and is not universally accepted.

This an open ended debate. I see it as significantly more than the typical 'language war' debates that plague our profession from time to time. My personal solution is to adopt OO as the central theme permeating the computing curriculum as the best solution (thus making choice of language much less significant and allowing co-operation between communities of complementary languages) but this is far from universally accepted even by staff in institutions where OO is taught. Truly we live in interesting times.

References

Chandler and Hand, 1996,
Teaching Object Technology in Britain,
Proceedings of TOOLS '96

McLaughlin, P.N. Peglar, J. Lovegrove, G.L., 1995,
Object-Orientation and the computing curriculum: issues and solutions, in proceedings of TATTOO '95 (De Monteforte University, January 1995)

Related Publications

Lovegrove, G.L. McLaughlin, P.N., Hazards of Migration in Large UK Computing Departments, in proceedings OOPSLA' 95 (Object Oriented Programming Systems, Languages and Applications) ACM SIGPLAN notices, Vol. 30,. No 10, 1995, ISBN-89791-703-0

McLaughlin, P.N. Lovegrove, G.L., OO environments and design methods for use in undergraduate curricula, in Proceedings ECOOP '95 (AITO/ACM SIGPLAN European Conference on Object-Oriented Programming), Arhus, Denmark, August 1995

Lovegrove, G.L., McLaughlin, P.N. Chabik, J. Standen, P.,OO methods in teaching: current experience and future possibilities, 1994, in proceedings of ICSQP '94 (IFIP/SQI, Hong Kong, December 1994)

McLaughlin, P.N., Lovegrove, G.L., Issues in teaching object technology to joint honours undergraduates, 1994, in proceedings of Software Engineering in Higher Education (Wessex Institute of Technology, Southampton, November 1994)


Please Click Here to Return to Index at the Top of This Page

Not whether Java but how Java

Chris Wallace, Peter Martin and Bob Lang
Faculty of Computer Studies and Mathematics, University of the West of England, Coldharbour Lane, Frenchay, Bristol BS16 1QY
E-mail : Chris.Wallace@csm.uwe.ac.uk


1. Hard decisions

Everyone who has taught programming has agonised over difficult curriculum design questions. Most prominent is the question of first language choice, a matter still undecided by the great and the good in computer science education these past 40 odd years. Fewer words have been expended on questions of curriculum structure: is a programming language to be learnt separate from or together with program design; should specification be introduced before/after/with implementation; what is the appropriate balance between programming in the large and programming in the small; teach one large language or many small languages? The position we each adopt on these questions depends on a range of contextual issues; on the ability and expectations of our students and staff; on what we believe good programming is ; on how the skills, knowledge and motivation of programmers is best acquired.

The report on the Open University Workshop on language choice held in September 1993 (Woodman 1996) makes salutary reading in this regard. It is noticeable that the exclusive focus of the bulk of the essays is on the languages themselves as artefacts: their syntax, semantics and the programming styles they enable. There is seldom a mention of the learner; her needs, her conceptual development, her motivation. Nor is there much evidence of reflection on the end-point of what constitutes expert performance in the programming task, seen not only as the process of constructing logically sound symbolic systems but also artefacts which satisfy human and economic needs. The attempts at 'scientific' treatment of the language choice question often, as a result, appeared to be window-dressing on a more complex set of ill-grounded beliefs and shared cultural prejudice.

2. Whether Java?

Reviewing the straightforward technical comparison, it appears to me that, had the conference been held now, Java would have been the choice of over half the authors. Many were forced reluctantly to adopt C++, despite its lack of garbage collection, mixture of value, pointer and reference semantics and general trickiness. Java has removed most of C++'s disadvantages, and Java 1.1 will remove more, albeit at the expense of a more complex language. Java syntax is close enough to C to help when students need to use C - particularly for interfacing to legacy systems. Unfortunately some poor syntax has been carried over in to Java too but nothing that cannot be lived with.

Other authors, such as Woodman at the Open University, chose Smalltalk. I was particularly struck by one sentence: 'If developments in the financial sector are anything to go by, then Smalltalk could be tomorrow's language' Sadly not. I myself hold Smalltalk in great affection, and am teaching it now to 130 second year computing students, perhaps for the last time. They love the environment at the present but the lack of code management (in Smalltalk Express) will annoy them in the end. Packages are essential, not just for project sanity but, by providing a tangible distinction between the student's work and Parcplace/Digitalks, for pride of accomplishment. Java's advantages of integration of concurrency and error handling, distinction between type and class via Interfaces and its widespread use in distributed systems would outweigh for most teachers the appeal of the uniform object model of Smalltalk.

3. If Java, then how?

Given both the difficulty of rational language choice, and the rough analysis that Java would now be a popular choice, based on the criteria suggested by various authors at the OU workshop, we should shift our attention from the whether Java question to the if Java, then how question.

One paper at the OU workshop (Petre, 1996) does attempt to broaden the question from technical considerations by reflecting on observations of expert programmer behaviour. While the whole paper warrants reading, I shall only quote her concluding implications for the teaching of programming and the training of programmers.

emphasize programming cultures, not programming languages;

support paradigm shifts; teach reasoning styles as selectable tools;

cultivate strategy and abstraction skills;

decouple solutions from coding;

cultivate readership and reflective programming;

recognise the importance of secondary notation;

provide operational information;

choose a genuine general -purpose language;

if you provide training wheels, remember to take them off;

foreshadow professional practice

Academic leaders face other problems too in changing languages, such as staff development, material development, and choice of teaching environments, but I believe it would be helpful to keep these pedagogic issues in mind as we wrestle with the problem of curriculum design.

4. The UWE modular Programme.

The Faculty of Computer Studies and Mathematics runs an undergraduate modular programme of awards which range across the spectrum of Business Decision Analysis, Information Systems, Computer Science and Computing for Real Time systems. HND and Honours Degree awards are part of the programme which has an intake of some 400 students each year. Students take the equivalent of six full modules each year, but for computing students, the curriculum is divided into term length half-modules. Currently none of the awards require A-Level or OND computing although about two-thirds of the current cohort do have prior computing studies.

This programme is being reviewed after having been in operation for four years. In the revised scheme we want to strengthen the mainstream computing awards by requiring some basic computing practice prior to entry. Ab initio students may also take the same module but require to take an additional bridging module. Information systems courses such as the long-established degree in Systems and Analysis and a new course in Business Information Systems are moving away from teaching programming altogether. Mathematics awards have the same problem over first language choice for their students. Currently this is Fortran but they would like to move to a language which supports symbolic manipulation and Maple is currently preferred.

For the computing awards, we are taking the opportunity to revisit the choice of first programming language, which for the past six years has been Modula-2. Teaching of introductory programming is currently split into a number of half-modules totalling 2 full modules. Language teaching in Modula-2 is one half-module, the teaching of program design, currently functional decomposition with pseudo-code, another. The two are coupled by a common problem set, and solutions are expected to be designed in pseudo-code before implementation in Modular-2. Second term half-modules expand on the language development and on program design. Most students will also take a half-module in Formal Specification, using Z.

This fine-grained design is being replaced by two full modules in the revised programme. One in 'programming in the small' is a combined language and design course aimed at developing single -language systems. It is for this module that Java is being considered as the replacement for Modula- 2. Some aspects of formal specification are required to be included, particularly pre-conditions, post-conditions and invariants.

The other module adopts a 'programming in the large' approach which tackles the design of systems running on multiple platforms with multiple languages, reusing or customising existing software resources. Here we expect to introduce the students to Perl and develop intranet applications. The two modules come together when Java applets are incorporated in the intranet applications. In this module we also teach notations for, first describing and then prescribing the structure of complex software and communications systems.

The other first year modules are computer systems architecture, analytic modelling, a module specific to the award and an elective module from some other Faculty such as Business, Art Media and design or Modern Languages.

In the second year, there are further core modules in software engineering, software design, data structures and databases and operating systems and networks in addition to further award-specific modules. In the final year there is a wide range of optional modules in computing specialities alongside a 2-module individual design project.

5. Java at UWE

It is always with some reservation that the thorny question of first language choice is raised. It is however noticeable that, once Java was proposed, staff were more interested in questions of what this would mean for teaching than on debate about that choice. There is of course some anxiety about a new language, particularly in the face of increased pressure on our time through 'efficiency cuts' and increasing quality demands.

Our approach has been to prototype the delivery of a first year Java course by changing from Smalltalk to Java on one version of a second-year half-module on object oriented development. Our HND stream is, this term, based on Java whilst the degree students remain with Smalltalk.. The groups are of unequal size - 60 HND students and 140 degree students. Although the two groups are not closely matched, and there is inevitably a element of Hawthorne effect with this new initiative, it will nevertheless be interesting to see how the two groups compare in the understanding of object-oriented concepts by the end of the modules. The four Java practical sessions are tutored by the lecturers who currently teach Modula-2 in the first year. We hope that this approach will provide some staff development as well as experience in the practical difficulties of Java teaching before we have to tackle the problem of 200 first-year students. We will also provide an in-house course during our staff development week at Easter.

Although the problems encountered in a second level course covering object-oriented concepts are clearly different from those likely to be encountered in a first level course on introductory programming, there are a number of issues in common, and if, as is our present intention, object- orientation is to be introduced in the latter part of the new first-level course, the efficacy of Java

as a vehicle for the teaching of basic OO concepts remains important.

Experience gained so far, and we are only three weeks into the course, would suggest that Java is a more accessible language

for a first level course than either Smalltalk or C++. However, a number of issues have been raised and are discussed briefly below :-

Availability of suitable and affordable text books.

Availability of programming environments for home use.

Compile time performance for large group working.

Compile time diagnostics and debugging tools.

Support for simple I/O on the one hand and GUI development on the other.

Suitability as a vehicle for other paradigms.

Language features and relationship to other languages.

Student expectations.

Taking these points in order, the first problem encountered was that of finding a text book which adequately addressed the OO concepts and the use of Java in application development. Many of the extensive array of Java texts that have leapt onto the bookshelves are poorly written, contain numerous typographical errors, spend an undue amount of time illustrating the development of Applets and concentrate on images, sound and animation at the expense of object- orientation.

The major drawback of Java for student home use is the need for Windows-95, but our feeling on this is that the problem will go away quickly as the average student machine configuration improves.

Compile time performance is important when using a networked system with large practical groups and we are currently conducting some comparison trials between Modula-2 and Java. On the positive side, the compile time diagnostics, whilst not guaranteeing to catch all class usage errors, does produce helpful diagnostics. The existence of language sensitive editors which allow compilation within the editor also serve to shorten the edit-compile-correct cycle.

One of the most obvious shortcomings first encountered with Java is its lack of provision of simple numeric input and formatted output when used in a simple VT100 mode. Correcting this is simply a matter of providing the necessary sub-classes or extensions to existing classes and it does seem strange that this has not been done.

On the other hand, the support for GUI's is good, given the constraints imposed by the need for platform independence and windows based application development, even without the help of a GUI builder is not beyond the capabilities of first level students.

One motivation for using Java as a first language is the teaching possibilities it opens up, not just for programming in the large, but for supporting the study of other paradigms such as concurrent programming, networking and distributed programming, data bases and of course the more traditional procedural approach adopted in structured programming.

The syntactic similarity between C, C++ and Java is at once an advantage and the cause for some concern. The benefit of this similarity lies in the ease of moving between these languages given the need our students have to program in C and C++ in more specialised modules at level 2 and 3, such as Image processing, graphics, embedded systems development etc. The unfortunate consequence is that a number of unsatisfactory features of C have been inherited - such as the switch statement, the use of break and continue and the absence of an enumerated type. On balance however, the elimination of the more dangerous features from C and C++ and the adoption of a fully dynamic model for objects eases the understanding of OO concepts.

One problem encountered early-on in the current course was dealing with the often unreasonably high expectations that students have, due to the amount of hype currently attached to Java, of being able to develop GUI's with animation and sound easily. Although it is undeniable that such programs can be hacked-out quickly, they are not as simple as might be expected for novices and if adopting a disciplined and professional object-oriented approach to software development, do not reasonably appear until quite late in a course.

One aim of the current Java course was to make use of graphics at the earliest opportunity. But to do this in any context other than a paint program development, requires the use of an MVC approach if misconceptions are to be avoided. Luckily, Java supports MVC quite well but this is clearly in the realms of the more advanced topics covered.

6. Program design paradigms

Although there has been some debate about the syntax of Java, there is much more concern about what the change means for the teaching of program design approaches. In the current programme, students start with top-down functional decomposition using pseudo-code. Depending on the specific award and student choice, students will encounter formal specification with Z, JSP, object-orientation, concurrent programming, functional and logic programming. Each paradigm has its own group of adherents within the faculty. Given these competing paradigms, there is potential for tension in the change to Java. The choice of Java does not of itself solve the more fundamental problem of the scheduling of the teaching of program design paradigms. Java has the capability of reducing the number of languages which students encounter but will not eliminate the need for other languages.

7. Comparative examples

I have always taught object orientation by starting from problems which are biased towards the paradigm, believing that this provided the best way to convert mind-sets. This year, driven more by the programme review than any change of heart, I started from an existing problem set chosen as suitable for a functional decomposition approach. Students had already encountered these in year 1. So that the Smalltalk students should not feel left out of the Java revolution, model answers were also provided in Smalltalk, together with the Modula-2 specimens.

8. Armstrong numbers

The first problem is used as a worked example in the present program design module. The problem is to decide which integers have the property of being equal to the sum of their digits raised to the power of the units, called Armstrong numbers.

Appendix A explains the problem and provides solutions in Modula-2, Java and Smalltalk.

Both the Java and Modula-2 programs adopt the same paradigm of procedural abstraction. Curiously neither of these solutions follows directly from the pseudo-code of the worked example, since this does not use procedural abstraction, presumably because it is thought to be too early in the course for this concept to be introduced. Indeed the suggested monolithic solution, by intertwining the computation of the Armstrong property and the counting of the numbers, makes procedural abstraction less likely.

The Smalltalk solution shows the power of a pure object language in which existing base classes can be extended and expressions executed directly. The implementation of integers of unlimited size is ideal for exploratory programming. It shows too the power of collection classes and closures in closing the gap between problem and solution. This kind of solution is not possible in Java because integers are not objects, and even if they were, compiled classes can only be extended by subclassing. I shall miss it.

But beyond these differences lies much commonalty. Any solution to this problem must draw on the basic concepts of sequence, iteration and selection, arithmetic operations such as +, * , mod and div, the idiom of iterative modification , the algorithm for reduction of a number to its digits and the generalisation of a three-digit number to an n-digit number. A good solution should also include procedural abstraction and, despite syntactic differences, all the languages enable this solution. We must ensure that students have the opportunity to develop clear understanding of these basic concepts, idioms and design strategies, whatever programming language is chosen. We must not lose sight of these more general mental tools in our enthusiasm to tackle exciting problem-centred programming, be it interactive applets or symbolic mathematics.

9. Snakes and Ladders

The problem set for the first year course concludes with a choice of this problem, in which a game of snakes and ladders is to be simulated, or the computation of a calendar for any month. Appendix B shows solutions to this problem in Modula-2, Java and Smalltalk. The solutions differ in the user interface provided and in the granularity of objects.

Here the advantages of Smalltalk over Java have diminished. Java in providing a package structure (not used in this example) provides a better means of separating user code from reused code. Indeed the Smalltalk solution is incomplete since the Random class used is not a base class but one I had written and then forgotten. Code management tools ease this problem but are an extra layer of complexity for Smalltalk.

Smalltalk collection classes provide a advantage in ease of use of Vector and Enumeration and string handling is easier, but the

real problem for a programmer lies in the structuring of the objects and their interrelationships. However much more time is spent, even by an experienced OO programmer on such issues as:

granularity

What are the objects? are squares, snakes and ladders, moves objects? In the Smalltalk solution I have squares as elements of an array, snakes and ladders as integers. Moves are objects in the Smalltalk solution but not in Java, merely because I was further down the track of putting a GUI on the Smalltalk model. These decisions will always be hard, even in a pure object language and we must not trivialise the difficulty by subscribing to the notion that finding objects is easy.

visibility

which objects know about which other objects? Here I have been driven to an unnatural position - that the game exists as an object which can 'see' everything, that a player can see the board but not the other players etc. Not much help from the problem structure here either.

allocation of behaviour

who throws the die? I have the game throwing the die and telling the player what the result was. I could objectify the die and pass it to the player to throw. No obvious choices here either.

All too easily we have passed in to a world of undecidable issues. We might appeal to the ease with which the objects can be reused, but this merely introduces the need to envisage an imaginary world of future games builders to decide on how to divide the overall behaviour into fragments which can be individually overwritten whilst still making sense of the whole.

10. Conclusions

Both the procedural and object oriented paradigms are essential parts of a modern education in computer programming. We must not think that, in finding that Java can provide satisfactory solutions to the implementation of both styles, we have thereby avoided the need, on the one hand, to pay proper attention to basic concepts, programming idioms and algorithms, and on the other to recognise the real difficulty of applying these styles to even apparently simple problems.

I would propose that the object oriented features of Java be kept in check until the basics of procedural abstraction have been laid. Objects cannot be avoided entirely and careful choice of problem set will needed.

11. References

Petre, Marian(1996)
'Programming Paradiigms and Culture: Implications of Expert Practice' in (Woodman , 1996)

Woodman, Marked (1996)
Programming Language Choice: Practice and Experience, Thompson Computer Press

Appendix A - Armstrong Numbers

A.1. The problem

An Armstrong number is calculated by taking a number, raising each digit to the power of the final digit and summing the result. If the result of this computation is equal to the original number, the original number is an Armstrong number. For example, given the number 153:

1 raised to the power 3 = 1
5 raised to the power 3 = 125
3 raised to the power 3 = 27

1 + 125 + 27 = 153

153 is therefore an Armstrong number.

Write a design for a program to list all the Armstrong numbers in the range 1 to 200 inclusive. In addition, the program should report on the number of Armstrong numbers that have been detected.

A.2. Modula- 2

written by Bob Lang

1.MODULE Armstrong;
2.FROM InOut IMPORT
3.WriteString, WriteCard, WriteLn;
4.CONST
5.MinTestNumber = 1;
6.MaxTestNumber = 200;
7.
8.PROCEDURE CardPower (Val, Exp: CARDINAL) : CARDINAL;
9.VAR
10.Result, (* The final result *)
11.i (* Loop counter *)
12.CARDINAL;
13.BEGIN (* CardPower *)
14.Result := 1;
15.FOR i := 1 TO Exp DO
16.Result := Result * Val;
17.END (* For *);
18.RETURN Result;
19.END CardPower;

20.PROCEDURE IsArmstrong (Number: CARDINAL) :

BOOLEAN;
21.VAR
22.TempNumber, (* Working copy of input
parameter: Number *)

23.LastDigit, (* Last digit of number being

tested *)
24.NextDigit, (* Current digit of number being
processed *)
25.Sum: (* Sum of accumulated powers *)
26.CARDINAL;
27.BEGIN (* IsArmstrong *)
28.LastDigit := Number MOD 10;
29.IF LastDigit <> 0 THEN
30.TempNumber := Number;
31.Sum := 0;
32.WHILE TempNumber > 0 DO
33.NextDigit := TempNumber MOD 10;
34.TempNumber := TempNumber DIV 10;
35.Sum := Sum + CardPower (NextDigit,
LastDigit);
36.END (* While *);
37.RETURN Sum = Number;
38.ELSE
39.RETURN FALSE;
40.END (* If *);
41.END IsArmstrong;

42.VAR
43.TestNumber, (* The number being tested for

Armstrong-ness *)
44.Count: (* How many Armstrong numbers have
been found *)
45.CARDINAL;
46.BEGIN (* Armstrong *)
47.WriteString ("This program produces a list
of Armstrong numbers between ");
48.WriteCard (MinTestNumber, 1);
49.WriteString (" and ");
50.WriteCard (MaxTestNumber, 1);
51.WriteLn;
52.WriteLn;
53.Count := 0;
54.FOR TestNumber := MinTestNumber TO
MaxTestNumber DO
55.IF IsArmstrong (TestNumber) THEN
56.WriteCard (TestNumber, 6);
57.WriteString (" is an Armstrong number");
58.WriteLn;
59.INC (Count);
60.END (* If *);
61.END (* For *);
62.WriteLn;
63.WriteString ("There were ");
64.WriteCard (Count, 1);
65.WriteString (" Armstrong numbers found.");
66.WriteLn;
67.END Armstrong.

A.3. Java

Written by Chris Wallace

1. public class Armstrong {

2.

public static int raisedToInteger(int
val,int power) {
3.
int result=1;
4.
for (int i=1; i<=power; i++) {
5.
result *= val;
6.
}
7.
return result;
8. }

9. public static boolean isArmstrong(int

number) {
10.
int tempNumber, power, digit, sum ;
11.
power = number % 10;
12.
if (power != 0) {
13.
tempNumber = number;
14.
sum = 0;
15.
while (tempNumber > 0 ) {
16.
digit = tempNumber % 10;
17.
tempNumber = tempNumber/ 10;
18.
sum +=
Armstrong.raisedToInteger(digit,power);
19.
}
20.
return sum == number;
21.
}
22.
else
23.
return false;
24.
}

25.

public static void testRange(int min, int
max) {
26.
for (int i=min; i <= max; i++ )
27.
if( Armstrong.isArmstrong(i))
28.
System.out.println(
String.valueOf(i) + " is an
Armstrong number");
29.
}

30.

public static void main(String args[]) {
31.
try {
32.
Armstrong.testRange(1, Integer.parseInt(args[0]));
33.
}
34.
catch (NumberFormatException e) {
35.
System.out.println(args[0] + " is
not an integer.");
36.
}
37.
}
38. }

39 > java Armstrong 200

A.4. Smalltalk

Written by Chris Wallace.

Integer instance methods

2. armstrongTotal
3.

| num digit power sum |
4.
num := self.
5.
sum := 0.
6.
power := num \\ 10.
7.
(power ~= 0) ifTrue: [
8.
[num ~= 0 ] whileTrue: [
9.
digit := num \\ 10.
10.
num := num // 10 .
11.
sum := sum + ( digit
raisedToInteger: power) .
12.
].
13.
].
14.
^ sum

15. isArmstrong
16. ^ self armstrongTotal = self

Execute in the Transcript Window:

17. (1 to: 200 ) select: [ :i | i

isArmstrong ]

18. ( 1 to: 200) select: [:i | i factorial

isArmstrong ]

Please Click Here to Return to Index at the Top of This Page

Java as a First Language?! (JFL)
Report on the workshop held at the 4th All Ireland conference on the Teaching of Computing

Fintan Culwin
School of Computing, Information Systems and Mathematics, South Bank University, 103 Borough Road, London SE1 0AA
E-mail : fintan@sbu.ac.uk


Over sixty people attended this workshop and 25 questionnaires were returned. The results of the workshop are summarised as follows.

1. The features table

The features table from the workshop is given in Table 1 below. For those who were present: a cross has been coded as 0, a bracketed cross as 1, a bracketed tick as 2, a tick as 3 and a tick plus as 4.

The IDE feature has been removed from the table as the outcome indicated that a relatively low cost environment was available for every language.

In the notes which follow I have largely resisted the temptation to add any comments which were not made by attendees. Where I have succumbed my comments are indicated in curly braces {}

Static type checking refers to the ability of the environment to determine that the actual parameter supplied is incompatible with the data type of the formal parameter.

Purity refers to the strength of the object model within the environment. Java obtained a 2 as although a main() action cannot exist outside a class (object) definition, the class definition need only be a token wrapper.

Multiple inheritance refers to the ability to define a new class as an extension of more than one parent class, inheriting data attributes and actions from all. {On reflection Ada 95 and Java should have got at least 1 as there are techniques by which the beneficial aspects of multiple inheritance can be implemented without the detrimental aspects. In Java this is syntactically light weight, in Ada 95 it is heavy weight}.

Language standard refers to the availability of a written definition of the language's syntax and semantics. Only Ada '95 has an ANSI/ ISO standard, {so it should have got a 4}.

Lexical complexity was operationally defined as the ease with which a non-trivial program, for example more complex than hello world, can be implemented.

Generics refers to the ability to separate an algorithm from the data type which it will operate upon. For example a generic sort algorithm can be instantiated to sort a list of integers, or floats, or strings or any other data type.

Operator overloading refers to the ability of the developer to provide additional meanings of common operators and to use them in infix notation. For example a developer declared data type called foo may have an addition operator defined for it, allowing the developer to write foo3 := foo1 + foo2.

Assertions refers to the ability of the language to make logical statements about the semantics of an action and to enforce them. For example an action to compute a square root may have a pre-assertion that the number whose square root is to be computed must be greater than or equal to zero, and that the computed value times itself must be approximately equal to the value whose square root is required.

Table 1

Exceptions refers to the ability of the language to interrupt the expected flow of control in response to some occurrence. This may be an implicit occurrence (for example dividing by zero) or an explicit occurrence (for example two input values being incompatible). The interruption in the flow of control is indicated by the throwing of an exception which will propagate up the call stack looking for a suitable exception handler. The advantage of this facility is to separate the code which handles exceptional conditions from that which implements the routine processing.

2. The criteria tables

The analysis of the criteria table is given below. Table 2 indicates the number of people who expressed an opinion on each of the weighting criteria, the average weighting given to the criteria and the standard deviation of the distribution. For clarity the marks have been scaled from a 0 (unimportant) to 10 (overriding importance) scale to a 0.0 to 1.0 scale.

The standard deviation is included to give an indication of the degree of consensus on the weighting factor. Thus safety has a small standard deviation indicating the greatest degree of agreement between the attendees, GUI has the largest indicating the largest degree of disagreement.

Table 2

Table 3 indicates the number of people who expressed an opinion on each language and the un-weighted average opinion for each criterion.

Table 3

Table 4 is the weighted opinions for each language which had more than one response.

Table 4

{I was surprised at the degree of consistency between the overall weighted and un-weighted averages. If I had been asked to predict the outcome before the workshop I would have thought that the disagreement would have been greater.}

de facto: This criterion was the existence of a de- facto or de-jure standard for the language.

use: This criterion was the extent and/or significance of the use of the language in 'the real world'.

GUI: This criterion was the suitability of the language for the construction of Graphical user Interfaces.

curve: This criterion was the steepness of the learning curve for the language.

cost: This criterion was the student cost of suitable development environment.

base: This criterion was the suitability of the language for use after the first software development course. The inverse of this criterion would have been the extent to which it is a throw away language.

cred: This criterion was the street credibility of the language with the students.

safe: This criterion was the safety of the language, defined as the extent to which it isolates the student from the underlying machine hardware.

debug: This criterion was the availability and ease of use of debugging tools for the language.

stab: This criterion was the stability of the language specification.

extend: This criterion was the ease by which a class could be extended.

book: This criterion was the availability and suitability of text books.

gpp: This criterion was the extent to which the language supports pedagogy by encouraging good programming practice.

3. Other Questions and Comments

Attendees were also asked to name the languages which they currently use for their first software development course and to name the language which they would favour. The results are shown in Table 5.

Table 5

Attendees were also invited to express any other comments. These are collected below.

(Verbal) The real issue is not which language, but which paradigm and what pedology.

I don't care whether it is a standard as a 1st language I want to get basic concepts across which are transferable. If the students want to learn a specific language then given the basic concepts- they can pick it up themselves. I am into education not training. (But C is going to be forced upon me as the students want to get jobs!)

My first year students are pushed to do some basic stuff, never mind the OO concepts.

If teaching/learning OO is the objective we wish then a pure OO language is essential if students are not to bring old procedural ideas and confuse themselves.

For a first language system two interrelated factors are significant. Size - i.e. of the language, for students to grasp without getting lost or bumping into the unexpected. Environment quality in terms of how the system responds to them. Full Ada would be a counter example - the compiler may diagnose errors that mean nothing to them, even after weeks of trying.

What really worries me is the butterfly effect of flitting to the next new language.

Heavy Ceilidh user so we would need to get a Ceilidh interface for any change.

I favour a very simple language because any language will limit your thinking and because our students will have to learn new languages during their course. I want the students exposed to more than 3 languages during their university education.


Please Click Here to Return to Index at the Top of This Page
[Return to How to get Monitor]