Joy (programming Language)
   HOME

TheInfoList



OR:

The Joy programming language in
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
is a
purely functional programming language 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. Program s ...
that was produced by Manfred von Thun of
La Trobe University La Trobe University is a public university, public research university based in Melbourne, Victoria (Australia), Victoria, Australia. Its main campus is located in the suburb of Bundoora, Victoria, Bundoora. The university was established in 1 ...
in
Melbourne Melbourne ( , ; Boonwurrung language, Boonwurrung/ or ) is the List of Australian capital cities, capital and List of cities in Australia by population, most populous city of the States and territories of Australia, Australian state of Victori ...
,
Australia Australia, officially the Commonwealth of Australia, is a country comprising mainland Australia, the mainland of the Australia (continent), Australian continent, the island of Tasmania and list of islands of Australia, numerous smaller isl ...
. Joy is based on composition of functions rather than
lambda calculus In mathematical logic, the lambda calculus (also written as ''λ''-calculus) is a formal system for expressing computability, computation based on function Abstraction (computer science), abstraction and function application, application using var ...
. It was inspired by the function-level programming style of
John Backus John Warner Backus (December 3, 1924 – March 17, 2007) was an American computer scientist. He led the team that invented and implemented FORTRAN, the first widely used high-level programming language, and was the inventor of the Backus–N ...
's FP (programming language), FP. It has turned out to have many similarities to Forth (programming language), Forth, due not to design but to an independent evolution and convergence.


Overview

Functions in Joy lack Parameter (computer science), formal parameters. For example, a function that squares a numeric input can be expressed as follows: DEFINE square

dup * . In Joy, everything is a function that takes a stack (data structure), stack as an argument and returns a stack as a result. For instance, the numeral '5' does not represent an integer constant, but instead a short program that pushes the number 5 onto the stack. * The dup operator simply duplicates the top element of the stack by pushing a copy of it. * The * operator pops two numbers off the stack and pushes their product. So the square function makes a copy of the top element, and then multiplies the two top elements of the stack, leaving the square of the original top element at the top of the stack, with no need for a formal parameter. This makes Joy concise, as illustrated by this definition of quicksort:

DEFINE qsort 

[small] [] [uncons [>] split] [swapd cons concat] binrec.


Mathematical purity

Joy is a concatenative programming language: "The concatenation of two programs denotes the composition of the functions denoted by the two programs".


See also

* RPL_(programming_language), RPL * Concatenative programming language


References


External links

*
Joy homepage mirror

Joy source code
(GitHub-Archive) * * * * {{cite journal, first=Stevan, last=Apter, title=Functional Programming in Joy and K, journal=Vector, url=http://www.vector.org.uk/archive/v214/joy214.htm, access-date=2011-02-28, archive-url=https://web.archive.org/web/20080828115345/http://www.vector.org.uk/archive/v214/joy214.htm, archive-date=2008-08-28, url-status=dead
mjoy, an interpreter in Lazarus for drawings with turtle graphics
(Subset of Joy)
Joy of Postfix Calculator App
(Subset of Joy) Programming languages Concatenative programming languages Stack-oriented programming languages Functional languages Academic programming languages Programming languages created in 2001 2001 software Dynamic programming languages Dynamically typed programming languages High-level programming languages