Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Clean (programming language)

From Wikipedia, the free encyclopedia
(Redirected fromConcurrent Clean)
Functional programming language

Clean
Paradigmfunctional
Designed bySoftware Technology Research Group ofRadboud University Nijmegen
First appeared1987; 39 years ago (1987)
Stable release
3.1 / 5 January 2022; 4 years ago (2022-01-05)
Typing disciplinestrong,static,dynamic
OSCross-platform
LicenseSimplified BSD[1]
Filename extensions.icl, .dcl, .abc
Websiteclean.cs.ru.nl
Influenced by
Lean,Miranda,Haskell
Influenced
Haskell,Idris[2]

Clean is ageneral-purposepurely functionalprogramming language. Originally called theConcurrent Clean System[3] or theClean System,[4][5] it has been developed by a group of researchers from theRadboud University in Nijmegen since 1987.[6][7] Although development of the language has slowed, some researchers are still working in the language.[8] In 2018, a spin-off company was founded that uses Clean.[9]

Features

[edit]

Clean shares many properties andsyntax with a younger sibling language,Haskell:referential transparency,list comprehension,guards,garbage collection,higher order functions,currying, andlazy evaluation. However, Clean deals with mutable state andinput/output (I/O) through auniqueness type system, in contrast to Haskell's use ofmonads. Thecompiler 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 bechanged in place.[10]

Anintegrated development environment (IDE) forMicrosoft Windows is included in the Clean distribution.

Examples

[edit]

Hello world:

Start="Hello, world!"

Factorial:

fac::Int->Intfac0=1facn=n*fac(n-1)Start=fac10
fac::Int->Intfacn=prod[1..n]// The product of the numbers 1 to nStart=fac10

Fibonacci sequence:

fib::Int->Intfib0=1fib1=1fibn=fib(n-2)+fib(n-1)Start=fib7
fibs::IntInt->[Int]fibsx_2x_1=[x_2:fibsx_1(x_2+x_1)]fib::Int->Intfibn=(fibs11)!!nStart=fib7

Infix operator:

(^)infixr8::IntInt->Int(^)x0=1(^)xn=x*x^(n-1)

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

How Clean works

[edit]

Computing is based ongraph rewriting andreduction. 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 toThe Computer Language Benchmarks Game.[11] A 2008benchmark showed that Clean native code performs similarly to theGlasgow Haskell Compiler (GHC), depending on the benchmark.[12]

Compiling

[edit]

Compilation of Clean tomachine 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 andC.
  3. Intermediate ABC code is converted to object code (.o) by the code generator written inC.
  4. Object code is linked with other files in the module and the runtime system and converted into a normal executable using the systemlinker (when available) or a dedicated linker written in Clean onWindows.

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

The ABC machine

[edit]

The ABC code mentioned above is anintermediate representation for anabstract machine. Because machine code generation for ABC code is relatively straightforward, it is easy to support new architectures. The ABC machine is animperative abstractgraph rewriting machine.[13] 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.

Theruntime system, which is linked into every executable, builds aStart 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

[edit]

Although Clean is typically used to generate native executables, several projects have enabled applications inweb browsers.The now abandonedSAPL project compiled Core Clean toJavaScript and did not use ABC code. Since 2019, an interpreter for ABC code, written inWebAssembly, is used instead.[14][15]

Platforms

[edit]

Clean is available forMicrosoft Windows (IA-32 andX86-64),macOS (X86-64), andLinux (IA-32,X86-64, andAArch64).[citation needed]

Some libraries are not available on all platforms, likeObjectIO which is only available on Windows. Also the feature to write dynamics to files is only available on Windows.[citation needed]

The availability of Clean per platform varies with each version:[16][17]

