This series, The Object-Oriented Thought Process, is intended for someone just learning an object-oriented language and wants to understand the basic concepts before jumping into the code or someone who wants to understand the infrastructure behind an OOP language they are already using. Click here to start at the beginning of the series.
In keeping with the code examples used in the previous articles, Java will be the language used to implement the concepts in code. One of the reasons that I like to use Java is because you can download the Java compiler for personal use at the Sun Microsystems Web site http://java.sun.com/. You can download the J2SE 1.4.2 SDK (software development kit) to compile and execute these applications and will provide the code listings for all examples in this article. I have the SDK 1.4.0 loaded on my machine. I will provide figures and the output (when appropriate) for these examples. See the previous articles in this series for detailed descriptions for compiling and running all the code examples in this series.
In the last column, we explored the components of a class—which is the basis for all object-oriented development. The class is the fundamental object-oriented unit. All objects are created from classes, so it important to understand the structure of a class. Improperly designing a class will have negative effects throughout the development process. In fact, it is the design of classes that has fueled the development of various object-oriented languages. Many people are surprised to learn that several popular languages are not actually object-oriented (like C++ and VB 6)—they fall into a category called object-based. In the case of C++, you can actually create an application that conforms to object-oriented principles; however, a C++ compiler must be able to compile C syntax—and C is definitely not an object-oriented language. Thus, the C++ compiler does not enforce object-oriented design.
In this article, we will explore the history and evolution of object-oriented languages so that you will have a better understanding of what makes an object-oriented language tick. Surprisingly, although many people believe that O-O technologies are fairly new, O-O languages have their origins in the early 1960s. In fact, much of the history of structured and O-O programming overlaps to some degree.
What really makes a programming language an O-O language? And when did the O-O movement really start? Many people point to the early 1960s as the time when Simula-67 introduced the concept of an object.
As the name implies, Simula was created to aid in simulations. It is not a coincidence that simulations typically model real-world systems. Many of these real-world systems contained hundreds, or thousands, of interacting parts. We will follow O-O language evolution through the discussion of several O-O languages. Many point to Smalltalk as the first pure O-O language. Interestingly enough, C++, perhaps the first major commercial O-O success, is not truly O-O. And finally, you will learn why Java was released with such fanfare and what makes its proponents consider it a complete programming language package.
By the 1960s, programmers realized that programming systems needed to be broken up into small, manageable pieces. The introduction of Simula-67 brought with it the first true programming object, classes, and a form of inheritance; therefore, Simula is an important milestone in any discussion on O-O programming languages. The language was designed by Dahl, Myhrhaug, and Nygaard at the Norwegian Computing Center at Oslo, Norway. The initial version of the language, Simula-1, was introduced in 1966. The programming modules defined by Simula were based not on procedures, but on actual physical objects. Simula had a novel way of presenting the object, so that each object has its own behavior and data.
Many consider that the first truly O-O language was Smalltalk, developed at the Learning Research Group at Xerox’s Palo Alto Research Center in the early 1970s. In Smalltalk, everything is really an object that enforces the O-O paradigm. It is virtually impossible to write a program in Smalltalk that is not O-O. This is not the case for other languages that support objects, such as C++ and Visual Basic (and Java, for that matter).
|C++ and Java Are Not Purely O-O|
|C++ has O-O features, but you can use non-objects in C++. Java is mostly O-O, but the primitive data types, such as integers and floats, are not implemented as objects.|
Smalltalk is actually much more than a programming language: It is a programming environment. In fact, Smalltalk is an interactive environment that interprets code on-the-fly. You can actually change the parameters and code of a program while the program is running.
Smalltalk first introduced many other concepts that would later appear revolutionary when implemented in other applications, such as browsers, windows, and pop-up menus. From the O-O perspective, Smalltalk supported inheritance and the concept of sending messages between objects. Smalltalk gained a loyal and vocal following, but initially did not make major gains in the programming market.
Although Smalltalk gave O-O development a certain amount of legitimacy in the marketplace, it took C++ to bring O-O development what it really needed: widespread acceptance in the marketplace. For this reason, C++ may well be the most important O-O language. Not until C++ was released and the industry started supported it with a vengeance did O-O development become mainstream.
C++ has its roots in a project to simulate software running on a distributed system. This simulator, actually written in Simula, is where Bjarne Stroustrup conceived of the idea of combining some of the features of Simula with the syntax of C.
While working at Bell, Stroustrup made personal contacts with people such as Brian Kernighan and Dennis Ritchie, who wrote the definitive book on C. When the initial simulator written in Simula failed, Stroustrup decided to rewrite it in a C predecessor called BCPL.
C++ was originally implemented in 1982 under the name C with Classes. As the name suggests, the most important concept of C with Classes was the addition of the class. The class concept provided the encapsulation now requisite with O-O languages.
The reasons C++’s O-O roots are in Simula are obvious. However, why did Stroustrup decide to use C? Because, he said, C is flexible, efficient, available, and portable. Some of these points can be debated today, but at the time, these reasons were valid. Perhaps the most important reason he used C was because he was at Bell Labs and C had gained a large following and was widely accepted in the marketplace.
Commercial C++ compilers began to appear in 1988. In June 1989, C++ Release 2.0 legitimately moved C++ into the mainstream of software development; in late 1989 the ANSI C++ committee formed.
While C provided a solid foundation for C++, it also was also a bit of a boat anchor. Using C syntax provided a clear transition path from C to C++; however, making C++ backward compatible with C has a serious drawback. While C++ does provide O-O constructs, it is possible to use structured programming techniques. Thus, C++ is not considered a true O-O language, but a hybrid language. During job interviews, many O-O novices will proclaim their competence with O-O languages by alluding to the fact that they have used a C++ compiler. The issue here is that you can use a C++ compiler while programming with straight C syntax. In short, you can use a C++ compiler and not conform to accepted O-O programming rules.
An interesting point about C++ is that a large percentage of the software that currently runs on PC-based systems is written in C++. Also, much of embedded system work is still done with C and C++. C++ remains a very powerful language where performance is at a premium—along with, obviously, assembler. A very disciplined programmer can create very elegant object-oriented programs with C++.
Java’s origins are in consumer electronics. In 1991, Sun Microsystems began to investigate how it might exploit this growing market. Some time later, James Gosling was investigating the possibility of creating a hardware-independent software platform for just this purpose. Initially, he attempted to use C++, but soon abandoned C++ and began the creation of a new language he dubbed Oak.
Gosling decided that he still wanted to base his language on the highly successful C++, but that he would incorporate only those features of C++ that were deemed worthwhile. The features that he eliminated from the C++ plate were multiple inheritance, automatic type conversions, the use of pointers, and C++’s memory management scheme. Although the Oak technology was intriguing, the market was not quite ready for it and Oak was put on the backburner.
With the advent of the Web and the emergence of browsers, the people at Sun put two and two together, and Oak was brought out of the mothballs and renamed Java. Sun created its browser, called HotJava, using Java. By summer 1995, Java ran on SPARC Solaris, Windows NT, Windows 95, and Linux. By fall 1995, Java beta 1 was released, and the Netscape Navigator 2.0 Browser incorporated Java. Java 1.0 was officially released in January 1996. Over the past nine years, Java has progressed to the current release Java 2 Platform Standard Edition 5.0 as well as other platforms such as an Enterprise Edition (J2EE) for the enterprise/server market and a Micro Edition(J2ME) for mobile and wireless.
Microsoft responded to the popularity of Java by producing a version of Java called Visual J++. However, Microsoft decided on a more comprehensive response. Using many of the groundbreaking that Java implemented, Microsoft developed a language called C# that became the foundation for the companies .NET platform. As with Java, C# relied heavily on the success and failures of earlier languages. The .NET development environment includes many of the really good characteristics of several other platforms. C#, like Java, uses C/C++ syntax. C# incorporates many of concepts introduced by the initial Java released (which I will list later in the article). The C# platform also builds upon many of the powerful features of the VB6 and Visual C++ environments.
While Java hangs its hat on the fact that it is platform independent, perhaps the most interesting point about C# is that is takes this portability thread in a totally different direction. With the release of the .NET environment, Microsoft moves into the realm of language portability. Whether or .NET will ever be truly platform independent, it does provide the ability to develop code in different languages that can be integrated into the same application. For example, you can develop objects in C# .NET and VB .NET and use them together. In fact, any objects developed in the .NET environment can be used together.
Visual Basic .NET
Visual Basic 6 is one of the most popular programming languages. The programming environment for VB6 has had a huge impact on state-of-the-art development environments. VB6 has evolved steadily towards the object-oriented model until it finally joined the list of object-oriented languages with the release of Visual Basic .NET. VB6 was not totally object-oriented; it did not implement inheritance completely. Remember that to be totally object-oriented, a language must implement encapsulation, polymorphism, and inheritance. Inheritance comes in two flavors, interface and implementation inheritance. VB6 implements interface inheritance but not implementation inheritance. I will discuss the various flavors of inheritance in future columns.
Supporting Object-Oriented Features
Many other languages that were originally non-O-O now support some degree of O-O features. This movement started soon after the emergence of E-Commerce. One movement of mainstream information technology toward object-technology (OT) was introduced by SAP around 2000, at that time the worldwide leader of client/server-based commercial application software. With Release 4.0 of SAP R/3, SAP introduced ABAP objects, thus bringing SAP’s Fortune 500 client list into the O-O mainstream of commercial business applications.
Why Do New Languages Keep Coming Along?
It is interesting that O-O technologies keep getting so much industry attention. If you compared the number of programmers using object-oriented technologies before 2000 to those who were not, you would have wondered how O-O languages became popular at all. To answer this question, let me explain the motivations for the development of Java—the language that really started this O-O language revolution. When the beta versions of Java initially hit the streets, Y2K was still five years away. Thus, the emergence of Java paralleled the Y2K mania that in a large way fueled the tech boom. Why then did an object-oriented language like Java make such a big splash? More to the point—what features did Java provide that led the the industry to embrace is so well?
With this in mind, let me talk about some of the hype surrounding Java. How much is Java really being used in critical applications? I would venture to guess that the most-used language today would be COBOL. If you counted up all the lines of code in each programming language, COBOL would, most likely, reign supreme. People have been writing COBOL systems for at least 25 years, so it has a long history. Add, in all the other languages that are not O-O, such as C, Basic, Fortran, RPG, and so on, and you can see that by comparison, the O-O portion of the world is very small indeed.
Even if you consider the PC (most of the legacy code mentioned in the previous paragraph is on non-PC platforms such as mainframes), the languages of choice are C, C++, Visual Basic, and so on. Throw in fourth-generation tools, and O-O languages are still in the minority (a small minority). Although you can write O-O code in C++, it is considered a hybrid language. In reality, only Smalltalk and Java are widely used pure O-O languages (ADA is used by the government, so perhaps it can be considered part of the widely used category).
|Smalltalk and Java|
|Some people would not place Smalltalk into the widely used category. Also, remember that even though many people speak of Java as being an O-O language, the primitive data types (integers, floats, and so on) are not implemented as objects.|
Prior to the release of Java, Smalltalk was making some headway in the market. Smalltalk proponents played the pure O-O language card against the C++ camp. It was true that C++, being a hybrid, tended to be somewhat unwieldy. Because of its dependence on C and the fact that it had been extended multiple times, C++ was in many ways difficult to understand and use. Thus, Smalltalk experienced a bit of a revival. In fact, Smalltalk is a very powerful development environment and has a very loyal following. Smalltalk is still a force to be reckoned with and in many ways has always fought the battle of the best technology available not winning out in the marketplace.
However, the selling point that Smalltalk was the only true, pure O-O language diminished when Java emerged. In many ways, Java was the best of both worlds. It was considered a pure O-O language, and its syntax was based on C/C++.
What Makes a State-of-the-Art Language?
So, what makes up a current, state-of-the-art programming language? Java is the latest in the evolutionary cycle, but what does Java claim to provide? The initial Java white paper from Sun (circa 1995) stated that Java was simple, object-oriented, distributed, robust, secure, architecture neutral, portable, interpreted, high performance, multithreaded, and dynamic. That’s saying a lot. Let me show you how Java attempted to back up these claims.
As already stated, Java eliminated some of the perceived complexity of C++, such as multiple inheritance, automatic type conversions, the use of pointers, and the C++ memory management scheme.
Whereas Smalltalk is a pure O-O, C++ is a hybrid language that supports O-O features. Interestingly, the O-O features of Java are essentially those of C++, but Java enforces the O-O paradigm.
The Internet and networking in general are pervasive in today’s market, and Java supports TCP/IP protocols such as HTTP and FTP. Java also has native support for accessing URLs.
Java has a very strong emphasis on preventing problems in the first place and detecting them early if they do crop up. The major difference between Java and C++ in this area is that Java does not support pointers, which prevents much of the data corruption encountered when using C++. Basically, pointers give programmers just enough rope to hang themselves.
Because Java was developed as a language for networked and distributed environments, security was a primary concern from the start. For example, when using Java with a non-trusted applet, the applet cannot update system resources outside its process space. Applets have been expanded to a more general term called Java objects.
|When the browser can authenticate an applet, normally via a digital signature, the applet is considered a trusted applet and may be allowed to update certain system resources.|
Java produced bytecodes (not native machine code) that can be run on any platform that supports a Java Virtual Machine (JVM). This means that there is no system-dependent, native code. This is very important because the is no way of knowing whether a browser client accessing your site is running on a Mac, a PC, Linux box, and so on. Actually, the bytecodes are run by a software program called a Java Virtual Machine (JVM) that is integrated into the browser itself.
|The Java Virtual Machine|
|The JVM is an interpreter that inputs Java bytecodes and turns them into platform-dependent code. In this design, the bytecodes are portable and the programmer does not have to worry about writing system-dependent code. However, interpreters often suffer from performance issues, and one of the earliest criticisms of Java related to poor performance.|
There are, theoretically at least, no system-dependent aspects to Java. C and C++ have a lot of system-dependent aspects embedded in them. For example, an int in C and C++ can be 16 bits, 32 bits, or any other size, depending on the platform. An int in Java is always 32 bits.
Java is not compiled and linked into native code like C++ or VB6. Java is compiled into bytecodes and then interpreted by the JVM. Thus, any platform that has a JVM can run Java bytecodes. C# (all of .NET) has a model using a platform called the Common Language Runtime (CLR).
This claim is a bit more dubious than the others. Early on, the rap against Java was that it was slow. Performance has improved; however, sometimes programmers need to write code in another language for performance reasons. For example, you may need to write a routine in C++ to write to a specific device driver and call it from your Java code. However, this breaks the Java model, so you no longer have a pure Java application.
You also can take the Java code and use features like just-in-time compilers to transform the Java bytecodes into platform-dependent native code for efficiency purposes.
Multithreading allows one program to do more than one thing at a time. (This is not to be confused with multiprocessing.) Multithreading leads to more real-time responsiveness from an application. However, in many languages multithreading is very complicated. Java makes multithreading much easier to manage.
Classes in Java are loaded dynamically, not linked into executables. Thus, finding runtime information is much easier. It also facilitates the loading of classes over networks.
Java greatly benefited from the lessons learned by the designers of C++. It is easy to look at Java and marvel at its elegance, but C++ did not have Java’s advantage of hindsight. In fact, one of the primary reasons that Java has gained the popularity that it has is a direct result of its lineage from C++. C and C++ programmers can use Java without having to learn a new syntax.
What language will be the next hot topic in the O-O arena? Of course, there is no way to predict the future. The market acceptance for Smalltalk, C++, Java, and .NET has thrust O-O development into the mainstream. Thus, there is sure to be more research in the areas of O-O technologies. Acceptance of a new language, whether O-O or not, is not a quick process. However, it will be interesting to see what new and improved language will give the current set of widely used languages a run for its money in the next 5 to 10 years.
Sun Microsystems: The Java Language: An Overview. java.sun.com/docs/overviews/java/java-overview-1.html.
Khoshafian, Setrag, and Razmik Abnous: Object Orientation. Wiley, 1995.
Stroustrup, Bjarne: The Design and Evolution of C++. Addison-Wesley, 1994.
About the Author
Matt Weisfeld is an Assistant Professor at Cuyahoga Community College (Tri-C) in Cleveland, Ohio. Matt is a part of the Information Technology department, teaching
programming languages such as C++, Java, and C# .NET as well as various Web
technologies. Prior to joining Tri-C, Matt spent 20 years in the information
technology industry gaining experience in software development, project
management, business development, corporate training, and part-time teaching.
Matt holds an MS in computer science and an MBA in project management.
The material presented in these articles is based on material from the second edition of my book, The Object-Oriented Thought Process, 2nd edition. The Object-Oriented Thought Process is intended for anyone who needs to understand the basic object-oriented concepts before jumping into the code.