HOME

TheInfoList



OR:

Clean is a general-purpose purely functional
computer programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
. It was called the Concurrent Clean System, then the Clean System, later just Clean. Clean has been developed by a group of researchers from the Radboud University in Nijmegen since 1987.


Features

The language Clean first appeared in 1987. Although development of the language itself has slowed down, some researchers are still working in the language. In 2018, a spin-off company was founded that uses Clean as well. Clean shares many properties and syntax with a younger sibling language, Haskell:
referential transparency In computer science, referential transparency and referential opacity are properties of parts of computer programs. An expression is called ''referentially transparent'' if it can be replaced with its corresponding value (and vice-versa) witho ...
,
list comprehension A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists. It follows the form of the mathematical ''set-builder notation'' (''set comprehension'') as distinct from the use of ...
,
guard Guard or guards may refer to: Professional occupations * Bodyguard, who protects an individual from personal assault * Crossing guard, who stops traffic so pedestrians can cross the street * Lifeguard, who rescues people from drowning * Prison gu ...
s,
garbage collection Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclabl ...
, higher order functions,
currying In mathematics and computer science, currying is the technique of translating the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single argument. For example, currying a function f th ...
and lazy evaluation. However, Clean deals with mutable state and I/O through a uniqueness typing 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.ftp://ftp.cs.ru.nl/pub/Clean/papers/2007/achp2007-CleanHaskellQuickGuide.pdf An integrated development environment (IDE) for Microsoft Windows is included in the Clean distribution.


Examples

Hello world ''Hello'' is a salutation or greeting in the English language. It is first attested in writing from 1826. Early uses ''Hello'', with that spelling, was used in publications in the U.S. as early as the 18 October 1826 edition of the '' Norwich ...
: Start = "Hello, world!"
Factorial In mathematics, the factorial of a non-negative denoted is the product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times (n-1) \times (n-2) ...
: Fibonacci sequence: Infix operator: (^) 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

Computation is based on
graph rewriting In computer science, graph transformation, or graph rewriting, concerns the technique of creating a new graph out of an original graph algorithmically. It has numerous applications, ranging from software engineering ( software construction and also ...
and reduction. Constants such as numbers are graphs and functions are graph rewriting formulas. This, combined with compilation to native code, makes Clean programs which use high abstraction run relatively fast according to the Computer Language Benchmarks Game.


Compiling

# Source files (.icl) and definition files (.dcl) are translated into Core Clean, a basic variant of Clean, in Clean. # Core clean is converted into Clean's platform-independent intermediate language (.abc), implemented in C and Clean. # Intermediate ABC code is converted to object code (.o) using C. # 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 Clean system versions were written completely in C, thus avoiding bootstrapping issues. The SAPL system compiles Core Clean to JavaScript and does not use ABC code.


The ABC machine

To close the gap between Core Clean, a high-level functional language, and
machine code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ve ...
, the ABC machine is used. This is an imperative abstract
graph rewriting In computer science, graph transformation, or graph rewriting, concerns the technique of creating a new graph out of an original graph algorithmically. It has numerous applications, ranging from software engineering ( software construction and also ...
machine. Generating concrete machine code from abstract ABC code is a relatively small step, so by using the ABC machine it is much easier to target multiple architectures for code generation. The ABC machine has an uncommon memory model. It has a graph store to hold the Clean graph that is being rewritten. The A(rgument)-stack holds arguments that refer to nodes in the graph store. This way, a node's arguments can be rewritten, which is needed for pattern matching. The B(asic value)-stack holds basic values (integers, characters, reals, etc.). While not strictly necessary (all these elements could be nodes in the graph store as well), using a separate stack is much more efficient. The C(ontrol)-stack holds return addresses for flow control. The
runtime system In computer programming, a runtime system or runtime environment is a sub-system that exists both in the computer where a program is created, as well as in the computers where the program is intended to be run. The name comes from the compile ...
, which is linked into every executable, has a print rule which prints a node to the output channel. When a program is executed, the Start node is printed. For this, it has to be rewritten to root normal form, after which its children are rewritten to root normal form, etc., until the whole node is printed.


Platforms

Clean is available for Microsoft Windows ( IA-32 and X86-64), macOS ( X86-64), and Linux ( IA-32, X86-64, and
AArch64 AArch64 or ARM64 is the 64-bit extension of the ARM architecture family. It was first introduced with the Armv8-A architecture. Arm releases a new extension every year. ARMv8.x and ARMv9.x extensions and features Announced in October 2011, A ...
). 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:


Comparison to Haskell

A 2008 benchmark showed that Clean native code performs roughly equally well as Haskell ( GHC), depending on the benchmark.


Syntactic differences

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.


References

{{Reflist


External links


Clean Wikiclean-lang.org
public registry with Clean packages
cloogle.org
a search engine to search in Clean packages Functional languages Term-rewriting programming languages Free compilers and interpreters Cross-platform free software