Clean (programming language)

Clean
Paradigmfunctional
Designed bySoftware Technology Research Group of Radboud University Nijmegen
First appeared1987; 37 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:

Bandar Udara StuttgartFlughafen StuttgartIATA: STRICAO: EDDS STRLokasi bandar udara di Baden-WürttembergInformasiJenisPublikPengelolaFlughafen Stuttgart GmbHLokasiStuttgart, JermanMaskapai penghubung Germanwings Ketinggian dpl389 mdplKoordinat48°41′24″N 009°13′19″E / 48.69000°N 9.22194°E / 48.69000; 9.22194 (Stuttgart Airport)Koordinat: 48°41′24″N 009°13′19″E / 48.69000°N 9.22194°E / 48.69000; 9.22194&#...

 

 

Alexis WajsbrotAlexis WajsbrotLahirAlexis Mickael WajsbrotParis, PrancisPekerjaanSutradara, Supervisor efek visual, Penulis naskahTahun aktif2002–sekarang Alexis Wajsbrot[1] adalah seorang sutradara, produser, dan artis efek visual asal Prancis yang dikenal karena membuat film horor tahun 2016 Don't Hang Up. Debut penyutradaraan Wajsbrot adalah film pendek Red Balloon,[2][3][4][5][6] sebuah film cerita seru 13 menit, dimana ia menjadi sa...

 

 

Sarjana MudaAlbum studio karya Iwan FalsDirilis22 September 1981DirekamJuni - September 1981GenreFolk rock, Country, Pop, Soft rockDurasi44:40LabelMusica Studio'sProduserWilly Soemantri, Amir KatamsiKronologi Iwan Fals 3 Bulan (1980)3 Bulan1980 Sarjana Muda (1981) Opini (1982)Opini1982 Sarjana Muda adalah album debut dari musisi Iwan Fals, Dirilis pada tahun 1981 di bawah bendera Musica Studio. Album ini berisi lagu-lagu Iwan Fals yang menjadi wakil masa itu seperti Oemar Bakri, yang berk...

