SUPPORT THE WORK

GetWiki

Oz (programming language)

ARTICLE SUBJECTS
aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
ARTICLE TYPES
essay  →
feed  →
help  →
system  →
wiki  →
ARTICLE ORIGINS
critical  →
discussion  →
forked  →
imported  →
original  →
Oz (programming language)
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{Short description|Multiparadigm programming language}}{{Use dmy dates|date=May 2022}}







factoids
|dialects = Oz, MozartErlang (programming language)>Erlang, Lisp, PrologAlice (programming language)>Alice, Scalamozart.github.io}}}}Oz is a multiparadigm programming language, developed in the Programming Systems Lab at Université catholique de Louvain, for programming-language education. It has a canonical textbook: Concepts, Techniques, and Models of Computer Programming.Oz was first designed by Gert Smolka and his students in 1991. In 1996, development of Oz continued in cooperation with the research group of Seif Haridi and Peter Van Roy at the Swedish Institute of Computer Science. Since 1999, Oz has been continually developed by an international group, the Mozart Consortium, which originally consisted of Saarland University, the Swedish Institute of Computer Science, and the Université catholique de Louvain. In 2005, the responsibility for managing Mozart development was transferred to a core group, the Mozart Board, with the express purpose of opening Mozart development to a larger community.The Mozart Programming System is the primary implementation of Oz. It is released with an open source license by the Mozart Consortium. Mozart has been ported to Unix, FreeBSD, Linux, Windows, and macOS.

Language features

OzBOOK, Gert Smolka, Computer Science Today, The Oz Programming Model, Lecture Notes in Computer Science, 1000, 1995, 324–343, 10.1007/BFb0015252, 978-3-540-60105-0,www.ps.uni-saarland.de/Publications/documents/Vol1000.pdf,
contains most of the concepts of the major programming paradigms, including logic, functional (both lazy evaluation and eager evaluation), imperative, object-oriented, constraint, distributed, and concurrent programming. Oz has both a simple formal semantics (see chapter 13 of the book mentioned below) and {{Citation needed-span|date=June 2007|text=an efficient implementation.}} Oz is a concurrency-oriented language, as the term was introduced by Joe Armstrong, the main designer of the Erlang language. A concurrency-oriented language makes concurrency easy to use and efficient. Oz supports a canonical graphical user interface (GUI) language QTk.WEB,www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/, QTk, 6 April 2009,www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/," title="web.archive.org/web/20130520060646www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/,">web.archive.org/web/20130520060646www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/, 20 May 2013, dead,
In addition to multi-paradigm programming, the major strengths of Oz are in constraint programming and distributed programming. Due to its factored design, Oz is able to successfully implement a network-transparent distributed programming model. This model makes it easy to program open, fault-tolerant applications within the language. For constraint programming, Oz introduces the idea of computation spaces, which allow user-defined search and distribution strategies orthogonal to the constraint domain.

Language overview

Data structures

Oz is based on a core language with very few datatypes that can be extended into more practical ones through syntactic sugar.Basic data structures:
  • Numbers: floating point or integer (real integer)
  • Records: for grouping data : circle(x:0 y:1 radius:3 color:blue style:dots). Here the terms x,y, radius etc. are called features and the data associated with the features (in this case 0,1,3 etc.) are the values.
  • Tuples: Records with integer features in ascending order: circle(1:0 2:1 3:3 4:blue 5:dots) .
  • Lists: a simple linear structure
’|’(2 ‘|’(4 ‘|’(6 ‘|’(8 nil)))) % as a record.2|(4|(6|(8|nil))) % with some syntactic sugar2|4|6|8|nil % more syntactic sugar[2 4 6 8] % even more syntactic sugarThose data structures are values (constant), first class and dynamically type checked. Variable names in Oz start with an uppercase letter to distinguish them from literalsWEB,mozart.github.io/mozart-v1/doc-1.4.0/tutorial/node3.html#label18, 3 Basics, which always begin with a lowercase letter.

Functions

FunctionsBOOK, Leif Grönqvist, Advanced Functional Programming in Oz, Higher Order Functions,www2.gslt.hum.gu.se/~leifg/gslt/doc/ozfunpaper.ps, 3 November 2014,www2.gslt.hum.gu.se/~leifg/gslt/doc/ozfunpaper.ps," title="web.archive.org/web/20160303171453www2.gslt.hum.gu.se/~leifg/gslt/doc/ozfunpaper.ps,">web.archive.org/web/20160303171453www2.gslt.hum.gu.se/~leifg/gslt/doc/ozfunpaper.ps, 3 March 2016, dead, are first class values, allowing higher order functional programming:fun {Fact N}
if N =
< 0 then 1 else N*{Fact N-1} endendfun {Comb N K}
{Fact N} div ({Fact K} * {Fact N-K}) % integers can’t overflow in Oz (unless no memory is left)
endfun {SumList List}
case List of nil then 0
[] H|T then H+{SumList T} % pattern matching on lists
end
endFunctions may be used with both free and bound variables. Free variable values are found using static lexical scoping.ROBERT GENTLEMAN>AUTHOR2=ROSS IHAKA, Lexical Scope in Statistical Computing,www.stat.auckland.ac.nz/~ihaka/downloads/lexical.pdf, Journal of Computational and Graphical Statisticsissue= 3, Systems and Languages pages=491–508, 10.1080/10618600.2000.10474895,

Higher-order programming

Functions are like other Oz objects. A function can be passed as an attribute to other functions or can be returned in a function. fun {Square N} % A general function
N*N
endfun {Map F Xs} % F is a function here - higher order programming
case Xs
of nil then nil
[] X|Xr then {F X}|{Map F Xr}
end
end%usage{Browse {Map Square [1 2 3]}} %browses [1 4 9]

Anonymous functions

Like many other functional languages, Oz supports use of anonymous functions (i.e. functions which do not have a name) with higher order programming. The symbol $ is used to denote these.In the following, the square function is defined anonymously and passed, causing [1 4 9] to be browsed.{Browse {Map fun {$ N} N*N end [1 2 3]}} Since anonymous functions don’t have names, it is not possible to define recursive anonymous functions.

Procedures

Functions in Oz are supposed to return a value at the last statement encountered in the body of the function during its execution. In the example below, the function Ret returns 5 if X > 0 and -5 otherwise.declarefun {Ret X}
if X > 0 then 5 else ~5 end
endBut Oz also provides a facility in case a function must not return values. Such functions are called procedures.WEB,mozart.github.io/mozart-v1/doc-1.4.0/tutorial/node5.html#control.procedure, 5 Basic Control Structures, Procedures are defined using the construct “proc” as followsdeclareproc {Ret X}
if X > 0 then {Browse 5} else {Browse ~5} end
endThe above example doesn’t return any value, it just prints 5 or -5 in the Oz browser depending on the sign of X.

Dataflow variables and declarative concurrency

When the program encounters an unbound variable it waits for a value. For example, below, the thread will wait until both X and Y are bound to a value before showing the value of Z.thread
Z = X+Y
{Browse Z}
endthread X = 40 endthread Y = 2 endThe value of a dataflow variable cannot be changed once it is bound:X = 1X = 2 % errorDataflow variables make it easy to create concurrent stream agents:fun {Ints N Max}
if N == Max then nil
else
{Delay 1000}
N|{Ints N+1 Max}
end
endfun {Sum S Stream}
case Stream
of nil then S
[] H|T then S|{Sum H+S T}
end
endlocal X Y in
thread X = {Ints 0 1000} end
thread Y = {Sum 0 X} end
{Browse Y}
endBecause of the way dataflow variables work, it is possible to put threads anywhere in a program and guaranteed that it will have the same result. This makes concurrent programming very easy. Threads are very cheap: it is possible to have 100,000 threads running at once.WEB,www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency, Archived copy, 29 November 2008,www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency," title="web.archive.org/web/20150224185115www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency,">web.archive.org/web/20150224185115www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency, 24 February 2015, dead,

