Clean (programming language)

Functional programming language


title: "Clean (programming language)" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["functional-languages", "term-rewriting-programming-languages", "free-and-open-source-compilers", "cross-platform-free-software", "programming-languages-created-in-1987", "statically-typed-programming-languages"] description: "Functional programming language" topic_path: "technology/programming-languages" source: "https://en.wikipedia.org/wiki/Clean_(programming_language)" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Functional programming language ::

::data[format=table title="Infobox programming language"]

FieldValue
nameClean
logoClean 3.0 (programming language) logo.svg
paradigmfunctional
designerSoftware Technology Research Group of Radboud University Nijmegen
released
latest release version3.1
latest release date
typingstrong, static, dynamic
operating systemCross-platform
licenseSimplified BSD
influenced byLean, Miranda, Haskell
influencedHaskell, Idris
file_ext.icl, .dcl, .abc
website
::

| name = Clean | logo = Clean 3.0 (programming language) logo.svg | paradigm = functional | designer = Software Technology Research Group of Radboud University Nijmegen | released = | latest release version = 3.1 | latest release date = | typing = strong, static, dynamic | operating system = Cross-platform | license = Simplified BSD | influenced by = Lean, Miranda, Haskell | influenced = Haskell, Idris | file_ext = .icl, .dcl, .abc | website =

Clean is a general-purpose purely functional programming language. Originally called the Concurrent Clean System or the Clean System, it has been developed by a group of researchers from the Radboud University in Nijmegen since 1987. Although development of the language has slowed, some researchers are still working in the language. In 2018, a spin-off company was founded that uses Clean.

Features

Clean shares many properties and syntax with a younger sibling language, Haskell: referential transparency, list comprehension, guards, garbage collection, higher order functions, currying, and lazy evaluation. However, Clean deals with mutable state and input/output (I/O) through a uniqueness type system, in contrast to Haskell's use of monads. The compiler takes advantage of the uniqueness type system to generate more efficient code, because it knows that at any point during the execution of the program, only one reference can exist to a value with a unique type. Therefore, a unique value can be changed in place.

An integrated development environment (IDE) for Microsoft Windows is included in the Clean distribution.

Examples

Hello world: ::code[lang=clean] Start = "Hello, world!" ::

Factorial: ::data[format=table]

::

Fibonacci sequence: ::data[format=table]

::

Infix operator: ::code[lang=clean] (^) infixr 8 :: Int Int -> Int (^) x 0 = 1 (^) x n = x * x ^ (n-1) ::

The type declaration states that the function is a right associative infix operator with priority 8: this states that x*x^(n-1) is equivalent to x*(x^(n-1)) as opposed to (x*x)^(n-1). This operator is pre-defined in StdEnv, the Clean standard library.

How Clean works

Computing is based on graph rewriting and reduction. Constants such as numbers are graphs and functions are graph rewriting formulas. This, combined with compiling to native code, makes Clean programs which use high abstraction run relatively fast according to The Computer Language Benchmarks Game. A 2008 benchmark showed that Clean native code performs similarly to the Glasgow Haskell Compiler (GHC), depending on the benchmark.

Compiling

Compilation of Clean to machine code is performed as follows:

  1. Source files (.icl) and definition files (.dcl) are translated into Core Clean, a basic variant of Clean, by the compiler frontend written in Clean.
  2. Core clean is converted into Clean's platform-independent intermediate language (.abc), by the compiler backend written in Clean and C.
  3. Intermediate ABC code is converted to object code (.o) by the code generator written in C.
  4. Object code is linked with other files in the module and the runtime system and converted into a normal executable using the system linker (when available) or a dedicated linker written in Clean on Windows.

Earlier versions of the Clean compiler were written completely in C, thus avoiding bootstrapping issues.

The ABC machine

The ABC code mentioned above is an intermediate representation for an abstract machine. Because machine code generation for ABC code is relatively straightforward, it is easy to support new architectures. The ABC machine is an imperative abstract graph rewriting machine. It consists of a graph store to hold the Clean graph that is being rewritten and three stacks:

  • The A(rgument)-stack holds arguments that refer to nodes in the graph store.
  • The B(asic value)-stack holds basic values (integers, characters, reals, etc.). Although these values could be nodes in the graph store, a separate stack is used for efficiency.
  • The C(ontrol)-stack holds return addresses for flow control. The runtime system, which is linked into every executable, builds a Start node in the graph store and pushes it on the A-stack. It then begins printing it, evaluating it as needed.

Running Clean in the browser

Although Clean is typically used to generate native executables, several projects have enabled applications in web browsers. The now abandoned SAPL project compiled Core Clean to JavaScript and did not use ABC code. Since 2019, an interpreter for ABC code, written in WebAssembly, is used instead.

Platforms

Clean is available for Microsoft Windows (IA-32 and X86-64), macOS (X86-64), and Linux (IA-32, X86-64, and AArch64).

Some libraries are not available on all platforms, like ObjectIO which is only available on Windows. Also the feature to write dynamics to files is only available on Windows.

The availability of Clean per platform varies with each version:

::data[format=table]

VersionDateLinuxmacOSOracle SolarisWindowsMiscellaneousIA-32x86-64AArch64Motorola 68040PowerPCx86-64SPARCIA-32x86-64
3.1
3.0
2.4
2.3
2.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0
1.3.3
1.3.2
1.3.1
1.3
1.2.4
1.2.3
1.2
1.1.3OS/2 (i80386)
1.1.2SunOS 4 (SPARC)
1.1
1.0.2OS/2 (i80386); SunOS 4 (SPARC)
1.0OS/2 (i80386)
0.8.4Experimental T800 transputer release
0.8.3
0.8.1
0.8OS/2 (i80386); SunOS 3–4 (SPARC)
0.7SunOS 3–4 (SPARC)
::

Comparison to Haskell

The syntax of Clean is very similar to that of Haskell, with some notable differences. In general, Haskell has introduced more syntactic sugar than Clean:

::data[format=table]

HaskellCleanRemarks
xisOdd x]list comprehension
x:xs[x:xs]cons operator
Node (Tree a) a (Tree a)
(Eq a, Eq b) = ...Eq a & Eq bclass assertions and contexts
fun t@(Node l x r) = ...fun t=:(Node l x r) = ...as-patterns
if x 10 then 10 else xif (x 10) 10 xif
::

References

References

  1. "Download Clean".
  2. "Idris - Uniqueness Types".
  3. "Clean 0.7: Readme".
  4. "Clean 1.0: Readme".
  5. "Clean 1.3: Readme".
  6. "Radboud University Nijmegen: Department of Software Science: Software".
  7. "FAQ".
  8. "Publications".
  9. "Home".
  10. "FTP link".
  11. "Which programming languages are fastest?".
  12. (2008). "From Interpretation to Compilation".
  13. (10 December 1990). "Functional Programs as Executable Specifications". Katholieke Universiteit Nijmegen.
  14. "Clean and iTasks / ABC Interpreter · GitLab".
  15. (15 July 2021). "Proceedings of the 31st Symposium on Implementation and Application of Functional Languages".
  16. "Release history".
  17. "Index of /Clean".

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

functional-languagesterm-rewriting-programming-languagesfree-and-open-source-compilerscross-platform-free-softwareprogramming-languages-created-in-1987statically-typed-programming-languages