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:

Josh Homme Homme con Queens of the Stone Age en Eurockeenes de Belfort, 2011Información personalNombre de nacimiento Joshua Michael HommeNacimiento 17 de mayo de 1973 (50 años) Palm Springs, California, Estados UnidosNacionalidad EstadounidenseFamiliaCónyuge Brody Dalle (matr. 2007; div. 2019)EducaciónEducado en Marywood-Palm Valley schoolPalm Desert High School Información profesionalOcupación Músico, productorAños activo 1989-presenteGénero Rock alternati...

 

Der Asteriskos auf dem Diskos Der Asteriskus, auch Asteriskos (griech. ἀστερίσκος, asterískos, „kleiner Stern, Sternchen“) ist ein gottesdienstliches Gerät, gebraucht vor allem in der byzantinischen Liturgie, zeitweilig auch in der römischen Papstmesse. Form und Zweck Bei dem Gerät handelt es sich um zwei gebogene Metallstreifen, die kreuzförmig übereinander gelegt und am Schnittpunkt verbunden sind, so dass sie eine Art sternförmige Kuppel bilden. Von dieser Form leitet...

 

Part of a series on the History of Iceland Timeline of Icelandic history Middle ages Settlement of Iceland 870–930 Icelandic Commonwealth 930–1262      Farthings 965      Christianization 999–1118 Sturlung era 1180–1264      Staðamálin 1178–1297 Norwegian rule 1262–1380      Old Covenant 1262 Danish rule 1380–1918      Reformation 1536–1627      Danish trade monopoly 1602–1874 Eruptio...

American digital identity company This article reads like a press release or a news article and may be largely based on routine coverage. Please help improve this article and add independent sources. (September 2023) TelesignType of businessAcquired by BICSFounded2005HeadquartersMarina del Rey, United StatesKey peopleJoe Burton (CEO), Thomas Dhondt (CFO), Mark Hydar (CTO)IndustryDigital identity, fraud prevention, communicationsProductsVoice SMS Digital Identity 2FA RCSURLwww.telesign.co...

 

Dice game by Milton Bradley This article is about the dice game. For the video game journalist, see Ben Yahtzee Croshaw. Not to be confused with the similar, but different game of Yatzy. YahtzeeUK release of the game from the 1980sOther namesCassyDesignersEdwin LoweIllustratorsFiore GmbH Taavi OolbergPeyo Charles M. SchulzPublishersMilton BradleyPublication1956; 67 years ago (1956)Years active1956 –Players2–10Playing time30 minutesChanceHighAge range8+Skillsluckprobabili...

 

Xia Dynasty king and founder Yu禹Song Dynasty depiction of YuKing of the Xia dynastyPredecessorShunSuccessorQiBornShiquan CountyDiedMount KuaijiSpouseLady TushanIssueQi of XiaFatherGunMotherNüzhi (女志) or Nüxi (女嬉)Chinese nameChinese大禹TranscriptionsStandard MandarinHanyu PinyinDà YǔGwoyeu RomatzyhDah YeuWade–GilesTa4 Yü3IPA[tâ ỳ]Yue: CantoneseYale RomanizationDaaih YúhJyutpingDaai6 Jyu5IPA[taːi˨ jyː˩˧]Southern MinHokkien POJTāi-í/Tāi-úOld Chi...

Whyalla di Australia Selatan. Whyalla adalah kota terpadat ketiga di Australia Selatan setelah Adelaide dan Mount Gambier. Whyalla adalah sebuah kota pelabuhan yang terletak dari pantai timur dari Semenanjung Eyre di Australia Selatan. Penduduknya berjumlah 21,122 orang (perkiraan 2006), menjadikannya daerah perkotaan terpadat kedua di negara bagian tersebut setelah Adelaide. Kira-kira 50.6% dari jumlah penduduk adalah laki-laki, 73% adalah kelahiran Australia, 86.3% penduduknya berwarga nega...

 

Medical conditionDu Pan syndromeOther namesFibular hypoplasia and complex brachydactylyRadiograph of the hands of an Egyptian patient with Du Pan syndromeRadiograph of the feet of an Egyptian patient with Du Pan syndromeSpecialtyMedical geneticsSymptomsComplicated brachydactyly and dysplastic/aplastic/hypoplastic fibula bones and hands and feetComplicationsBalanceUsual onsetBirthDurationLife-longCausesGenetic mutationRisk factorsBeing born to consanguineous parents or having a parent with the...

 

Taiwanese politician For the actor and singer, see Jay Shih. In this Chinese name, the family name is Shih. Jay N. ShihShih Neng-chieh施能傑Minister of Directorate-General of Personnel Administration of the Republic of ChinaIn office20 May 2016[1] – 10 February 2022[2]DeputyChang Nien-chung, Su Chun-jungHwai Hsu, Su Chun-jungPreceded byHuang Fu-yuanSucceeded bySu Chun-jungMinister of Research, Development and Evaluation Commission of the Republic of ChinaIn offic...

