FACTOID # 28: Libya is the only country with a single-coloured flag.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS   

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Concurrent Clean

Clean is a purely functional programming language that, in some respects, is similar to the better-known Haskell programming language.


Clean has several advantages as a programming language. It features a uniqueness type system, which allows a purely functional way of dealing with resources such as I/O that cannot be duplicated. Clean also has a list comprehension system which can create queries at least as complex as SQL can handle. Clean also uses a more compact format for conditionals. Clean has a very simple and easy-to-use IDE that writes only the project files, not the actual programs. Clean programs are extremely portable; in almost all cases, porting to a different platform simply means a recompile.


The hello world program for Clean is shown below:

 module hello Start :: String Start = "Hello, world!" 

The first line, module hello, tells the compiler that that this module, or part of a project, is called "hello". It has to be stored in a file called hello.icl unless you want to change that line of code. The next line, Start :: String, says that the variable Start, which is the first thing the compiler evaluates, is of the String type. The last line sets the variable Start to "Hello, world!". Since no other output method, such as a GUI, is declared, the words "Hello, world!" just appear in a console box.


Clean is based on the mathematical principle of graph rewriting. Constants such as numbers are graphs, and functions are graph rewriting formulas. Clean programs are evaluated using the well-understood technique of reduction, which essentially reduces everything to a very simple form. Reduction makes programs implemented in Clean relatively fast, even with the high abstraction of the language.


Clean has a very unique compiling system. First, source files (.icl) and project files (.dcl) are converted into Clean's own bytecode (.abc files). This is implemented in C and Clean . The bytecode is completely platform-independent, but it cannot be run. Next, this bytecode is converted to object code (.obj) using C. After that, the object code is linked with other files in the module and the runtime system and converted into a normal executable (done in Clean). Although it seems like there would be bootstrapping issues with this, they are resolved because earlier versions of the Clean system were written completely in C.


Clean was produced and is mantained by the Radboud University Nijmegen. The IDE was written by the Dutch-based company Hilt. It is available for the platforms Windows, Macintosh, Solaris, and Linux, but input-output capabilities are limited on Linux. It is licensed under the GNU LGPL, but it can be used without the LGPL if it is bought for €495. Clean is not developed with an open source development model, though.


Although Clean isn't used much commercially, it is used extensively in research.


Overview

Here is an implementation of the factorial function in Clean:

 fac :: Int -> Int fac 0 = 1 fac n = n * fac (n-1) 

The first line defines the type of the function: an integer as argument and an integer as a result. The second line defines the case when the argument is the constant 0. The second one defines how fac should be computed for an arbitrary n. Note that in Clean the first alternative that matches the actual arguments will be used, that is, the order of the cases is important in Clean. The alternative, supported by several other languages, is to disregard the ordering of the cases, thus requiring that each alternative be disjoint so that only one is applicable in each possible situation.


Each program in Clean computes the value of the expression Start. By providing an appropriate definition for the function Start, the value of any expression can be computed. Thus, the "Hello world" program is just:

 Start :: String Start = "Hello world" 

An infix operator is defined just like every other function except that the type of the function indicates that it is an infix operator, and the operator itself is written within parenthesis:

 (^) infixr 8 :: Int Int -> Int (^) x 0 = 1 (^) x n = x * x ^ (n-1) 

The infixr type declaration states that the function is a right associative infix operator with priority 8: this priority level implies that there are no parenthesis needed in the body of the second case of the operator definition to distinguish (x*x)^(n-1) and x*(x^(n-1)); the (^) operator is pre-defined as a type class in the Clean standard environment.


External links


  Results from FactBites:
 
Catalog of compilers: concurrent, parellel, and simulation languages expanded (1849 words)
Concurrent ML is a concurrent extension of SML/NJ, supporting dynamic thread creation, synchronous message passing on synchronous channels, and first-class synchronous operations.
It provides a simple language for specifying concurrent algorithms, interfaces to Fortran and C, a portable toolkit that allows applications to be developed on a workstation or small parallel computer and run unchanged on supercomputers, and integrated debugging and performance analysis tools.
Concurrent Clean is now a commercial product but it is still free for non-commercial use.
Programming languages (1583 words)
Concurrent Clean is a Haskell-like language with uniqueness typing.
Scala is a concurrent, object-oriented, functional language with a special focus on web services, and designed as a successor to Funnel, a language based on the Join calculus which combines FP with Petri nets.
Comega is an extension of C# with control flow constructs for asynchronous wide-area concurrency and data types for XML and table manipulation.
  More results at FactBites »

 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your location
Your comments
Please enter the 5-letter protection code


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.