Clean (programming language)

Clean
Paradigmfunctional
Designed bySoftware Technology Research Group of Radboud University Nijmegen
First appeared1987; 38 years ago (1987)
Stable release
3.1 / 5 January 2022; 2 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 a general-purpose purely functional programming language. Originally called the Concurrent Clean System[3] or the Clean System,[4][5] it has been developed by a group of researchers from the Radboud 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

Clean shares many properties and syntax with a younger sibling language, Haskell: referential transparency, list comprehension, guards, garbage collection, higher order functions, currying, and lazy evaluation. However, Clean deals with mutable state and input/output (I/O) through a uniqueness type 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 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 be changed in place.[10]

An integrated development environment (IDE) for Microsoft Windows is included in the Clean distribution.

Examples

Hello world:

 Start = "Hello, world!"

Factorial:

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

Start = fac 10
fac :: Int -> Int
fac n = prod [1..n] // The product of the numbers 1 to n

Start = fac 10

Fibonacci sequence:

fib :: Int -> Int
fib 0 = 1
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)

Start = fib 7
fibs :: Int Int -> [Int]
fibs x_2 x_1 = [x_2:fibs x_1 (x_2 + x_1)]

fib :: Int -> Int
fib n = (fibs 1 1) !! n

Start = fib 7

Infix operator:

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

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

How Clean works

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

Compiling

Compilation of Clean to machine 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 and C.
  3. Intermediate ABC code is converted to object code (.o) by the code generator written in C.
  4. 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.

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

The ABC machine

The ABC code mentioned above is an intermediate representation for an abstract machine. Because machine code generation for ABC code is relatively straightforward, it is easy to support new architectures. The ABC machine is an imperative abstract graph 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.

The runtime system, which is linked into every executable, builds a Start 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

Although Clean is typically used to generate native executables, several projects have enabled applications in web browsers. The now abandoned SAPL project compiled Core Clean to JavaScript and did not use ABC code. Since 2019, an interpreter for ABC code, written in WebAssembly, is used instead.[14][15]

Platforms

Clean is available for Microsoft Windows (IA-32 and X86-64), macOS (X86-64), and Linux (IA-32, X86-64, and AArch64).[citation needed]

Some libraries are not available on all platforms, like ObjectIO 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]

Version Date Linux macOS Oracle Solaris Windows Miscellaneous
IA-32 x86-64 AArch64 Motorola 68040 PowerPC x86-64 SPARC IA-32 x86-64
3.1 5 January 2022 Yes Yes Yes No No Yes No Yes Yes
3.0 2 October 2018 Yes Yes No No No Yes No Yes Yes
2.4 23 December 2011 Yes Yes No No No Yes No Yes Yes
2.3 22 December 2010 Yes Yes No No No No No Yes Yes
2.2 19 December 2006 Yes Yes No No Yes No Yes Yes Yes
2.1.1 31 May 2005 Yes No No No Yes No Yes Yes No
2.1.0 31 October 2003 Yes No No No Yes No Yes Yes No
2.0.2 12 December 2002 Yes No No No Yes No Yes Yes No
2.0.1 4 July 2002 Yes No No No Yes No Yes Yes No
2.0 21 December 2001 No No No No No No No Yes No
1.3.3 13 September 2000 Yes No No No Yes No Yes Yes No
1.3.2 1 July 1999 No No No Yes Yes No Yes Yes No
1.3.1 January 1999 Yes No No No Yes No Yes Yes No
1.3 22 May 1998 Yes No No No Yes No Yes Yes No
1.2.4 June 1997 No No No Yes Yes No No Yes No
1.2.3 May 1997 No No No Yes Yes No No Yes No
1.2 13 January 1997 No No No Yes Yes No No No No
1.1.3 October 1996 No No No No No No Yes No No OS/2 (i80386)
1.1.2 September 1996 Yes No No No No No Yes No No SunOS 4 (SPARC)
1.1 March 1996 Yes No No Yes No No No No No
1.0.2 September 1995 Yes No No Yes No No Yes No No OS/2 (i80386); SunOS 4 (SPARC)
1.0 May 1995 No No No Yes No No No No No OS/2 (i80386)
0.8.4 11 May 1993 Yes No No Yes No No No No No Experimental T800 transputer release
0.8.3 26 February 1993 No No No Yes No No No No No
0.8.1 19 October 1992 No No No Yes No No No No No
0.8 13 July 1992 No No No Yes No No No No No OS/2 (i80386); SunOS 3–4 (SPARC)
0.7 May 1991 No No No Yes No No No No No SunOS 3–4 (SPARC)