American television writer, producer This biography of a living person needs additional citations for verification. Please help by adding reliable sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately from the article and its talk page, especially if potentially libelous.Find sources: Jennifer M. Johnson – news · newspapers · books · scholar · JSTOR (January 2012) (Learn how and when to remov...

 

 

English association football player and manager Ryan Mason Mason playing for Tottenham Hotspur in 2015Personal informationFull name Ryan Glen Mason[1]Date of birth (1991-06-13) 13 June 1991 (age 32)[1]Place of birth Enfield, London, EnglandHeight 5 ft 9 in (1.75 m)[1]Position(s) MidfielderTeam informationCurrent team Tottenham Hotspur (assistant coach)Youth career1999–2008 Tottenham HotspurSenior career*Years Team Apps (Gls)2008–2016 Tottenham H...

 

 

土库曼斯坦总统土库曼斯坦国徽土库曼斯坦总统旗現任谢尔达尔·别尔德穆哈梅多夫自2022年3月19日官邸阿什哈巴德总统府(Oguzkhan Presidential Palace)機關所在地阿什哈巴德任命者直接选举任期7年,可连选连任首任萨帕尔穆拉特·尼亚佐夫设立1991年10月27日 土库曼斯坦土库曼斯坦政府与政治 国家政府 土库曼斯坦宪法 国旗 国徽 国歌 立法機關(英语:National Council of Turkmenistan) ...

Rugby league team season 2010 Melbourne Storm seasonNRL Rank16th (wooden spoon)2010 recordWins: 14; draws: 0; losses: 10Points scoredFor: 489; against: 363Team informationCEOBrian Waldron Matt Hanson Frank Stanton (acting) Ron GauciCoachCraig BellamyCaptainCameron Smith (20 Games) Cooper Cronk (3 Games) Adam Blair (1 Game)StadiumAAMI Park – 30,050 (9 Games) Etihad Stadium - 53,500 (3 Games)Avg. attendance14,670High attendance25,480 (Round 4)[a]Top scorersTr...

 

 

County in Kentucky, United States County in KentuckyFloyd CountyCountyFloyd County CourthouseLocation within the U.S. state of KentuckyKentucky's location within the U.S.Coordinates: 37°34′N 82°45′W / 37.56°N 82.75°W / 37.56; -82.75Country United StatesState KentuckyFounded1800Named forJohn FloydSeatPrestonsburgLargest cityPrestonsburgArea • Total396 sq mi (1,030 km2) • Land393 sq mi (1,020 km2)...

 

 

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: Adityapur – news · newspapers · books · scholar · JSTOR (December 2021) (Learn how and when to remove this message) Suburb / Satellite city in Jamshedpur, Jharkhand, IndiaAdityapurSuburb / Satellite cityAdityapurLocation in Jharkhand, IndiaShow map of Jharkhand...

Miniature depiction of Peire Raimon de Tolosa Peire Raimon de Tolosa (or Toloza; fl. 1180–1220)[1] was a troubadour from the merchant class of Toulouse. He is variously referred to as lo Viellz (the Old) and lo Gros (the Fat), though these are thought by some to refer to two different persons.[1] On the other hand, lo Viellz could refer to his being of an early generation of troubadours.[2] Eighteen of Peire Ramon's poems survive, one canso with a melody.[1&#...

 

 

Greek philosopher (c. 371 – c. 287 BC) For the crater, see Theophrastus (crater). This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: Theophrastus – news · newspapers · books · scholar · JSTOR (February 2023) (Learn how and when to remove this message) TheophrastusStatue of Theophrastus, Palermo Botanical GardenBornc. 371 BCEresosDiedc. 287 BC...

 

 

LVTP-5 LVTP-5类型兩棲裝甲運兵車原产地 美国服役记录服役期间1952-参与战争/衝突1958年黎巴嫩危機越戰生产历史研发者博格華納研发日期1950-1951制造数量1124基本规格重量37.4公噸长度9.04公尺宽度3.57公尺高度2.92公尺操作人数3+34 乘員装甲6-16公厘的鋼質裝甲主武器M1919A4機槍(A、A1)、白朗寧M2重機槍(A1與其他款式)、M240通用機槍(LVTH-6)、M49 24倍徑105mm榴彈炮(LVTH-6)、工蜂四型(LVTP-...

南圣地亚哥Santiago do Sul市镇南圣地亚哥在巴西的位置坐标:26°38′20″S 52°41′06″W / 26.6389°S 52.685°W / -26.6389; -52.685国家巴西州圣卡塔琳娜州面积 • 总计73.562 平方公里(28.402 平方英里)海拔450 公尺(1,480 英尺)人口(2007) • 總計1,450人 • 密度19.7人/平方公里(51.1人/平方英里) 南圣地亚哥(葡萄牙语:Santiago do Sul�...

 

 

Battle of GrčaricePart of World War IIDate7—10 September 1943LocationGrčarice, German occupied Yugoslavia, modern-day Slovenia45°39′5.78″N 14°45′20.02″E / 45.6516056°N 14.7555611°E / 45.6516056; 14.7555611Result Partisan victoryBelligerents Slovene Chetniks Slovene PartisansCommanders and leaders Karl Novak Danilo Borut Koprivica Pavle Vošmar Vidmar Milan Kranjc Kajtimar Jaka Avšič Vinko Šumrada-RadošUnits involved Blue Guard:Dolenjska Chetnik Deta...

 

 

大量破壊兵器 種類 生物兵器化学兵器核兵器放射能兵器 国別 アメリカアルジェリア アルゼンチンイギリス イスラエルイタリア イラクイラン インドオーストラリア オランダカナダ スウェーデンドイツ パキスタンフランス ブラジルポーランド 台湾中国 韓国北朝鮮 日本南アフリカ ロシアミャンマー リビア 関連 核兵器の歴史広島・長崎核実験 カテゴリ表話編歴この記...

This list is incomplete; you can help by adding missing items. (January 2015) List of events ← 2010 2009 2008 2011 in the Democratic Republic of the Congo → 2012 2013 2014 Decades: 1990s 2000s 2010s 2020s See also:Other events of 2011History of the DRC The following lists events that happened during 2011 in the Democratic Republic of the Congo. Incumbents President: Joseph Kabila Prime Minister: Adolphe Muzito Events January January 6 - Médecins Sans Frontières accuses the Democ...

 

 

635 battle Battle of BuwaibPart of the Muslim conquest of Sassanid empireMihran bin Badhan's death in the battle, as portrayed in Tārīkhunā bi-uslūb qaṣaṣī (Our History in a Narrative style), published 1935DateApril 635LocationBuwaib (north of Al-Hira), Euphrates, IraqResult Rashidun victoryBelligerents Rashidun Caliphate(Rashidun army) Sassanid Empire(Sassanid army)Commanders and leaders Al-Muthanna ibn Haritha Mihran bin Badhan † vteMuslim conquest of PersiaMesopotamia C...

 

 

Pour les articles homonymes, voir David. Cet article est une ébauche concernant une localité panaméenne. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. San José de DavidDavidNom local DavidGéographiePays  PanamaSubdivision ChiriquíSuperficie 176 km2Altitude 6 mCoordonnées 8° 26′ N, 82° 26′ ODémographiePopulation 89 442 hab.Densité 508,2 hab./km2FonctionnementStatut 5...

أوسركافتمثال لرأس أوسركاف، عثر عليه في معبد الشمس الذي بناهفرعون مصرالحقبةالأسرة المصرية الخامسةسبقهشبسس كاف على الأرجح أو ثامفثيستبعهساحو رع الألقاب الملكية قرينة (ات)نفر حتبس (على الأرجح) أو خنت كاوسأبناءساحو رع، خاماتالأبغير معروف ، من المحتمل أنه أحد ملوك الأسرة الر...

 

 

Rete tranviaria di Monaco di BavieraServizio di trasporto pubblicoTiporete tranviaria urbana Stati Germania CittàMonaco di Baviera Apertura1876 Linee impiegate13  GestoreMVG  Lunghezza79 km Scartamento1435 mm Trasporto pubblico Manuale La rete tranviaria di Monaco di Baviera (in tedesco Straßenbahn München, localmente nota come Tram München) è la rete tranviaria che serve la città di Monaco di Baviera. È gestita dalla società Münchner Verkehrsgesellschaft (MVG) ed...