Challenging Imperative Programming with Algebra, Logic and Functions

Jan van Eijck

Abstract

The challenge is to integrate algebraic, logic and functional programming into a paradigm that can beat imperative programming. This is an old goal, and many have lost faith that it can be achieved. However, there are signs that due to leaps in system complexity and the intricacies of concurrency the (in)famous von Neumann bottleneck is turning into a real limitation on what imperative programming can achieve.

1  Introduction

``How much land does a man need?'' asked Lev Tolstoi, and the answer turned out to be: surprisingly little. ``How many programming languages does a software designer need?'' The answer seems to be: surprisingly many. See below.

Of course, well-designed languages are a key to good software design, but while many well designed languages are available (see below), the problem of ill-designed software persists. Why is this so?

A refreshing concept for software design is being puth forth at Praxis High Integrity Systems (IEEE Spectrum Software Report ``The Exterminators'', September 2005), but it is nothing new. Years ago, that was the way software was developed. Programmers actually designed their programs - remember flowcharts ? - and wrote ``pseudocode'' before ever beginning to write code. Why has that changed?

For the last 20 years, the goal has been to make programming easier and easier by supplying ever more powerful tools - compilers, Visio, programming packages, workbenches, and so on - and by creating higher-level and more abstract languages. Theoretically, these tools should have made the output better, and, used correctly, they would have. Instead, the innovations made programming and coding so easy that literally anyone can write code. Not well-structured code or bug-free code - just code.

Joseph DeCarolis in a letter to IEEE Spectrum, January 2006.

2  Imperative Versus Declarative Programming

3  Algebra and Programming

The key feature in specifying abstract data types is to present a precise description of that data type without referring to any concrete representation of the objects of that datatype and without referring to any implementation details on the operations on the datatype.

This abstract point of view is provided by many-sorted algebras. Many sorted algebras are specifications of abstract datatypes.

4  Logic and Logic Programming

First order predicate logic can be turned into a computation engine by adding SDL resolution, unification and fixpoint computation. The result is datalog.

To extend this into a full fledged programming paradigm, backtracking and cut (an operator for pruning search trees) were added. The result is Prolog.

Excellent source of information on logic programming: http://vl.fmnet.info/logic-prog/

5  Functional Programming

Pure lambda calculus was developed in the 1930s and 40s by logician Alonzo Church, as a foundational project intended to put mathematics on a firm basis of `effective procedures'. In the system of pure lambda calculus, everything is a function, functions can be applied to other functions to obtain values by a process of application, and new functions can be constructed from existing functions by a process of lambda abstraction. Unfortunately, the system of pure lambda calculus admits the formulation of Russell's paradox.

Representing sets by their characteristic functions (essentially procedures for separating the members from a set from the non-members), we can define

 
  \ x . not (x x)

Now apply r to itself:
 
   r  r  = (\ x . not (x x))  (\ x . not (x x)) 
         =  not ((\ x . not (x x))(\ x . not (x x)))
         =  not (r  r)

So if (r r) is true then it is false and vice versa. This means that pure lambda calculus is not a suitable foundation for mathematics. However, as Church and Turing realized, it is a suitable foundation for computation.

Frequently asked questions about functional programming: http://www.cs.nott.ac.uk/~gmh/faq.html.

6  Functional Logic Programming

Many proposals have been made for the integration of functional programming and logic programming:

7  Multiparadigm Programming

Programming languages are just tools. Multi-paradigm languages are the equivalent of multi-purpose tools like Swiss army knifes:




File translated from TEX by TTH, version 2.78.
On 1 Feb 2006, 16:18.