Comparison to Haskell

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

Haskell Clean Remarks
[ x | x <- [1..10] , isOdd x]
[ x \\ x <- [1..10] | isOdd x]
list comprehension
x:xs
[x:xs]
cons operator
data Tree a
  = Empty
  | Node (Tree a) a (Tree a)
:: Tree a
  = Empty
  | Node (Tree a) a (Tree a)
algebraic data type
(Eq a, Eq b) => ...
... | Eq a & Eq b
class assertions and contexts
fun t@(Node l x r) = ...
fun t=:(Node l x r) = ...
as-patterns
if x > 10 then 10 else x
if (x > 10) 10 x
if

References

  1. ^ "Download Clean". Clean. Retrieved 23 July 2019.
  2. ^ "Idris - Uniqueness Types". Retrieved 20 November 2018.
  3. ^ "Clean 0.7: Readme". Archived from the original on 24 May 2019.
  4. ^ "Clean 1.0: Readme". Archived from the original on 5 May 2019.
  5. ^ "Clean 1.3: Readme". Archived from the original on 27 April 2019.
  6. ^ "Radboud University Nijmegen: Department of Software Science: Software".
  7. ^ "FAQ". Clean. Retrieved 26 November 2021.
  8. ^ "Publications". Clean. Retrieved 26 November 2021.
  9. ^ "Home". TOP Software Technology. Retrieved 26 November 2021.
  10. ^ a b ftp://ftp.cs.ru.nl/pub/Clean/papers/2007/achp2007-CleanHaskellQuickGuide.pdf
  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). Retrieved 21 May 2016. {{cite journal}}: Cite journal requires |journal= (help)
  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. Retrieved 13 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. Retrieved 7 January 2022.
  17. ^ "Index of /Clean". Retrieved 7 January 2022.

Read other articles:

Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menambahkan referensi yang layak. Tulisan tanpa sumber dapat dipertanyakan dan dihapus sewaktu-waktu.Cari sumber: Pianggu, Awang, Barito Timur – berita · surat kabar · buku · cendekiawan · JSTOR PiangguDesaKantor desa PiangguNegara IndonesiaProvinsiKalimantan TengahKabupatenBarito TimurKecamatanAwangKode pos736...

 

 

American politician (1789-1858) John Morin Scott63rd Mayor of PhiladelphiaIn office1841–1844Preceded byJohn SwiftSucceeded byPeter McCallPresident of the Select Council for PhiladelphiaIn office1826–1832Member of the Pennsylvania House of RepresentativesIn office1815–1816, 1839 Personal detailsBorn(1789-10-25)October 25, 1789New York City, U.S.DiedApril 3, 1858(1858-04-03) (aged 68)Philadelphia, Pennsylvania, U.S.Resting placeLaurel Hill Cemetery, Philadelphia, Pennsylvania, U.S.Po...

 

 