بطولات العالم للمصارعه 2019 البلد كازاخستان  التقسيم الاعلى نور سلطان  المكان نور سلطان  الموسم 16  تاريخ 2019  تاريخ الانتهاء 22 سبتمبر 2019  عدد المشاركين الموقع الرسمى الموقع الرسمى  تعديل  بطولات العالم للمصارعه 2019 (بالانجليزى: 2019 World Wrestling Championships) هوا موسم ...

 

У этого термина существуют и другие значения, см. танковая армия. 2-я танковая армия 2. Panzerarmee Внешнее обозначение 2-й танковой армии Годы существования 1940—1945 Страна  Германия Входит в сухопутные войска Тип танковая армия Функция танковые войска Прозвища Танковая групп...

 

Radio station in Centerville, IowaKCOGCenterville, IowaBroadcast areaAppanoose County, IowaFrequency1400 kHzBrandingCenterville's True Oldies ChannelProgrammingFormatTrue OldiesAffiliationsAccuWeatherFox News RadioFox Sports RadioOwnershipOwnerEdwin BrandHoney Creek Broadcasting, LLCSister stationsKMGOHistoryFirst air dateFebruary 27, 1949Call sign meaningKeep Calling On GodTechnical informationFacility ID33736ClassCPower500 watts day1000 watts nightTranslator(s)103.9 K280GY (Centerville...

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: Taxman film – news · newspapers · books · scholar · JSTOR (July 2019) (Learn how and when to remove this template message) 1998 filmTaxmanFilm posterDirected byAvi NesherWritten byAvi NesherRoger BergerProduced byAvi NesherKathy Jordan[1]Starring J...

 

Гран-при Бельгии 1950 годанидерл. XII Grote Prijs van Belgiё Дата 18 июня 1950 года Место Бельгия, Спа Трасса Спа-Франкоршам (14120 м) Дистанция 35 кругов, 494,200 км Погода Солнечно, тепло, сухо Поул 4:37 (184 км/ч) Нино ФаринаAlfa-Romeo Быстрый круг 4:34,1 (185,5 км/ч)18-й круг Нино ФаринаAlfa-Romeo Подиум П...

 

Neighborhood in Dallas, Texas Place in Texas, United StatesCity Center DistrictThe majority of these buildings are within the City Center DistrictLocation in DallasCountryUnited StatesStateTexasCountiesDallasCityDallasAreaDowntownElevation459 ft (140 m)ZIP code75201, 75202Area code(s)214, 469, 972 The City Center District is an area in north-central downtown Dallas, Texas (USA). It lies south of the Arts District, north of the Main Street District, northwest of Deep Ellum, southwest...

Bandar Udara H. Hasan AroeboesmanH. Hasan Aroeboesman AirportIATA: ENEICAO: WATEInformasiJenisPublikPemilikKementerian Perhubungan Republik IndonesiaPengelolaDirektorat Jenderal Perhubungan UdaraMelayaniEnde, IndonesiaKetinggian dpl15 mdplKoordinat08°50′57″S 121°39′38″E / 8.84917°S 121.66056°E / -8.84917; 121.66056Koordinat: 08°50′57″S 121°39′38″E / 8.84917°S 121.66056°E / -8.84917; 121.66056Situs webhttp://indo...

 

Тетраподоморфы Eusthenopteron foordiЧетвероногие в широком смысле. Сверху: зелёная литория, акантостега; Снизу: обыкновенная сипуха, обыкновенная лисица Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:Вто...

 

藍天蔚(1878年—1922年3月11日),字秀豪。湖北黄陂人。清末民初军事将领,中国民主革命家。[1] 生平 清末的革命活動 藍天蔚幼年从事学问兼经商。長大后,加入張之洞的新軍,入将弁学堂学习。1902年(光緒28年),经張之洞推薦,赴日本留学。先入成城学校,后入陸軍士官学校。[1] 1903年(光緒29年)春,在日本的中国留学生發起拒俄運動,成立拒俄義勇队。...

Esti artículu o seición necesita referencies qu'apaezan nuna publicación acreitada, como revistes especializaes, monografíes, prensa diaria o páxines d'Internet fiables. Pues añadiles tu mesmu o avisar al autor principal del artículu na so páxina d'alderique pegando: {{subst:Avisu referencies|Autódromu Fernanda Pires da Silva}} ~~~~ Autódromu Fernanda Pires da Silva Autódromu Llocalización País PortugalDistritu portugués Distritu de LisboaConceyu CascaisFreguesia Cascais e Estor...

 

Paghimo ni bot Lsjbot. 47°21′00″S 74°28′00″W / 47.35°S 74.46667°W / -47.35; -74.46667 Islotes Cachos Kapuloan Nasod  Tśile Rehiyon Aysén Gitas-on 1 m (3 ft) Tiganos 47°21′00″S 74°28′00″W / 47.35°S 74.46667°W / -47.35; -74.46667 Timezone BRT (UTC-3)  - summer (DST) EDT (UTC-4) GeoNames 3897470 Kapuloan ang Islotes Cachos sa Tsile.[1] Nahimutang ni sa rehiyon sa Aysén, sa habagatang bahin s...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!