Comparison of functional programming languages

Last updated

The table shows a comparison of functional programming languages which compares various features and designs of different functional programming languages.

Name Pure Lazy evaluation Typing Abstract data types Algebraic data types Data is immutable Type classes Garbage collectionFirst appeared
Common Lisp No [1] Simulated with thunks [2] Dynamic [3] Yes [4] Extension [5] No [6]  ?Yes1984
Scheme No [7] Yes [8] Dynamic [7] Yes [9] Simulated with thunks [10] No [11] NoYes1975
Racket NoDefault in Lazy Racket [12] Dynamic by default, gradual with Typed Racket [13] Yes [14] Yes, with Algebraic Racket [15] Partial [16] NoYes1995
Clojure No [17] Yes [18] Dynamic [19] Yes [20] Yes [21] Yes [22] NoYes2007
Standard ML No [23] No [24] [25] Static [26] YesYesYes [27] NoYes1983
OCaml No [28] Yes [28] Static [29] Yes [30] Yes [31] Yes [32] Simulated with parametric modules [33] Yes1996
F# No [34] Yes [35] Static [36] Yes [37] Yes [38] Yes [39] NoYes2005
Haskell Yes [40] Default [41] Static [42] Yes [40] Yes [43] Yes [44] Yes [45] Yes1990
Scala No [46] Yes [47] Static [46] Yes [48] Yes [48] Yes [49] Yes [50] Yes2004
JavaScript No [51] [ unreliable source? ]Extension [52] Dynamic [53] Extension [54] Extension [55] Partial [56] [57]  ?Yes1995
Clean Yes [58] Yes, with optional strictness annotations [59] Static with uniqueness/optionally dynamic [60] Yes [59] Yes [59] Yes, except for unique types [59] Yes [59] Yes1987
Miranda Yes [61] Default [62] Static [61] Yes [63] Yes [61] YesNoYes1986
SASL Yes [64] YesDynamic [65] YesYesYesNoYes1972
Elixir NoStream module [66] DynamicYesNoYes ?Yes2012
Erlang NoNo [67] DynamicYes [68] NoYes [69]  ?Yes1986
Elm YesNoStatic [70]  ?Yes [71] Yes [70] NoYes2012
Futhark YesNoStatic [72] YesYesYes [70] NoYes2014
Python No [73] Simulated with generatorsDynamic [74] Yes [75] NoPartial [76]  ?Yes1991
Idris Yes [77] Yes [77] Static [77] Yes [77] Yes [77] Yes [77] Yes [77] Yes2007
Nix YesNoStaticNoYesYesNoYes2003
Wolfram Language NoNoStaticYesYesYesNoYes1988
Kotlin NoLazy delegation [78] and Sequence [79] StaticYesNoYesNoYes2011
Swift NoNoStaticYesYesYesNoSwift uses Automatic Reference Counting, which differs from tracing garbage collection but is designed to provide similar benefits with better performance.2014
Julia NoNo [80] Dynamic [81] Yes [81] NoPartial [81]  ?Yes2012
PureScript YesNoStaticYesYesYesYesYes2013
Rust NoLazy iterators [82] and external libraries [83] Static [84] Yes [85] Yes [86] Yes [87] Yes, through traits [85] No2010
Bosque NoNoStaticYesYesYes ?Yes2019
D Optional [88] [89] Optional [90] Static [91]  ?YesYes [92] NoYes [93] 2001
Gleam No [94] Experimental external librariesStaticYesYesYesNoYes2019

Related Research Articles

In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that map values to other values, rather than a sequence of imperative statements which update the running state of the program.

This is a "genealogy" of programming languages. Languages are categorized under the ancestor language with the strongest influence. Those ancestor languages are listed in alphabetic order. Any such categorization has a large arbitrary element, since programming languages often incorporate major ideas from multiple sources.

In object-oriented (OO) and functional programming, an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object, which can be modified after it is created. In some cases, an object is considered immutable even if some internally used attributes change, but the object's state appears unchanging from an external point of view. For example, an object that uses memoization to cache the results of expensive computations could still be considered an immutable object.

Programming languages can be grouped by the number and types of paradigms supported.

In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assignment statement is a fundamental construct.

Metaprogramming is a computer programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyse, or transform other programs, and even modify itself, while running. In some cases, this allows programmers to minimize the number of lines of code to express a solution, in turn reducing development time. It also allows programs more flexibility to efficiently handle new situations with no recompiling.

In computing, a persistent data structure or not ephemeral data structure is a data structure that always preserves the previous version of itself when it is modified. Such data structures are effectively immutable, as their operations do not (visibly) update the structure in-place, but instead always yield a new updated structure. The term was introduced in Driscoll, Sarnak, Sleator, and Tarjan's 1986 article.