Ideology asserting that the Punjabis are a distinct nation This article is about the ideology that asserts Punjabi cultural solidarity. For the militant separatist movement aimed at creating an independent Sikh country, see Khalistan movement. Part of a series onPunjabis History Folklore Language Dialects Punjab Punjabis Nationalism DiasporaAsia Afghanistan Europe United Kingdom North America United States Canada Oceania Australia New Zealand Culture Clothing Cuisine Dance Festivals (India �...

Premium hotel chain Pullman Hotels and ResortsCompany typeSubsidiaryIndustryLuxury hotelsFounded2007 (2007)HeadquartersParis, FranceNumber of locations145Area servedWorldwideParentAccorWebsitepullman.accor.com Pullman Hotels and Resorts is a French multinational upscale hotel brand owned by Accor. Pullman has 145 hotels and resorts in 42 countries spread across Africa, the Americas, Asia, Europe, the Middle-East and Oceania.[1] History Pullman in Sydney Railroad origins The name ...

 

 

Village FairVillage Fair 2006GenreRock, Alternative, Indie, Hip hop, ElectronicDatesLate September – mid-OctoberLocation(s) Australia Mount Panorama, Bathurst, New South Wales Years active1974–currentFounded byVolunteer CSU StudentsWebsitewww.villagefair.com.au Village Fair (VF) is an annual music festival located in Bathurst, Australia which first started as a community Festival for students from rival dormitories of Charles Sturt University, Bathurst campus, in 1974. It has increasingl...

 

 

Railway station in Tamil Nadu, India This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Coimbatore North Junction railway station – news · newspapers · books · scholar · JSTOR (June 2013) (Learn how and when to remove this message) Coimbatore NorthExpress train, Passenger train and Commuter rail stationPlatform...

Smartphones manufactured by Xiaomi Xiaomi Mi 4cCodenamelibraManufacturerXiaomiSeriesMiFirst releasedSeptember 2015DiscontinuedSeptember 22, 2018 (2018-09-22)PredecessorXiaomi Mi 4SuccessorXiaomi Mi 5cRelatedXiaomi Mi 4iTypeSmartphoneForm factorSlate phoneDimensions138.1 × 69.6 × 7.8 mmMass132 gOperating systemOriginal: MIUI 7 (Android 5.1 Lollipop) Current: MIUI 10.1.1.0 (stable) (Android 7.0 Nougat) Unofficial: LineageOS 17.1 (Android 10)System-on-chipQualcomm Snapdragon 808...

 

 

British politician The Right HonourableStephen McPartlandOfficial portrait, 2017Minister of State for SecurityIn office7 July 2022 – 6 September 2022Prime MinisterBoris JohnsonPreceded byDamian HindsSucceeded byTom TugendhatChair of the Regulatory Reform CommitteeIn office28 November 2017 – 20 May 2021Preceded byAndrew BridgenSucceeded byOffice abolishedMember of Parliament for StevenageIn office6 May 2010 – 30 May 2024Preceded byBarbara FollettSucceeded byTBC...

 

 

Spanish languageA manuscript of the Cantar de mio Cid, 13th century Overview Pronunciation stress Orthography Names History Old Middle Influences Grammar Determiners Nouns gender Pronouns personal object Adjectives Prepositions Verbs conjugation irregular verbs Dialects Andalusian Andean Argentine Belizean Bolivian Canarian Caribbean Central American Chilean Colombian Costa Rican Cuban Dominican Ecuadorian Equatoguinean Guatemalan Honduran Mexican Murcian New Mexican Nicaraguan Paraguay Panam...

Acanthoderes daviesii Klasifikasi ilmiah Kerajaan: Animalia Filum: Arthropoda Kelas: Insecta Ordo: Coleoptera Famili: Cerambycidae Subfamili: Lamiinae Tribus: Acanthoderini Genus: Acanthoderes Spesies: Acanthoderes daviesii Acanthoderes daviesii adalah spesies kumbang tanduk panjang yang tergolong familia Cerambycidae. Spesies ini juga merupakan bagian dari genus Acanthoderes, ordo Coleoptera, kelas Insecta, filum Arthropoda, dan kingdom Animalia. Larva kumbang ini biasanya mengebor ke dalam...

 

 

First navy jack of the United States, currently flown only by the oldest warship in the U.S. Navy United States of AmericaThe First Navy Jack, currently flown only by the oldest warship in the U.S. Navy.The First Navy JackProportion2:1AdoptedOctober 13, 1975 (as U.S. naval jack)August 18, 1980 (for oldest U.S. warships)September 11, 2002 (as U.S. naval jack)RelinquishedDecember 31, 1976 (as U.S. naval jack)June 4, 2019 (as U.S. naval jack)Design13 horizontal stripes of alternating red and whi...

 

 

Place in Manitoba, CanadaMoose LakeNASA image showing the location of Moose LakeCommunity boundariesMoose LakeCoordinates: 53°42′0″N 100°17′59.99″W / 53.70000°N 100.2999972°W / 53.70000; -100.2999972CountryCanadaProvinceManitobaCensus division21RegionNorthern RegionArea[1] • Total1.66 km2 (0.64 sq mi)Elevation260 m (840 ft)Population (2011) • Total1,137 • Density684.4/km2 (1,773/sq&#...

Castello di WiltonWilton CastleRovine del castello di Wilton in un'immagine del 2009LocalizzazioneStato Regno Unito Regione/area/distrettoInghilterra LocalitàRoss-on-Wye Coordinate51°54′59.4″N 2°35′49.38″W51°54′59.4″N, 2°35′49.38″W Informazioni generaliCondizioniIn uso CostruzioneXII secolo Usoridotto in rovina, parzialmente in uso come set fotografico Modifica dati su Wikidata · Manuale Il castello di Wilton (in inglese Wilton Castle), noto anche come cas...

 

 

Town in New York, United StatesNorth Salem, New YorkTownTown of North SalemDowntown Croton Falls, a hamlet within the town SealLocation of North Salem, New YorkCoordinates: 41°19′41″N 73°36′47″W / 41.32806°N 73.61306°W / 41.32806; -73.61306CountryUnited StatesStateNew YorkCountyWestchesterIncorporated1788Government • Town SupervisorWarren Lucas (R[1])Area[2] • Total22.939 sq mi (59.41 km2) •...

 

 

Cet article est une ébauche concernant Cuba. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Consultez la liste des tâches à accomplir en page de discussion. Province de Santiago de Cuba Situation de la province à Cuba. Administration Pays Cuba Capitale Santiago de Cuba Démographie Population 1 045 337 hab. (2008) Densité 170 hab./km2 Géographie Coordonnées 20° nord, 76° o...

Жан-Ив Даниель-Лесюрфр. Jean-Yves Daniel-Lesur Основная информация Дата рождения 19 ноября 1908(1908-11-19) Место рождения Париж Дата смерти 2 июля 2002(2002-07-02) (93 года) Место смерти Париж Похоронен кладбище Пасси Страна  Франция Профессии композитор, органист Инструменты орга�...

 

 

Sybase Open 1995Sport Tennis Data6 febbraio – 13 febbraio Edizione107a SuperficieCemento indoor CampioniSingolare Andre Agassi Doppio Jim Grabb / Patrick McEnroe 1996 Il Sybase Open 1995 è stato un torneo di tennis giocato sul cemento indoor. È stata la 107ª edizione del SAP Open, che fa parte della categoria World Series nell'ambito dell'ATP Tour 1995. Si è giocato nell'HP Pavilion di San Jose negli Stati Uniti, dal 6 al 13 febbraio 1995. Indice 1 Campioni 1.1 Singolare 1.2 Doppio 2 Co...

 

 

  لمعانٍ أخرى، طالع هيلزبورو (توضيح). هيلزبورو     الإحداثيات 38°21′05″N 97°12′09″W / 38.3514°N 97.2025°W / 38.3514; -97.2025   [1] تاريخ التأسيس 1879  تقسيم إداري  البلد الولايات المتحدة[2][3]  التقسيم الأعلى مقاطعة ماريون  خصائص جغرافية  المساحة 6.65476...

GaribaldoRe dei LongobardiRe d'ItaliaStemma In carica671 PredecessoreGrimoaldo SuccessorePertarito Nome completoGaribald (in longobardo) Nascita?, 665 circa Morte?, ? PadreGrimoaldo Madre?, sorella di Godeperto e Pertarito Garibaldo (o Gariboldo[senza fonte]; 665 circa) è stato re dei Longobardi e re d'Italia nel 671. Indice 1 Biografia 2 Note 3 Bibliografia 3.1 Fonti primarie 3.2 Letteratura storiografica 4 Voci correlate 5 Collegamenti esterni Biografia Figlio di Gr...

 

 

Cet article est une ébauche concernant un bateau ou un navire et la Royal Navy. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Classe Attacker Le HMS Attacker Caractéristiques techniques Type Porte-avions d'escorte Longueur 151,2 m[1] Maître-bau 21,18 m Tirant d'eau 7,19 m Déplacement 10 200 tonnes Port en lourd 14 170 tonnes Propulsion 1 héliceturbines à vapeur2 ch...