Dynamic Object-Oriented Programming

Copyright © 1994 Franz Inc. All rights reserved.
Permission is hereby granted to redistribute provided this copyright notice appears.
For the latest version of this white paper, please contact Franz Inc.

When Rolls Royce first began selling automobiles, each car was meticulously built by hand, and every customer was provided with a mechanic who would adjust a whole array of components to suit their individual tastes. Then Henry Ford came along and adopted the technology of interchangeable parts to mass produce a significantly less expensive car that could be bought in any configuration, so long as it was a black Model T. Essentially, Ford was able to bring his costs down by severely limiting the customer's choice. The situation has improved a great deal since the first Model T appeared, and car buyers now can choose among an array of aesthetic and performance options at reasonable cost, but those desiring a truly custom car still must pay a very high premium.

Today, companies and individuals buying software are forced to make a similar choice. Either they must pay an extremely high price to purchase a special-purpose application and then have it customized to precisely meet their requirements, or they can elect to buy a general-purpose application that provides a much more limited configuration capability and hope it will suffice. Providing highly customized configurations of an application is still an extremely time and labor intensive processes. As a result, a tremendous opportunity exists now for those software developers that can deliver the power and configurability of custom applications at the cost of shrink-wrapped software.

The latest approach developers have taken in their efforts to seize this opportunity is object-oriented programming (OOP). But although OOP's ability to simplify modification has enabled developers to improve productivity and reduce cost, until now developers have fallen short of their goal because it has been impractical to extend OOP's benefits beyond the developer's front door. Once the software is in the hands of the customer, it is still difficult, and costly, to change.

Dynamic OOP lets software developers create a new breed of custom shrink-wrapped applications, software that can be developed cost-effectively, that addresses the needs of a broad range of customers and yet can be easily altered to precisely meet their specific requirements. Dynamic OOP is able to achieve the goal of high configurability and low cost by leveraging the power available on the desktop to produce software that can be significantly modified easily, and inexpensively, at the customer site. Not only does dynamic OOP provide an avenue for software developers to be more competitive in their current markets, it also opens the door to creating new markets for exciting new applications like intelligent agents that were impractical or impossible to develop before.

The Trend to Greater Configurability

Over the past ten years, the personal computer has evolved from personal productivity tool to mainframe replacement as desktop power has continued to double every two years. During this time, the large and increasingly sophisticated user base began to demand that developers provide software that can be modified to more closely meet their specific needs. Instead of creating costly custom versions of their applications, software developers are responding by exposing more and more of an application's internal functionality, and providing increasingly sophisticated ways for the user to manipulate them.

Made possible by the extra horsepower available on the desktop, developers today are embedding entire programming languages into their applications, creating frameworks that enable power users and third-party developers to tailor these generic shrink-wrapped packages more closely to their needs. For example, all the components of Microsoft Office include an embedded BASIC-like extension language; fourth-generation languages such as Powersoft's Powerbuilder have been developed for customizing line-of-business applications; a large measure of the success of AutoCAD derives from the ability to customize deployed copies to specific vertical markets through AutoLisp, a dynamic extension language; Interleaf supplies an embedded Lisp-based extension language to customize deployed copies of its document publishing system; Apple Computer's AppleScript and AppleEvents dynamically configure applications running in the Macintosh operating system; and General Magic's TeleScript is an object-oriented programming language specifically for creating intelligent network agents, which are essentially dynamic object-oriented extensions to an application.

But perhaps the most visible example to date is OLE (Object Linking and Embedding), Microsoft's approach to dynamically configuring applications by enabling them to interact with each other. The object-based approach taken by OLE brings a new level of power to the user by enabling discreet, disparate applications to work together to solve a problem. For example, a graphical object embedded in a Microsoft Word document can be edited by double clicking on it. Word itself does not have the functionality to edit graphics, but through the mechanism provided by OLE, the graphics editing functionality of another OLE-enabled application such as Microsoft Draw can be imported into Word, modifying Word's menus, toolbars and other user interface items as needed to give the user access to the "new" functionality. In essence, the word processor has been reconfigured on-the-fly into a graphics processor.

But as great an advance as OLE is over the traditional fixed functionality of most of today's software, it only enables existing objects and behaviors to be rearranged or combined in new ways. Word, Excel, WordPerfect and all the other OLE-enabled applications available today do not allow new behaviors or objects to be added or existing ones to be changed. To accomplish this requires the use of a dynamic technology that extends the advantages of object-oriented programming into the run-time environment.

The Horsepower Race

The trend toward greater configurability has been made possible by the parallel trend toward greater computing power. The graphical user interfaces, wizards, object linking and embedding and embedded extension languages common today would not have been viable on the desktop computers of ten years ago because they did not have the computing power and system resources (memory, etc.) to run them with acceptable performance levels, or at all. Today's desktop computers, however, offer as much performance as the mainframes of just ten years ago, and this trend is likely to continue as RISC processors and multiprocessor systems begin to appear.

