Pure (programming language): Difference between revisions

Content deleted Content added
m <syntaxhighlight>; <pre> for no lang
Line 6:
{{Infobox programming language
|name = Pure
|logo = [[File:Pure lang logo.png]]
|paradigm = [[Functional programming|Functional]], [[Declarative programming|declarative]], [[Rewriting|term rewriting]]
|designer = Albert Gräf
|developer = Albert Gräf
|released = {{Start date and age|2008}}
|latest release version = 0.23
|latest release date = {{Start date and age|2017|01|10|df=yes}}
|typing = [[Strong and weak typing|Strong]], [[DynamicType typingsystem#DYNAMIC|dynamic]]
|implementations =
|dialects =
|operating system = [[Cross-platform]]: [[FreeBSD]], GNU/[[Linux]], [[macOS]], [[Microsoft Windows|Windows]]
|operating_system = Portable
|license = [[GNU Lesser General Public License]]
|influenced_byinfluenced by = Q, [[Haskell (programming language)|Haskell]], [[Lisp (programming language)|Lisp]], [[Alice (programming language)|Alice]], [[MATLAB]]
|influenced =
|website = [http://{{URL|purelang.bitbucket.org/ purelang.bitbucket.org]}}
}}
 
'''Pure''', successor to the equational language '''Q''', is a dynamically typed, [[Functional programming|functional]] [[programming language]] based on [[term rewriting]]. It has facilities for user-defined [[operator (programming)|operator]] syntax, [[Macro (computer science)|macros]], [[arbitrary-precision arithmetic|]] (multiple-precision numbers]]), and compilationcompiling to native code through the [[LLVM]]. ItPure is the[[free successorand toopen-source software]] distributed (mostly) under the [[QGNU (equationalLesser programmingGeneral language)|QPublic programming languageLicense]] version 3 or later.
 
Pure comes with an interpreter and debugger, provides automatic memory management, and has powerful functional and symbolic programming capabilitiesabilities, asand wellinterfaces asto interface[[Library to(computing)|libraries]] in [[C libraries(programming language)|C]] (e.g., for numerics, low-level protocols, and other such tasks). At the same time, Pure is a "''small"'' language designed from scratch; its interpreter is not large, and the library modules are written in Pure itself. The syntax of Pure resembles that of [[Miranda (programming language)|Miranda]] and [[Haskell (programming language)|Haskell]], but it is a [[free-format language]] and thus uses explicit delimiters (rather than [[off-side rule|indentation]] indents) to indicatedenote program structure.
 
The Pure language is a successor of the [[Q (equational programming language)| Q]] language created previouslyformerly by the same author, Albert Gräf at the [[University of Mainz]] in, Germany. ComparedRelative to Q, it offers some important new features (insuch particular,as local functions with [[lexical scoping]], efficient vector and matrix support, and the built-in C interface) and programs run much faster as they are [[Just-in-time compilation|JIT-compiled just-in-time]] to native code on the fly. Pure is mostly aimed at mathematical applications and [[scientific computing]] currently, but its interactive interpreter environment, the C interface and the growing collectionset of addon modules make it suitable for a variety of other applications, such as [[artificial intelligence]], symbolic computation, and real-time multimedia processing.
 
Pure [[pluginsPlug-in (computing)|plug-ins]] are available for the [[Gnumeric]] spreadsheet and Miller Puckette's [[Pure Data]] graphical multimedia software, which make it possible to extend these programs with functions written in the Pure language. Interfaces are also provided as library modules to [[GNU Octave]], [[OpenCV]], [[OpenGL]], the [[GNU Scientific Library]], [[FAUST (programming language)|FAUST]], [[SuperCollider]], and liblo (for [[Open Sound Control|OSC]] (OSC)) are also provided as library modules.
 
Pure is [[free software]] distributed (mostly) under the [[GNU Lesser General Public License]] version 3 (or later).
 
==Examples==
Line 76 ⟶ 75:
</pre>
 
Note the useUse of the <ttcode>&</ttcode> operator which turns the tail of the sieve into a [[thunk]] to delay its computation. The thunk is evaluated implicitly and then [[Memoization|memoized]] (using [[call by need]] evaluation) when the corresponding part of the list is accessed, e.g.:
 
<pre>
Line 82 ⟶ 81:
</pre>
 
Pure has efficient support for vectors and matrices (similar to that provided byof [[MATLAB]] and [[GNU Octave]]), including vector and matrix comprehensions. E.g., a [[Gaussian elimination]] algorithm with [[partial pivoting]] can be implemented as follows in Pure thusly:
 
<pre>
Line 138 ⟶ 137:
</pre>
 
Calling [[C (programming language)|C]] functions from Pure is very easy. E.g., the following imports the <ttcode>puts</ttcode> function from the [[C library]] and uses it to print the string <ttcode>"Hello, world!"</ttcode> on the terminal:
 
<syntaxhighlight lang="c">
Line 147 ⟶ 146:
 
==See also==
{{Portal|Free and open-source software}}
* [[Functional programming]]
* [[:Category: Functional languages|Functional languages]]
Line 161 ⟶ 160:
 
==External links==
* {{officialOfficial website|http://purelang.bitbucket.org/}}
* [http://puredocs.bitbucket.org/ Pure language and library documentation]
* [http://purelang.bitbucket.org/quickref/pure-quickref.pdf Pure quick reference]