![]() |
|
|
| |
|
||||
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, 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. OverviewHere 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 Each program in Clean computes the value of the expression 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 External links
|
|
|
|
|
|
|
|
Copyright 2008 WordIQ.com - Privacy Policy
::
Terms of Use
:: Contact Us
:: About Us This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Clean programming language". |