0% found this document useful (0 votes)
36 views2 pages

Overview of the Clean Programming Language

Clean is a purely functional programming language developed since 1987 at Radboud University. It shares properties with Haskell like lazy evaluation, higher-order functions, and garbage collection. Clean uses uniqueness typing to handle mutable state and I/O more efficiently than Haskell's use of monads. Source code is compiled through several steps to an intermediate ABC machine code then to native machine code to run efficiently. The ABC machine uses a graph rewriting model of computation and an uncommon memory model to more easily target multiple architectures. Clean is available on Windows, Mac, Solaris and Linux.

Uploaded by

Rock Kim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Overview of the Clean Programming Language

Clean is a purely functional programming language developed since 1987 at Radboud University. It shares properties with Haskell like lazy evaluation, higher-order functions, and garbage collection. Clean uses uniqueness typing to handle mutable state and I/O more efficiently than Haskell's use of monads. Source code is compiled through several steps to an intermediate ABC machine code then to native machine code to run efficiently. The ABC machine uses a graph rewriting model of computation and an uncommon memory model to more easily target multiple architectures. Clean is available on Windows, Mac, Solaris and Linux.

Uploaded by

Rock Kim
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Tijani Kehinde Hussein

Matric No.: UJ/2016/MS/0520


Course Code: ACC 425
Course Title: Management Information System
Date: 28 June 2021

CLEAN (PROGRAMMING LANGUAGE)

INTRODUCTION
1. Clean is a general-purpose purely functional computer programming language.
For much of the language's active development history it was called Concurrent Clean,
but this was dropped at some point. Clean is being developed by a group of
researchers from the Radboud University in Nijmegen since 1987. A 2008 benchmark
showed that Clean native code performs roughly equally well as Haskell (GHC),
depending on the benchmark.
FEATURES
2. The language Clean first appeared in 1987 and is still being further developed. It
shares many properties with Haskell: referential transparency, list comprehension,
guards, garbage collection, higher order functions, currying and lazy evaluation. An
integrated development environment (IDE) for Microsoft Windows is included in the
Clean distribution. 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
anything with a uniqueness type can only be used once. Therefore, a unique value can
be changed in place.
HOW CLEAN WORKS
3. Computation is based on graph rewriting 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
a. Source files (.icl) and definition files (.dcl) are translated into Core Clean, a
basic variant of Clean, in Clean.
b. Core clean is converted into Clean's platform-independent intermediate
language (.abc), implemented in C and Clean.
c. Intermediate ABC code is converted to object code (.o) using C.
UJ/2016/MS/0520 TIJANI KEHINDE HUSSEIN – ACC 425 (MIS) - 1
d. 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.
4. 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
5. To close the gap between Core Clean, a high-level functional language, and
machine code, the ABC machine is used. This is an imperative abstract graph rewriting
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.
6. The runtime system, 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
7. Clean is available for Microsoft Windows, Apple Macintosh, Solaris and Linux.
Some libraries are not available on all platforms, like Object IO which is only available
on Windows and Mac. The feature to write dynamics to files is only available on
Windows.
References
1. "Download Clean" [Link]

2. "FAQ - Clean" ([Link]

3. [Link]

UJ/2016/MS/0520 TIJANI KEHINDE HUSSEIN – ACC 425 (MIS) - 2

Common questions

Powered by AI

Clean's graph rewriting model is significant because it facilitates efficient computation and potential parallelism. By representing programs as graphs, Clean can apply transformations natively, leading to high performance. This model also inherently supports parallel computation as graph reductions can be done concurrently, depending on data dependencies. Consequently, Clean can execute high-level abstractions rapidly, positioning it favorably against similar functional languages .

Clean's development history since 1987, including its borrowing elements from Haskell and focusing on the uniqueness typing system and graph rewriting model, has profoundly influenced its current features. This history explains its comparable performance with Haskell and robust design for managing side effects. Continuous improvements have kept Clean competitive, as evidenced by performance benchmarks showing it matches Haskell in efficiency. Its historical focus on graph rewriting and efficient code generation remains central to its features today .

The ABC machine includes three main components: the graph store, the A(rgument)-stack, and the B(asic value)-stack. The graph store holds the Clean program being rewritten, allowing for graph transformations. The A-stack holds pointers to nodes, facilitating pattern matching. The B-stack efficiently manages basic values like integers and characters. These components enable effective graph rewriting and machine code generation, crucial for Clean’s high performance across multiple architectures .

Clean's availability across multiple platforms including Windows, Mac, Solaris, and Linux, influences development practices by offering a broad deployment scope. However, developers must consider platform-specific library availability and features when designing software, as some functionalities like Object IO are Windows and Mac exclusive, and dynamic writing is only on Windows. These differences necessitate strategic planning for cross-platform compatibility and may dictate the extent of functionality implemented for specific platforms .

Clean supports Microsoft Windows, Apple Macintosh, Solaris, and Linux. However, there are limitations, such as certain libraries not being available on all platforms. For example, the Object IO library is only available on Windows and Mac, and the ability to write dynamics to files is exclusive to Windows .

Clean's compilation process involves several steps that optimize its code efficiency. Source files and definition files are converted into Core Clean, then into a platform-independent intermediate language (ABC). The ABC code is then converted to object code via C and linked to form an executable. The use of ABC as an intermediate step, along with the ABC machine for translating high-level functions to machine code, facilitates efficient cross-architecture deployment, crucial for generating optimized executables .

Clean facilitates high abstraction usage through its graph rewriting model and uniqueness typing system. These techniques allow high-level program abstractions to be expressed and executed efficiently, as the compiler can optimize runtime handling of data. By avoiding side effects and enabling parallel computation through unique types, Clean achieves a high degree of abstraction while maintaining performance consistency and efficiency, which is essential for applications requiring tight execution constraints .

Clean handles mutable state through a uniqueness typing system, which differs from Haskell's use of monads. This system allows Clean to generate more efficient code, as the compiler understands that a unique value can only be used once, enabling in-place changes and avoiding unnecessary data replication .

Clean uses a uniqueness typing system for I/O operations, unlike traditional languages that often use sequential or imperative means. This approach ensures that I/O effects are considered single-use, enhancing robustness and avoiding unintended side effects. It requires programmers to think functionally and manage I/O within the constraints of functional paradigms, which can be more complex compared to imperative languages .

The uniqueness typing system in Clean significantly impacts garbage collection and resource management by ensuring that unique values are single-use. This allows the compiler to modify or dispose of values in place without needing complex memory management strategies, optimizing garbage collection. The system reduces overhead associated with reference counting or tracing garbage collection mechanisms, improving overall performance and predictability in resource management .

You might also like