Strict programming language

Last updated

A strict programming language is a programming language which employs a strict programming paradigm, allowing only strict functions (functions whose parameters must be evaluated completely before they may be called) to be defined by the user. A non-strict programming language allows the user to define non-strict functions, and hence may allow lazy evaluation. [1]

Contents

Examples

Nearly all programming languages in common use today are strict. Examples include C#, Java, Perl (all versions, i.e. through version 5 and version 7), Python, [2] Ruby, Common Lisp, and ML.

Some strict programming languages include features that mimic laziness. Raku, formerly known as Perl 6, has lazy lists. [3] Python has generator functions. [4] Julia provides a macro system to build non-strict functions, [5] as does Scheme.

Examples for non-strict languages are Haskell, R, Miranda, and Clean. [6]

Explanation

In most non-strict languages the non-strictness extends to data constructors. This allows conceptually infinite data structures (such as the list of all prime numbers) to be manipulated in the same way as ordinary finite data structures. It also allows for the use of very large but finite data structures such as the complete game tree of chess.

Non-strictness has several disadvantages which have prevented widespread adoption:

Strict programming languages are often associated with eager evaluation, and non-strict languages with lazy evaluation, but other evaluation strategies are possible in each case. The terms "eager programming language" and "lazy programming language" are often used as synonyms for "strict programming language" and "non-strict programming language" respectively.

In many strict languages, some advantages of non-strict functions can be obtained through the use of macros or thunks.

Citations

  1. Scott 2006, p. 541.
  2. Lott, Steven (2015). Functional Python Programming. Birmingham, UK: Packt Publishing. p. 35. ISBN   978-1-78439-699-2. Python focuses on strict evaluation
  3. "Raku Programming/Lazy Lists and Feeds - Wikibooks, open books for an open world". en.wikibooks.org. Retrieved 2021-02-09.
  4. Lott, Steven (2015). Functional Python Programming. Birmingham, UK: Packt Publishing. p. 35. ISBN   978-1-78439-699-2. a generator function is non-strict. [...] we can leverage generator functions to create lazy evaluation.
  5. Innes, Mike J. (2021-02-06), MikeInnes/Lazy.jl , retrieved 2021-02-09
  6. Cluet & Hull 1998, pp. 25–26.

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.

A "Hello, World!" program is generally a simple computer program which outputs to the screen a message similar to "Hello, World!" while ignoring any user input. A small piece of code in most general-purpose programming languages, this program is used to illustrate a language's basic syntax. A "Hello, World!" program is often the first written by a student of a new programming language, but such a program can also be used as a sanity check to ensure that the computer software intended to compile or run source code is correctly installed, and that its operator understands how to use it.

In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an expression until its value is needed and which also avoids repeated evaluations.

In computer science, control flow is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language.

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.

In computer science, graph reduction implements an efficient version of non-strict evaluation, an evaluation strategy where the arguments to a function are not immediately evaluated. This form of non-strict evaluation is also known as lazy evaluation and used in functional programming languages. The technique was first developed by Chris Wadsworth in 1971.

In computer science, a generator is a routine that can be used to control the iteration behaviour of a loop. All generators are also iterators. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values. However, instead of building an array containing all the values and returning them all at once, a generator yields the values one at a time, which requires less memory and allows the caller to get started processing the first few values immediately. In short, a generator looks like a function but behaves like an iterator.

<span class="mw-page-title-main">Raku (programming language)</span> Programming language derived from Perl

Raku is a member of the Perl family of programming languages. Formerly known as Perl 6, it was renamed in October 2019. Raku introduces elements of many modern and historical languages. Compatibility with Perl was not a goal, though a compatibility mode is part of the specification. The design process for Raku began in 2000.

In computer science, future, promise, delay, and deferred refer to constructs used for synchronizing program execution in some concurrent programming languages. They describe an object that acts as a proxy for a result that is initially unknown, usually because the computation of its value is not yet complete.

In a programming language, an evaluation strategy is a set of rules for evaluating expressions. The term is often used to refer to the more specific notion of a parameter-passing strategy that defines the kind of value that is passed to the function for each parameter and whether to evaluate the parameters of a function call, and if so in what order. The notion of reduction strategy is distinct, although some authors conflate the two terms and the definition of each term is not widely agreed upon.

<span class="mw-page-title-main">Python syntax and semantics</span> Set of rules defining correctly structured programs

The syntax of the Python programming language is the set of rules that defines how a Python program will be written and interpreted. The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages. It supports multiple programming paradigms, including structured, object-oriented programming, and functional programming, and boasts a dynamic type system and automatic memory management.

<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">Scripting language</span> Programming language for run-time events

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.


Haskell is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell has pioneered a number of programming language features such as type classes, which enable type-safe operator overloading, and monadic input/output (IO). It is named after logician Haskell Curry. Haskell's main implementation is the Glasgow Haskell Compiler (GHC).

The following outline is provided as an overview of and topical guide to the Perl programming language:

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

In computer science, purely functional programming usually designates a programming paradigm—a style of building the structure and elements of computer programs—that treats all computation as the evaluation of mathematical functions.

References