An expression-oriented programming language is a programming language in which every construction is an expression and thus yields a value. The typical exceptions are macro definitions, preprocessor commands, and declarations, which expression-oriented languages often treat as statements.

In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recursion is particularly useful, and is often easy to optimize in implementations.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are intended to address criticisms of Java.

Programming languages are used for controlling the behavior of a machine. Like natural languages, programming languages follow rules for syntax and semantics.

A foreign function interface (FFI) is a mechanism by which a program written in one programming language can call routines or make use of services written or compiled in another one. An FFI is often used in contexts where calls are made into binary dynamic-link library.

QuickCheck is a software library, specifically a combinator library, originally written in the programming language Haskell, designed to assist in software testing by generating test cases for test suites – an approach known as property testing.

In functional programming, filter is a higher-order function that processes a data structure in some order to produce a new data structure containing exactly those elements of the original data structure for which a given predicate returns the boolean value true.

A hash array mapped trie (HAMT) is an implementation of an associative array that combines the characteristics of a hash table and an array mapped trie. It is a refined version of the more general notion of a hash tree.

<span class="mw-page-title-main">Clojure</span> Dialect of the Lisp programming language on the Java platform

Clojure is a dynamic and functional dialect of the Lisp programming language on the Java platform.

<span class="mw-page-title-main">Rosetta Code</span> Wiki-based programming chrestomathy

Rosetta Code is a wiki-based programming chrestomathy website with implementations of common algorithms and solutions to various programming problems in many different programming languages. It is named for the Rosetta Stone, which has the same text inscribed on it in three languages, and thus allowed Egyptian hieroglyphs to be deciphered for the first time.