VersionDateLinuxmacOSOracle SolarisWindowsMiscellaneous
IA-32x86-64AArch64Motorola 68040PowerPCx86-64SPARCIA-32x86-64
3.15 January 2022YesYesYesNoNoYesNoYesYes
3.02 October 2018YesYesNoNoNoYesNoYesYes
2.423 December 2011YesYesNoNoNoYesNoYesYes
2.322 December 2010YesYesNoNoNoNoNoYesYes
2.219 December 2006YesYesNoNoYesNoYesYesYes
2.1.131 May 2005YesNoNoNoYesNoYesYesNo
2.1.031 October 2003YesNoNoNoYesNoYesYesNo
2.0.212 December 2002YesNoNoNoYesNoYesYesNo
2.0.14 July 2002YesNoNoNoYesNoYesYesNo
2.021 December 2001NoNoNoNoNoNoNoYesNo
1.3.313 September 2000YesNoNoNoYesNoYesYesNo
1.3.21 July 1999NoNoNoYesYesNoYesYesNo
1.3.1January 1999YesNoNoNoYesNoYesYesNo
1.322 May 1998YesNoNoNoYesNoYesYesNo
1.2.4June 1997NoNoNoYesYesNoNoYesNo
1.2.3May 1997NoNoNoYesYesNoNoYesNo
1.213 January 1997NoNoNoYesYesNoNoNoNo
1.1.3October 1996NoNoNoNoNoNoYesNoNoOS/2 (i80386)
1.1.2September 1996YesNoNoNoNoNoYesNoNoSunOS 4 (SPARC)
1.1March 1996YesNoNoYesNoNoNoNoNo
1.0.2September 1995YesNoNoYesNoNoYesNoNoOS/2 (i80386);SunOS 4 (SPARC)
1.0May 1995NoNoNoYesNoNoNoNoNoOS/2 (i80386)
0.8.411 May 1993YesNoNoYesNoNoNoNoNoExperimentalT800 transputer release
0.8.326 February 1993NoNoNoYesNoNoNoNoNo
0.8.119 October 1992NoNoNoYesNoNoNoNoNo
0.813 July 1992NoNoNoYesNoNoNoNoNoOS/2 (i80386);SunOS 3–4 (SPARC)
0.7May 1991NoNoNoYesNoNoNoNoNoSunOS 3–4 (SPARC)

Comparison to Haskell

[edit]

The syntax of Clean is very similar to that of Haskell, with some notable differences. In general, Haskell has introduced moresyntactic sugar than Clean:[10]

HaskellCleanRemarks
[x|x<-[1..10],isOddx]
[x\\x<-[1..10]|isOddx]
list comprehension
x:xs
[x:xs]
cons operator
dataTreea=Empty|Node(Treea)a(Treea)
::Treea=Empty|Node(Treea)a(Treea)
algebraic data type
(Eqa,Eqb)=>...
...|Eqa&Eqb
class assertions and contexts
funt@(Nodelxr)=...
funt=:(Nodelxr)=...
as-patterns
ifx>10then10elsex
if(x>10)10x
if

References

[edit]
  1. ^"Download Clean".Clean. Retrieved23 July 2019.
  2. ^"Idris - Uniqueness Types". Retrieved20 November 2018.
  3. ^"Clean 0.7: Readme". Archived fromthe original on 24 May 2019.
  4. ^"Clean 1.0: Readme". Archived fromthe original on 5 May 2019.
  5. ^"Clean 1.3: Readme". Archived fromthe original on 27 April 2019.
  6. ^"Radboud University Nijmegen: Department of Software Science: Software".
  7. ^"FAQ".Clean. Retrieved26 November 2021.
  8. ^"Publications".Clean. Retrieved26 November 2021.
  9. ^"Home".TOP Software Technology. Retrieved26 November 2021.
  10. ^ab"FTP link"(PDF).ftp.cs.ru.nl (FTP).[dead ftp link](To view documents seeHelp:FTP)
  11. ^"Which programming languages are fastest?".Computer Language Benchmarks Game. Archived from the original on 28 June 2011.{{cite web}}: CS1 maint: bot: original URL status unknown (link)
  12. ^Jansen, Jan Martin; Koopman, Pieter; Plasmeijer, Rinus (2008)."From Interpretation to Compilation"(PDF).FTP server (FTP). Retrieved21 May 2016.[dead ftp link](To view documents seeHelp:FTP)
  13. ^Koopman, Pieter (10 December 1990).Functional Programs as Executable Specifications (PhD). Katholieke Universiteit Nijmegen. p. 35.ISBN 90-9003689-X.
  14. ^"Clean and iTasks / ABC Interpreter · GitLab".Clean and iTasks on GitLab. Retrieved13 April 2023.
  15. ^Staps, Camil; van Groningen, John; Plasmeijer, Rinus (15 July 2021). "Lazy interworking of compiled and interpreted code for sandboxing and distributed systems".Proceedings of the 31st Symposium on Implementation and Application of Functional Languages. pp. 1–12.doi:10.1145/3412932.3412941.ISBN 9781450375627.S2CID 202751977.
  16. ^"Release history".Clean. Retrieved7 January 2022.
  17. ^"Index of /Clean". Retrieved7 January 2022.

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Clean_(programming_language)&oldid=1292507673"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp