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. It has turned out to have many similarities to
Forth Forth or FORTH may refer to: Arts and entertainment * ''forth'' magazine, an Internet magazine * ''Forth'' (album), by The Verve, 2008 * ''Forth'', a 2011 album by Proto-Kaw * Radio Forth, a group of independent local radio stations in Scotl ...
, due not to design but to an independent evolution and convergence.


Overview

Functions in Joy lack
formal parameters In computer programming, a parameter, a.k.a. formal argument, is a Variable (computer science), variable that represents an argument, a.k.a. actual argument, a.k.a. actual parameter, to a subroutine call.. A function's function signature, signatu ...
. 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 Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
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 Quicksort is an efficient, general-purpose sorting algorithm. Quicksort was developed by British computer scientist Tony Hoare in 1959 and published in 1961. It is still a commonly used algorithm for sorting. Overall, it is slightly faster than ...
:

DEFINE qsort 

mall Mall commonly refers to a: * Shopping mall * Strip mall * Pedestrian zone * Esplanade Mall or MALL may also refer to: Places Shopping complexes * The Mall (Bromley), London, United Kingdom * The Mall (Patna), Bihar, India * The Mall (Sofia) ...
[] [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 *
Concatenative programming language A concatenative programming language is a point-free computer programming language in which all expressions denote functions, and the juxtaposition of expressions denotes function composition. Concatenative programming replaces function applic ...


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