References

  1. "LISP Introduction" . Retrieved 26 November 2013.
  2. Antoniotti, Marco. "CLAZY: Lazy Calling in Common Lisp" . Retrieved 26 November 2013.
  3. Tratt, Laurence (July 2009). "Dynamically Typed Languages". Advances in Computers. 77: 149–184. doi:10.1016/s0065-2458(09)01205-4 . Retrieved 26 November 2013.
  4. "LISP Tutorial Lecture 3: Data Abstraction".
  5. "Algebraic data types in Common Lisp". GitHub . Retrieved 11 May 2020.
  6. "Mutable Data Structures" (PDF). Retrieved 28 November 2013.
  7. 1 2 "Similar Functional Languages" . Retrieved 26 November 2013.
  8. "(Scheme) 17. Lazy Evaluation" . Retrieved 30 April 2020.
  9. "Records - Revised6 Report on the Algorithmic Language Scheme" . Retrieved 11 May 2020.
  10. "Algebraic Data Types in Scheme" . Retrieved 11 May 2020.
  11. "Programs with State" . Retrieved 29 November 2013.
  12. Barzilay, Eli. "Lazy Racket" . Retrieved 8 February 2020.
  13. Tobin-Hochstadt, Sam; St-Amour, Vincent; Dobson, Eric; Takikawa, Asumu. "Typed Racket" . Retrieved 8 February 2020.
  14. "The Racket Guide: Programmer-Defined Datatypes" . Retrieved 8 February 2020.
  15. Griffis, Eric. "Algebraic Racket" . Retrieved 8 February 2020.
  16. Buttrick, Matthew. "Beautiful Racket: Data Structures" . Retrieved 8 February 2020.
  17. "Clojure Functional Programing".
  18. "Clojure - lazy" . Retrieved 27 November 2013.
  19. "Exploring clojure: dynamic typing". 7 December 2012. Retrieved 26 November 2013.
  20. Engelberg, Mark (21 April 2009). "Thoughts On Programming" . Retrieved 26 November 2013.
  21. "clojure-contrib, typing example" . Retrieved 26 November 2013.
  22. "clojure: functional programming overview" . Retrieved 26 November 2013.
  23. "Introduction to Functional Programming" (PDF). Retrieved 26 November 2013.
  24. "Lazy and Eager Evaluation" (PDF). Retrieved 26 November 2013.
  25. Harper, MacQueen, Milner. "Standard ML" (PDF). Section 3.6.{{cite web}}: CS1 maint: multiple names: authors list (link)
  26. Wikibooks:Standard ML Programming/Types
  27. "Mutable and optional data" . Retrieved 28 November 2013.
  28. 1 2 "Functional Programming – OCaml" . Retrieved 26 November 2013.
  29. Hickey, Jason. "Introduction to Objective Caml" (PDF). Section 2.4. Cambridge University Press. Archived from the original (PDF) on 2 October 2013. Retrieved 26 November 2013.
  30. "Type and exception definitions".
  31. "Learn OCaml - Data Types".
  32. "Learn OCaml - Imperative Features".
  33. "Implementing Type-Classes as OCaml Modules" . Retrieved 11 May 2020.
  34. "Learning F#" . Retrieved 6 December 2013.
  35. "Lazy Computations (F#)". Microsoft Developer Network. Retrieved 26 November 2013.
  36. "About F#" . Retrieved 26 November 2013.
  37. "Structures - F#" . Retrieved 11 May 2020.
  38. "Discriminated Unions". 15 September 2021.
  39. "The F# 3.0 Language Specification: 1.1.2 Making Data Simple" (PDF). Retrieved 26 November 2013.
  40. 1 2 "Haskell Wiki" . Retrieved 26 November 2013.
  41. "Haskell Wiki Lazy Evaluation" . Retrieved 26 November 2013.
  42. "Haskell Typing". HaskellWiki. Retrieved 26 November 2013.
  43. "Haskell Wiki Abstract Data Type" . Retrieved 26 November 2013.
  44. "Haskell Wiki" . Retrieved 27 November 2013.
  45. "Type Classes and Overloading".
  46. 1 2 "Scala Overview" (PDF). Retrieved 26 November 2013.
  47. "Scala by Example" (PDF). Retrieved 26 November 2013.
  48. 1 2 "Scala Reference" (PDF). Retrieved 26 November 2013.
  49. "Mutable and Immutable Collections" . Retrieved 26 November 2013.
  50. "The Neophyte's Guide to Scala Part 12: Type Classes" . Retrieved 29 November 2013.
  51. List of multi-paradigm programming languages#Language overview
  52. Tao, Dan. "Lazy.js". Dan Tao. Retrieved 26 November 2013.
  53. "JavaScript Overview". Mozilla Developer Network. Retrieved 26 November 2013.
  54. Frank, Thomas. "Add some klass to JavaScript". thomasfrank.com. Archived from the original on 8 December 2013. Retrieved 26 November 2013.
  55. Faubion, Nathan. "ADT". NPM. Joyent, nodejitsu. Retrieved 26 November 2013.
  56. Immutable object#JavaScript
  57. "Javascript Data structures". Mozilla Developer Network. Retrieved 26 November 2013.
  58. "FAQ - Clean".
  59. 1 2 3 4 5 Plasmeijer, Rinus; Van Eekelen, Marko; Van Groningen, John (December 2011). Clean Version 2.2 Language Report (PDF). Department of Software Technology, University of Nijmegen. Retrieved 23 May 2018.
  60. "Clean".
  61. 1 2 3 "Miranda Official Website".
  62. "An Overview of Miranda".
  63. "An Overview of Miranda".
  64. Turner, D.A. "An Implementation of SASL". University of St. Andrews, Department of Computer Science Technical Report. TR/75/4.
  65. Kahn, Gilles; Bertot, Yves; Huet, Gérard; Lévy, Jean-Jacques; Plotkin, Gordon (2009-09-24). Kahn networks at the dawn of functional programming. Cambridge University Press. ISBN   9780521518253.
  66. "Stream — Elixir v1.17.2". | title=Stream - Elixir v.1.6.0}}
  67. "Erlang Reference Manual" . Retrieved 27 November 2013.
  68. "Erlang Programming Language - Abstract Patterns".
  69. "Stack Overflow - How do I modify a record in erlang?" . Retrieved 15 December 2013.
  70. 1 2 3 "Elm Blog - Interactive Programming". Archived from the original on 6 October 2013. Retrieved 29 November 2013.
  71. "Elm Syntax - Algebraic Data Types". Archived from the original on 13 March 2016. Retrieved 29 November 2013.
  72. "Type Inference" . Retrieved 24 July 2023.
  73. "Functional Programming in Python".
  74. "What is Python?".
  75. "Abstract Data Types and Stacks" (PDF).
  76. Immutable object#Python
  77. 1 2 3 4 5 6 7 "Idris Overview" . Retrieved 6 December 2013.
  78. "Kotlin - Delegated Properties".
  79. "kotlin-stdlib - kotlin.sequences".
  80. "Noteworthy Differences from Other Languages - The Julia Language".
  81. 1 2 3 "Types - The Julia Language".
  82. "The Rust Programming Language, Processing a Series of Items with Iterators".
  83. "Rust crate 'lazy'".
  84. "The Rust Programming Language, Data Types".
  85. 1 2 "The Rust Programming Language, Traits".
  86. "The Rust Programming Language, Enums".
  87. "The Rust Programming Language, Variables and Mutability".
  88. "D pure functions" . Retrieved 3 February 2024.
  89. "D safe functions" . Retrieved 3 February 2024.
  90. "Laziness - Dlang Tour" . Retrieved 7 April 2020.
  91. "Type System" . Retrieved 7 April 2020.
  92. "Immutable - Dlang Tour" . Retrieved 7 April 2020.
  93. "Garbage Collection" . Retrieved 7 April 2020.
  94. "Frequently asked questions – Gleam".