In conclusion

In this article you've been introduced to the ideas of functional programming through one of the new generation of functional languages. You saw how a Hope program is just a series of functions that are regarded as definitions of parts of a data structure -- the `results' of the program -- and how the powerful idea of higher-order functions allows us to capture many common program patterns in a single function.

Some of these ideas will already be familiar to users of LISP, but they appear in a purer form in Hope, because there are no mechanisms for updating data structures like LISP's SETQ and RPLACA or for specifying the order of evaluation like GO and PROG. Unlike LISP programs, Hope programs are free from side-effects and possess the mathematical property of referential transparency.

You also saw features that are primitive or lacking in LISP and in most imperative languages. The data declaration lets you define complex data types without worrying about how they're represented and pattern- matching lets you decompose them, so you can use abstract data types directly without writing access procedures and without the need to invent lots of new names. The typing mechanism lets the compiler check that you're using data objects in a correct and consistent way, while the idea of polymorphic types stops the checking from being too restrictive and lets you define common data `shapes' with a single function.

Higher-order functions and polymorphic types allow us to write programs that are very concise. Programmers are more productive and their programs are easier to understand and to reason about. The property of referential transparency improves our ability to reason about programs still further and makes it possible to transform them mechanically into programs that are still provably correct, but more efficient in their use of space or time. Finally, referential transparency keeps the meaning of Hope programs independent of the order they're evaluated in, making them ideal for parallel evaluation on suitable machines. You'll be seeing a lot more of Hope and languages like it in the future.



Roger Bailey <rb@doc.ic.ac.uk>