词条 | Clean (programming language) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
释义 |
| name = Clean | logo = | paradigm = functional | year = {{Start date and age|1987}} | designer = Software Technology Research Group of Radboud University Nijmegen | latest_release_version = 3.0 | latest_release_date = {{Start date and age|2018|10|19}} | typing = strong, static, dynamic | operating_system = Cross-platform | license = GNU LGPL, Simplified BSD, commercial software | influenced_by = Lean, Miranda, Haskell | influenced = Haskell, Idris[1] | file_ext = .icl, .dcl, .abc, .sapl | website = {{URL|clean.cs.ru.nl}} }} 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 was developed by a group of researchers from the Radboud University in Nijmegen, 1987. FeaturesThe language Clean first appeared in 1987 and is still being further developed.[2] It shares many properties with Haskell: referential transparency, list comprehension, guards, garbage collection, higher order functions, currying and lazy evaluation. On Windows, an integrated development environment (IDE) is included in the Clean distribution. Clean's method for dealing with mutable state and I/O is done 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.[3] ExamplesHello world: Factorial: Fibonacci sequence: Infix operator: The type declaration states that the function is a right associative infix operator with priority 8: this states that How Clean worksComputation 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.[4] Compiling
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-MachineTo 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.[5] 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, which is linked into every executable, has a PlatformsClean is available for Microsoft Windows, Apple Macintosh, Solaris and Linux. Some libraries are not available on all platforms, like ObjectIO which is only available on Windows and Mac. The feature to write dynamics to files is only available on Windows. LicenseClean is dual licensed: it is available under the terms of the GNU LGPL, and also under a proprietary license. For the libraries, runtime system and examples, not the GNU LGPL but the Simplified BSD License applies.{{citation needed|date=January 2017}} Versus HaskellSpeedA benchmark from 2008 shows that Clean is faster than Haskell in most cases:[6]
As can be seen, Clean outruns Haskell (GHC) on almost all test cases. Only parser combinators are faster in Haskell. Using GHC -O we get some optimisations, making pattern matching and higher order functions faster than in Clean as well. In most cases, however, Clean outperforms GHC -O or at least isn't slower. The programs used were:
Syntactic differencesThe syntax of Clean is very similar to Haskell, with some notable differences:[3]
In general, Haskell has introduced more syntactic sugar than Clean. Community
References1. ^{{cite web|title="Idris - Uniqueness Types"|url=http://docs.idris-lang.org/en/latest/reference/uniqueness-types.html|accessdate=2018-11-20}} 2. ^{{cite web | url=http://wiki.clean.cs.ru.nl/FAQ | title=FAQ - Clean}} 3. ^1 ftp://ftp.cs.ru.nl/pub/Clean/papers/2007/achp2007-CleanHaskellQuickGuide.pdf 4. ^{{cite web|title=Which programming languages are fastest? |url=http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php |website=Computer Language Benchmarks Game |deadurl=bot: unknown |archiveurl=https://web.archive.org/web/20110628185627/http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php |archivedate=28 June 2011 |df= }} 5. ^{{cite book|last1=Koopman|first1=Pieter|title=Functional Programs as Executable Specifications|date=December 10, 1990|publisher=Krips Repro|location=Meppel|isbn=90-9003689-X|page=35}} 6. ^{{cite journal|last1=Jansen|first1=Jan Martin|last2=Koopman|first2=Pieter|last3=Plasmeijer|first3=Rinus|title=From Interpretation to Compilation|date=2008|url=ftp://ftp.cs.ru.nl/pub/Clean/papers/2008/janj08-CEFP07-InterpretationToCompilation.pdf|accessdate=2016-05-21}} External links
4 : Functional languages|Term-rewriting programming languages|Free compilers and interpreters|Cross-platform free software |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。