Example: Trial division sieve

This example computes a stream of prime numbers using the trial division algorithm by recursively creating concurrent stream agents that filter out non-prime numbers:fun {Sieve Xs}
case Xs of nil then nil
[] X|Xr then Ys in
thread Ys = {Filter Xr fun {$ Y} Y mod X = 0 end} end
X|{Sieve Ys}
end
end

Laziness

Oz uses eager evaluation by default, but lazy evaluationJOURNAL, Paul Hudak, Paul Hudak, Conception, evolution, and application of functional programming languages, ACM Computing Surveys, 1989, 21, 3, 359–411 s2cid = 207637854,
is possible. Below, the fact is only computed when value of X is needed to compute the value of Y.
fun lazy {Fact N}
if N =
< 0 then 1 else N*{Fact N-1} endendlocal X Y in
X = {Fact 100}
Y = X + 1
endLazy evaluation gives the possibility of storing truly infinite data structures in Oz. The power of lazy evaluation can be seen from the following code sample:declarefun lazy {Merge Xs Ys}
case Xs#Ys
of (X|Xr)#(Y|Yr) then
if X < Y then X|{Merge Xr Ys}
elseif X>Y then Y|{Merge Xs Yr}
else X|{Merge Xr Yr}
end
end
endfun lazy {Times N Xs}
case Xs
of nil then nil
[] X|Xr then N*X|{Times N Xr}
end
enddeclare HH = 1 | {Merge {Times 2 H} {Merge {Times 3 H} {Times 5 H}}}{Browse {List.take H 6}}The code above elegantly computes all the Regular NumbersRAO, AC >AUTHOR2=VARADA RAJU, D
, amp, Application of the Hamming number technique to detect isomorphism among kinematic chains and inversions, Mechanism and Machine Theory, 26, 1, 55–75, 1991
, 10.1016/0094-114x(91)90022-v,
in an infinite list. The actual numbers are computed only when they are needed.

Message passing concurrency

The declarative concurrent model can be extended with message passing via simple semantics:declarelocal Stream Port in
Port = {NewPort Stream}
{Send Port 1} % Stream is now 1|_ (’_’ indicates an unbound and unnamed variable)
{Send Port 2} % Stream is now 1|2|_
...
{Send Port n} % Stream is now 1|2| .. |n|_
end With a port and a thread, asynchronous agents can be defined:fun {NewAgent Init Fun}
Msg Out in
thread {FoldL Msg Fun Init Out} end
{NewPort Msg}
end

State and objects

It is again possible to extend the declarative model to support state and object-oriented programming with very simple semantics. To create a new mutable data structure called Cells:local A X in
A = {NewCell 0}
A := 1 % changes the value of A to 1
X = @A % @ is used to access the value of A
endWith these simple semantic changes, the whole object-oriented paradigm can be supported. With a little syntactic sugar, OOP becomes well integrated in Oz.class Counter
attr val
meth init(Value)
val:=Value
end
meth browse
{Browse @val}
end
meth inc(Value)
val :=@val+Value
end
endlocal C in
C = {New Counter init(0)}
{C inc(6)}
{C browse}
end

Execution speed

The execution speed of a program produced by the Mozart compiler (version 1.4.0 implementing Oz 3) is very slow. On a 2012 set of benchmarks it averaged about 50 times slower than that of the GNU Compiler Collection (GCC) for the C language.shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php?calc=chart&gcc=on&oz=on" title="archive.today/20120713231944shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php?calc=chart&gcc=on&oz=on">The Computer Language Benchmarks Game

See also

References

{{Reflist|30em}}

External links



- content above as imported from Wikipedia
- "Oz (programming language)" does not exist on GetWiki (yet)
- time: 1:05am EDT - Wed, May 22 2024
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 21 MAY 2024
GETWIKI 09 JUL 2019
Eastern Philosophy
History of Philosophy
GETWIKI 09 MAY 2016
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
GETWIKI 20 AUG 2014
CONNECT