9.1 Introduction
This chapter continues our study of programming by introducing three different approaches to the problem solving process. Section 9.2 discusses functional programming, in which computer programs are viewed as “functions” to be computed, rather than as sequences of commands to be executed. Section 9.3 introduces declarative programming, which views programs as a collection of declarations – true statements of two types: facts and rules. Section 9.4 discusses object-oriented programming, in which programs are viewed as a collection of objects. Coordinated action is carried out by the exchange of messages between objects.
Imperative programming (discussed in the previous chapter), functional programming, and declarative programming are each considered to be distinct programming paradigms. Object-oriented constructs and behaviors are often viewed as higher-level organizational attributes that can be incorporated into each of the three basic paradigms, rather than as a separate programming paradigm unto itself.
Over the past decade, object-oriented concepts have revolutionized programming languages. In fact, the vast majority of widely used programming languages are now object-oriented, including C++, Java, and Visual Basic. While functional and logical programming have not made nearly as deep a mark on mainstream programming as object-oriented programming, these two paradigms are used in various sub-disciplines of computer science, such as artificial intelligence. Despite their rather limited use at the present time, study of functional and logical programming will help you to see that the imperative paradigm is but one approach to writing computer programs.