Programmers have always been faced with a tradeoff between how easily they can create an application and how well it will perform on the computer it's being written for, a tradeoff between programming efficiency and run-time cost. Lotus 1-2-3 was originally created in assembly language because at the time it was the only way to achieve acceptable run-time performance on the under-powered computers of its day. Lotus traded increased effort and lower productivity at the development stage for better run-time performance.

When true 16-bit computers appeared, the tradeoff began to shift as software developers leveraged the increased power. Programmers at Lotus and other developers were able to reduce their programming effort and improve their productivity through the programming efficiencies offered by higher-level languages like C. Development productivity climbed, and although the resulting applications were larger and ran less efficiently, this was more than made up for by the extra power of these machines.

Developers also began adding greater functionality and configurability to their software. The extra horsepower enabled developers to include more extensive configurability, as well as the facility to extend an application's functionality through the use of embedded macro languages, scripting languages and more robust extension languages. These became possible because the higher application overhead was offset by improved hardware performance.

Today's 32-bit processors have enough raw computing power to make possible yet another jump in programming productivity. The most dramatic improvement has been achieved through the use of object-oriented languages.

Object-Oriented Programming

Object-oriented programming is a proven technology that can dramatically improve programmer productivity, and in a relatively short time has gained general acceptance as the best approach to developing and modifying software. The rapid introduction of languages that support OOP, such as C++, Objective C, Object Pascal, Eiffel, CLOS, Smalltalk and others, as well as the growth of CASE companies supporting OOP, attest to OOP's success.

Of all the benefits of OOP, the one associated with providing the greatest productivity gain is the ability to reuse program code. Code reuse is made possible by OOP's characteristics of inheritance and polymorphism. These make it possible to create a customized or updated version of an application exhibiting dramatically different behavior by changing very little of the original program code. The behavior of existing objects can be inherited by other objects without the bother of having to redefine or explicitly include them. If appropriate, some of the behavior can be overridden as needed. Polymorphism simplifies program structure by customizing the behavior of a function based on the type of its arguments, so that a single function such as "add" works on both integers and floating-point numbers rather than requiring separate "add integer" and "add floating point number" commands for each operation. Polymorphism also allows new types to be added without having to make any changes to the program's structure. Another OOP characteristic, encapsulation, makes programs easier to understand and maintain by hiding an object's details or inner workings behind a well-defined and strict interface, enabling modifications in one part of a program to be made without affecting the rest of the program.

Compared to procedural languages, using OOP to simplify and enhance the custom configuration of an application is a very powerful idea. For example, imagine using an application framework designed for controlling and tracking sales in a department store. The classes defined for such a framework might include clothing, luxury items, extended service, discount and special customers (who receive a discount anyway), among others. The discount class might have features such as the discount amount and a period when the discount applies. Operations might include the methods stock, order and sell.

Now imagine a store wanting to carry a new item, discount clothing. To accommodate this new item, a new class called discount clothing is created by simply combining the discount class with all the objects in the clothing class. Next, a new method for sell specifically to handle discount clothing is written, and uses the information in the discount class and price information in the objects of the clothing class. (New methods are also written for stock and order and any other operations that apply.) No other parts of the program need to be changed. Now, when a clerk makes a sale on discount clothing, the new method is automatically applied and the proper price rung up.

Batch OOP Versus Dynamic OOP

Object-oriented programming, if done well, can pay off greatly through the ease with which applications can be developed, modified and maintained by the software developer. But to date, the benefits of the object-oriented approach have not been fully realized because most object-oriented programs operate in batch mode. Once an application written in a batch object-oriented language like C++ is compiled, it is frozen and can't be modified without access to the original source code. Most of the information about objects has been discarded during compilation. Essentially, a gap exists between the efficiencies gained in the design and development of batch OOP applications and how easily they can be tailored to meet a user's specific requirements after they are deployed.

In addition to the productivity gains made in configuring applications after they are deployed, the continuing trend towards more powerful computers makes practical an alternative approach to programming that can achieve a corresponding increase in development productivity. With a static language, programmers must write a complete program before they can compile and test it. Dynamic languages are inherently interactive and enable programmers to test their code as they write it. Anyone familiar with BASIC understands the ability to write a single line of code, press return, and see it executed immediately. In contrast, the edit-compile-test-debug cycle of static-language application development often requires hours to successfully recompile a change in even a single line of code. Dynamic languages also free programmers from much of the dirty work usually associated with application development, such as memory management.

Examples of the various approaches to programming 
available today.

Batch Dynamic Non-Object Oriented C, COBOL Visual BASIC Object Oriented C++ CLOS, Smalltalk

But the price paid for the productivity gains in development by dynamic languages is, once again, performance. Applications written in a dynamic language generally require a higher degree of run-time overhead. As a result, batch object-oriented languages have remained popular among commercial developers because they produce applications that achieve the proper balance between productivity and performance. But this is all changing.

