2. Origins

Part of CS:2820 Object Oriented Software Development Notes, Spring 2017
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

 

Origins of Object Oriented Programming:

The idea of object-oriented programming was born in two different domains, independently and around the same time in the mid 1960s:

A group of programmers working on discrete-event simulation Oslo, Norway developed the idea of objects, classes, class hierarchy and almost all of the other key concepts of object-oriented programming in the mid 1960's. They came at this from thinking about discrete event simulations, mostly as applied to logistics. If you are moving materials from here to there, you have trucks to move things, but there are different classes of trucks each with different attributes. Semi trucks and pickup trucks are both types of trucks, but you can detatch the trailer from a semi, while you cannot detatch the cargo area of a pickup (ignoring the possible use of a chainsaw on a modern aluminum truck).

This group, led by O.J. Dahl, developed a simulation language called Simula while they were working this out, and as they finally came to understand the consequences of their ideas, they created a distinctly new language called Simula 67 (the target release date was 1967, but since this is software, they were late).

Simula 67 was not a simulation language, it was a completely general purpose object-oriented programming language, the very first of its kind. We get essentially all of our standard terms for object-oriented programming from Simula. Some people have gone so far as to describe Simula 67 as an improvement over most of its successors.

The other important group in this story was a group led by Christopher Strachey at Cambridge University in England. Strachey was as much a theorist as a practical programmer. His group designed a programming language called CPL (there is disagreement about whether the C stood for Christopher's or Cambridge or Combined, but PL stood for Programming Language). Nobody ever succeeded in implementing CPL, but a student implemented a subset called BCPL (Basic CPL).

One of the things that Strachey's group explored was the use of BCPL as an operating system development language. It is important to know that BCPL was not object oriented in any way. It was very primitive, but unlike other languages of the era (with the exception of assembly language), it allowed people to invent just about any kind of programming model they wanted. As Strachey and his associate Joseph Stoy developed a toy operating system called OS6, they discovered the basic ideas of objects, applying them primarily to I/O streams, where all kinds of I/O were implemented essentially as subclasses of a common stream interface class. They did not have object-oriented terminology, but they had the idea.

A group at Bell Labs in Murray Hill, New Jersey seti out to build a new operating system in the late 1960s. They called it Unix, and they were quite interested in BCPL, enough so that they built a new implementation for it that they named, simply, B. The B project and the first version of UNIX were married when they wrote a new compiler that (naturally) they called C and used it to rewrite UNIX. The internals of Unix, particularly, those involved with input/output, have a strong object-oriented flavor despite the fact that there is no support for objects in C.

When Bjarne Stroustrup, an experienced Simula 67 programmer, was hired by the Unix group at Bell Labs, he was sufficiently annoyed by the lack of support for objects in C that he wrote a C preprocessor that he called C++ that extended C with the features of Simula 67 that he liked. Originally, this was just his way of producing code in C (policy required that) without having to write in a language he considered inadequate.

By 1980, C++ began its spread outside of Bell Labs and the Unix world. Two things contributed to this: One was BSD Unix, the first version of Unix supported on the then best-selling 32-bit mainframe of the era, the VAX 11/780 made by Digital Equipment Corporation. We bought one here at the University of Iowa, and we ran Unix on it, and the story was very sinilar around the world. The second thing was the GNU C++ compiler, the most important of the early ventures in open-source software development.

At Sun Microsystems in the early 1990s, James gosling was not happy with the C foundation of C++ and set out to strip away the mistakes that C++ had inherited from C and produce a lightweight language called Java. This had two main selling points: First, it looked like C++ so programmers who knew that language could move to Java with minimal "culture shock." Second, many of the dangerous features of C were disabled. Some early wags described Java as being C++ with training wheels.

Java

So what is Java? Here is the classic Hello World program in Java:

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

It hardly seems worth the effort to add comments to such a minimal program, but we will always add a minimum of commentary to all of our programs. The bare minimum is something like the following:

// HelloWorld.java
/**
 * Program to output Hello World to standard output
 * @author Douglas W. Jones
 * @version 1/22/2016
 */
public class HelloWorld {
        public static void main(String[] args) {
                System.out.println("Hello, World.");
        }
}

Here, we prefix the file with a one-line comment giving the expected file name. If you have lots of files open on screen, it's a good idea to have the content of the files identify themselves. The second comment is a formalized comment directed at standard documentation program called Javadoc. This gives a description of the program followed by the name of the program's author and the date it was released.

Use a text editor to create this program and then run it.

Hello world is not a very interesting program. Here is a more interesting one. it prints successive members of the Fibonacci series to standard output:

// Fibonacci.java
/**
 * Program to print successive Fibonacci numbers to standard output
 * @author Douglas W. Jones
 * @version 1/22/2016
 */
public class Fibonacci {

        /**
         * Recursive function to compute the i'th Fibonacci number
         */
        private static int fib( int i ) {
                if (i < 2) return i;
                return f(i - 1) + f(i - 2);
        }

        /**
         * Main program
         */
        public static void main(String[] args) {
                int i = 0;
                while (true) { // compute successive Fibonacci numbers
                        System.out.println( "f(" + i + ")=" + f(i) );
                        i = i + 1;
                }
        }
}