Difference between revisions of "Language features"

From Clean
Jump to navigationJump to search
(Created page with '== The Functional Programming Language Clean == A functional programming language like Clean is based on the concept of mathematical functions. Clean is a pure functional languag…')
 
Line 1: Line 1:
== The Functional Programming Language Clean ==
 
 
A functional programming language like Clean is based on the concept of mathematical functions. Clean is a pure functional language, there is not such a thing as an assignment. This has a big advantage: a function cannot have a side-effect. A Clean function is referential transparent: the result of a function only depends on the value of the function arguments and on nothing else.
 
A functional programming language like Clean is based on the concept of mathematical functions. Clean is a pure functional language, there is not such a thing as an assignment. This has a big advantage: a function cannot have a side-effect. A Clean function is referential transparent: the result of a function only depends on the value of the function arguments and on nothing else.
  

Revision as of 13:12, 5 July 2010

A functional programming language like Clean is based on the concept of mathematical functions. Clean is a pure functional language, there is not such a thing as an assignment. This has a big advantage: a function cannot have a side-effect. A Clean function is referential transparent: the result of a function only depends on the value of the function arguments and on nothing else.

This has important consequences:

  • Once a function is working, it will always work. A function will always react in the same way, regardless when and in which context the function is used; One can reason about Clean functions and the Clean program as a whole (which is a function application) by using traditional mathematical reasoning: uniform substitution and mathematical induction.
  • For making real world applications one needs of course to be able to update a database, perform I/O, update an array destructively, pass a message to another program. And, the application should run efficiently enough. Although Clean does not have assignments, objects can be updated destructively. Clean is the only functional language in the world which has a special type system, uniqueness typing. This type system is developed in Nijmegen. It enables to update function arguments destructively retaining the purity of the language.

Research Concepts Used in Clean

The Software Technology Research Group is working on functional languages since 1984. Many new concepts which are now commonly used in the functional language community have been introduced by our group (such as term graph rewriting, lazy copying, abstract reduction, uniqueness typing, Clean's Object I/O concept, concurrent and parallel aspects of Clean, dynamic typing) have a look at our publications.

Feature List of the Clean Language

For people who are familiar with other functional languages, such as Haskell, we give here a short list with the features of the language. For more information on the language, look here.

  • Clean is a lazy, pure, higher-order functional programming language with explicit graph-rewriting semantics; one can explicitly define the sharing of structures (cyclic structures as well) in the language;
  • Although Clean is by default a lazy language one can smoothly turn it into a strict language to obtain optimal time/space behavior: functions can be defined lazy as well as (partially) strict in their arguments; any (recursive) data structure can be defined lazy as well as (partially) strict in any of its arguments;
  • Clean is a strongly typed language based on an extension of the well-known Milner / Hindley / Mycroft type inferencing/checking scheme (Milner 1978; Hindley 1969; Mycroft 1984) including the common higher order types, polymorphic types, abstract types, algebraic types, synonym types and existentially quantified types;

Due to the strong typing of Clean and the obligation to initialize all objects being created run-time errors can only occur in a very limited number of cases: when partial functions are called with arguments out of their domain (e.g. dividing by zero), when arrays are accessed with indices out-of-range and when not enough memory (either heap or stack space) is assigned to a Clean application;

  • Type classes and type constructor classes are provided to make overloaded use of functions and operators possible;
  • Clean offers the following predefined types: integers, reals, Booleans, characters, strings, lists, tuples, records, (destructively updateable) arrays and files;
  • Clean has pattern matching, guards, list comprehensions and array comprehensions and a lay-out sensitive mode;
  • One can define functions on a local level using where blocks, let expressions (even before a guard) and strict let expressions;
  • Clean's key feature is a polymorphic uniqueness type inferencing system, a special extension of the Milner / Hindley / Mycroft type inferencing/checking system allowing a refined control over the single threaded use of objects; with this uniqueness type system one can influence the time and space behavior of programs; it can be used to incorporate destructive updates of objects within a pure functional framework, it allows destructive transformation of state information, it enables efficient interfacing to the non-functional world (to C but also to I/O systems like X-Windows) offering direct access to file systems and operating systems;
  • Clean is a modular language allowing separate compilation of modules; one defines implementation modules and definition modules; there is a facility to implicitly and explicitly import definitions from other modules;
  • Clean offers a sophisticated I/O library with which window based interactive applications (and the handling of menus, dialogues, windows, mouse, keyboard, timers and events raised by sub-applications) can be specified compactly and elegantly on a very high level of abstraction;

GUI-based programs written in Clean using the 0.8 I/O library can be ported without modification of source code to anyone of the many platforms we support.

  • There are many libraries available offering additional functionality.