Programmers today are able once again to make a significant jump in productivity by leveraging the available desktop power, opening the door to a much more powerful programming approach. Dynamic object-oriented languages, like Lisp and Smalltalk, can use the power of today's PCs to create a new generation of low-cost application frameworks that can be easily transformed into custom applications at a customer site without the need for source code. Any of the underlying objects, classes, methods and general functions of these frameworks can be made as available to the user as they are to the developer, letting applications be changed easily after deployment, and enabling truly custom applications to be created from generic shrink-wrapped software.

Returning to the department store example, customizing the general framework to the store's specific needs was a simple, straightforward matter of adding objects and methods. Now imagine adding the discount clothing class to the department store framework without access to the source code, on-the-fly, while the program remains running. This is the power of dynamic OOP. What's more, the customized application in the example can evolve over time just as easily, as the store's needs change.

Dynamic OOP opens up a deployed application's object-oriented foundation, making modifications so simple and efficient they can even be completely automated. As a result, dynamic OOP allows the creation of a new class of applications that can interact with and be modified by other applications.

The Role of Dynamic OOP

The future will be filled with applications that can dynamically reconfigure themselves, a capability that will prove to be critically important especially in networked environments and on-line systems. By combining the attributes of dynamic, interactive languages with object-oriented programming, it becomes possible to dramatically alter the behavior of an application by "injecting" a very small amount of data while the application is running.

This unique capability of dynamic OOP is being popularized today by General Magic's creation of a new breed of intelligent network agents that greatly simplify the delivery of information to personal digital assistants (PDAs). General Magic's concept of an intelligent agent is a compact piece of code that modifies the behavior of a server-based application for a custom purpose by transporting new objects and methods across the network. Generated by the PDA, the agent attaches itself to an application running on the server, modifies its behavior to get the desired information and sends the result back to the PDA. Using dynamic OOP reduces network traffic and allows automatic generation of the custom code, off-loading the compute- and data-intensive components of the system from the PDA while retaining true interactivity.

Compact software updates and bug fixes can be distributed over networks simply through email to thousands of computers without monopolizing huge amounts of valuable network bandwidth. Creators of on-line system front-end applications no longer have to anticipate every conceivable service provider's need, enabling creative custom looks and functionality for new services by simply uploading very small files containing the necessary behavior to the front-end application at connect time. Third-party developers can more efficiently and effectively tailor general frameworks for specific vertical applications because they can have easy access to the framework's objects and methods, allowing a level of customization in the run-time environment not possible before.

CLOS

Not every programmer has to go to the extreme of creating their own object-oriented dynamic language in order to achieve its benefits. Unlike General Magic or Apple Computer, mainstream software developers still have the option to implement an object-oriented design quickly and cleanly using a standardized dynamic OOP environment, one that smoothly integrates object-oriented and functional programming constructs.

This environment is available today as the Common Lisp Object System (CLOS), developed as part of the Common Lisp ANSI standardization process begun in 1986, is the first ANSI-standard object-oriented language. Unlike Smalltalk, which has no current standard, or C++, which continues to change and will not be standardized until at least 1998, CLOS has already been implemented by all the major Common Lisp vendors on most major hardware platforms, making Common Lisp programs very portable.

CLOS offers more of the features that developers 
using dynamic OOP require.

CLOS Smalltalk C++ Garbage Collection Yes Yes No Multiple Inheritance Yes No Yes Multi-Methods Yes No No Dynamic Typing Yes Yes No Static Typing Yes No Yes Metaobject Protocol Yes Partial No Dynamic Redefinition Yes Partial No

CLOS supports a dynamic model, allowing classes and methods to be created or altered and objects to change class at run time. Most current object-oriented design methodologies use a static object model in which a design uses a fixed set of classes and objects that never change class. CLOS's dynamic model makes it possible to write applications that change dynamically at run time, allowing end users, third-party developers and even other applications to reconfigure a running application.

CLOS is a very powerful interactive development environment. Unlike batch OOP languages, CLOS supports late binding, making it easy to define and modify program components and immediately debug them. With CLOS, only the modified program components are processed by the compiler and are then dynamically linked into the running environment, eliminating lengthy compile-link-run cycles. Using CLOS, program components can be added or changed without having to recompile any others. Class hierarchies in CLOS are easily modified, and existing instances are automatically updated.

Franz Inc.

As the leading supplier of CLOS development systems, Franz Inc. is in the forefront of dynamic OOP technology. Through its efforts, dynamic OOP is already at work in applications in mechanical and electrical CAD, as well as in sophisticated scheduling applications in transportation, manufacturing and other markets. Franz Inc. also is working closely with forward-looking software developers around the world to develop a new generation of applications that take advantage of CLOS's dynamic configuration capabilities, including network aware applications, intelligent agents and on-line systems in commercial, financial and telecommunications industries, as well as research centers and universities. Franz Inc. has an excellent reputation for customer and technical support, and through ongoing relationships with value added resellers and strategic partnerships with leading computer industry players, Franz Inc. will continue to offer the most comprehensive array of platforms for the development and delivery of CLOS applications.

# # #