This action might not be possible to undo. Are you sure you want to continue?
Before we start on the functional programming paradigm we give a broad introduction to programming paradigms in general. In this section we will discuss the meaning of the word 'paradigm', and we will enumerate the main programming paradigms, as we see them. In Chapter 2 we will discuss each of the main programming paradigms in some details. Be aware, however, that this material is about the functional programming paradigm. The two first chapters of the material mainly serve as background, and as contrast for an enhanced understanding of the functional school.
Lecture 1 - slide 2
It is interesting and useful to investigate the meaning of the word 'paradigm' We will here look at the meaning of the word 'paradigm', as it appears in 'The American Heritage Dictionary of the English Language, Third Edition':
"An example that serves as pattern or model."
Another and slightly more complicated explanation stems from the 'The Merriam-Webster's Collegiate dictionary':
"A philosophical and theoretical framework of a scientific school or discipline
within which theories, laws, and generalizations and the experiments performed in support of them are formulated" Below we will first describe the meaning of the word 'paradigm' as we adopt it in this course. After that we describe related concepts, namely 'programming technique', 'programming style', and 'programming culture'.
Programming paradigm (in this course) • A pattern that serves as a school of thoughts for programming of computers Programming technique • Related to an algorithmic idea for solving a particular class of problems • Examples: 'Divide and conquer' and 'program development by stepwise refinement' Programming style The way we express ourselves in a computer program
We will in particular attempt to trace the idea and basic discipline behind the four main programming paradigms. and certain programming techniques. which we also mention below. We do not go into the other programming paradigms. A main programming paradigm stems an idea within some basic discipline which is relevant for performing computations • • Main programming paradigms • The imperative paradigm • The functional paradigm • The logical paradigm • The object-oriented paradigm Other possible programming paradigms • The visual paradigm • One of the parallel paradigms • The constraint based paradigm In Chapter 2 we will characterize the four main programming paradigms mentioned above. It may very well be a matter of taste if some of the additional programming paradigms. in this material. should be considered as main programming paradigms as well. we characterize a main programming paradigm in terms of an idea and a basic discipline. programming styles. mentioned above.• The way we express ourselves in a computer program Related to elegance or lack of elegance Programming culture • The totality of programming behavior.2. 2 . The main programming paradigms Lecture 1 . • • 1. which often is tightly related to a family of programming languages • The sum of a main paradigm.slide 3 In this section we will enumerate the four main programming paradigms which will be treated in additional details in Chapter 2. We identify four main programming paradigms and a number of minor programming paradigms In the concept definition below.
uk/foldoc/foldoc.ac.doc.cgi?query=visual+programming 3 .1.ic. References [-] Foldoc: visual programming http://wombat.3.
2. C The natural abstraction is the procedure 5 . Overview of the four main programming paradigms In this section we will characterize the four main programming paradigms. such as food recipes and car repair • Typical commands offered by imperative languages • Assignment. 2. As an adjective it means 'expressing a command or plea'. • Execution of computational steps in an order governed by control structures • We call the steps for commands • Straightforward abstractions of the way a traditional Von Neumann computer works • Similar to descriptions of everyday routines. then do this' would be different from 'first do this. • Characteristics: • Discipline and idea • Digital hardware technology and the ideas of Von Neumann • Incremental change of the program state as a function of time.1. then do that'. we attempt to trace the basic discipline and the idea behind each of the main programming paradigms. As a noun. 'First do that. In other words. asking for something to be done. as ident ified in Section 1. uses the word 'imperative' for commands in the language. The phrase also reflects that the order to the commands is important.2. Pascal. The basic idea is the command. procedure calls • Language representatives • Fortran. next do that' is a short phrase which really in a nutshell describes the spirit of the imperative paradigm. IO. As the main contribution of this exposition. In the itemized list below we describe the main properties of the imperative paradigm. we will also be able to see how the functional programming paradigm corresponds to the other main programming paradigms. First do this and next do that The 'first do this. Overview of the imperative paradigm Lecture 1 . With this introduction to the material. an imperative is a command or an order. such as the object oriented language Beta. which has a measurable effect on the program state. Basic.slide 5 The word 'imperative' can be used both as an adjective and as a noun. Some programming languages. Algol.
which can be activated as a single action. which can be called as a single command. The word statement is often used with the special computer science meaning 'a elementary instruction in a source language'. which are more complicated. Below we characterize the most important.1. 2.1. Evaluate an expression and use the resulting value for something • Characteristics: • Discipline and idea • Mathematics and the theory of functions • The values produced are non-mutable • Impossible to change any constituent of a composite value • As a remedy.2. and less 'clean' than mathematical function theory. A procedure abstracts one or more actions to a procedure. Needless to say. overall properties of the functional programming paradigm. we will come back to most of them in the remaining chapters of this material. The word instruction is another possibility. The reason is that the paradigm originates from a purely mathematical discipline: the theory of functions. it is possible to make a revised copy of composite value • Atemporal 6 . We prefer to devote this word the computational steps performed at the machine level. the imperative paradigm is rooted in the key technological ideas of the digital computer.slide 6 We here introduce the functional paradigm at the same level as imperative programming was introduced in Section 2. Functional programming is in many respects a simpler and more clean programming paradigm than the imperative one. • "Procedural programming" We use several names for the computational steps in an imperative language. As described in Section 2.• The natural abstraction is the procedure • Abstracts one or more actions to a procedure. We will use the word 'command' for the imperatives in a high level imperative programming language. Overview of the functional paradigm Lecture 1 .
. In that way. These properties are very important when programs become larger and larger.. The logical paradigm seems less natural in the more general areas of computation. Overview of the logic paradigm Lecture 1 . making use of a set of inference rules 2. lists. Fits well with computations driven by needs • Opens a new world of possibilities • 2. 7 . all the necessary technicalities of programming come in second row.. and queries. which are important in the problem domain of interest. The underlying.slide 7 The logic paradigm is dramatically different from the other three main programming paradigms. and somewhat deeper reason to the success of the object-oriented paradigm is probably the conceptual anchoring of the paradigm. Answer a question via search for a solution Below we briefly characterize the main properties of the logic programming paradigm.fledged data just like numbers. The primary and most direct reason is undoubtedly the strong support of encapsulation and the logical grouping of program aspects.4. The logic paradigm fits extremely well when applied in problem domains that deal with the extraction of knowledge from basic facts and relations. An object-oriented program is constructed with the outset in concepts.slide 8 The object-oriented paradigm has gained great popularity in the recent decade. inference rules. • Program execution becomes a systematic search in a set of facts.3. • Characteristics: • Discipline and idea • Automatic proofs within artificial intelligence • Based on axioms.• • Abstracts a single expression to a function which can be evaluated as an expression Functions are first class values • Functions are full. Overview of the object-oriented paradigm Lecture 1 .
ac. as opposed to programming of the individual objects • Classes represent concepts whereas objects represent phenomena • Classes are organized in inheritance hierarchies • Provides for class extension or specialization This ends the overview of the four main programming paradigms.cgi?query=object-oriented+programming Foldoc: logic programming http://wombat.ic. seen as a school of thought in the area of computer programming.uk/foldoc/foldoc. and models of human interaction with real world phenomena • Data as well as operations are encapsulated in objects • Information hiding is used to protect internal properties of an object • Objects interact by means of message passing • A metaphor for applying an operation on an object • In most object-oriented languages objects are grouped in classes • Objects in classes are similar enough to allow programming of the classes.cgi?query=logic+programming Foldoc: functional programming http://wombat.doc. 2.cgi?query=imperative 8 .uk/foldoc/foldoc.doc. • Characteristics: • Discipline and idea • The theory of concepts.doc.cgi?query=functional+programming Foldoc: imperative http://wombat. with special emphasis on examples drawn from the domain of web program development.ac.ic.ac.doc.Send messages between objects to simulate the temporal evolution of a set of real world phenomena As for the other main programming paradigms. References [-] [-] [-] [-] Foldoc: object-oriented programming http://wombat.ic. From now on the main focus will be functional programming in Scheme.ac.5.uk/foldoc/foldoc. we will now describe the most important properties of object-oriented programming.ic.uk/foldoc/foldoc.