Oz (programming language): Difference between revisions

Content deleted Content added
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
m State and objects: Adding wikilinks
 
(18 intermediate revisions by 12 users not shown)
Line 1:
{{Short description|Multiparadigm programming language}}
{{Use dmy dates|date=May 20122022}}
{{Infobox programming language
|name = Oz
Line 11 ⟶ 13:
|typing = [[dynamic typing|dynamic]]
|implementations = Mozart Programming System
|license = [[MIT License|MIT X11]]<ref>{{cite web |url=https://mozart.github.io/license-info/ |title=Mozart Oz License Info |date=2014-01-16 |accessdate=January 2014 |access-01-date=16 January 2014}}</ref>
|dialects = Oz, Mozart
|influenced by = [[Erlang (programming language)|Erlang]], [[Lisp (programming language)|Lisp]], [[Prolog]]
Line 17 ⟶ 19:
|website = {{URL|mozart.github.io}}
}}
{{Use dmy dates|date=May 2012}}
 
'''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.
Line 27 ⟶ 28:
==Language features==
Oz<ref name="Oz programming model">
{{cite journalbook
| author = Gert Smolka
| title = TheComputer OzScience Programming ModelToday
| chapter = The Oz Programming Model
|journal series = Lecture Notes in Computer Science
| volume = 1000
| year= 1995
Line 36 ⟶ 38:
| doi = 10.1007/BFb0015252
| isbn = 978-3-540-60105-0
| chapter-url= https://www.ps.uni-saarland.de/Publications/documents/Vol1000.pdf}}
</ref> contains most of the concepts of the major [[programming paradigm]]s, 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 (computer science)|concurrency]]-oriented language, as the term was introduced by Joe Armstrong, the main designer of the [[Erlang (programming language)|Erlang language]]. A concurrency-oriented language makes concurrency easy to use and efficient. Oz supports a canonical [[graphical user interface]] (GUI) language QTk.<ref>{{Cite web |url=http://www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/ |title=QTk |access-date=6 April 2009 |archive-url=https://web.archive.org/web/20130520060646/http://www.mozart-oz.org/home/doc/mozart-stdlib/wp/qtk/html/ |archive-date=20 May 2013 |url-status=deadusurped }}</ref>
 
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 tolerance|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#Computer science|orthogonal]] to the constraint ___domain.
Line 57 ⟶ 59:
[2 4 6 8] % even more syntactic sugar
</syntaxhighlight>
Those data structures are values (constant), [[first-class object|first class]] and [[dynamic typing|dynamically type checked]]. Variable names in Oz start with an uppercase letter to distinguish them from [[Literal (computer programming)|literals]]<ref>{{Cite web|url=https://mozart.github.io/mozart-v1/doc-1.4.0/tutorial/node3.html#label18|title=3 Basics}}</ref> which always begin with a lowercase letter.
 
===Functions===
Line 91 ⟶ 93:
| url= https://www.stat.auckland.ac.nz/~ihaka/downloads/lexical.pdf
|journal=Journal of Computational and Graphical Statistics
|volume= 9|issue= 3, Systems and Languages |date=Sep 2000|pages=491–508}}|doi=10.1080/10618600.2000.10474895
}}
</ref>
 
Line 113 ⟶ 116:
 
====Anonymous functions====
Like many other functional languages, Oz supports use of [[anonymous functionsfunction]]s (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 <code>[1 4 9]</code> to be browsed.
Line 130 ⟶ 133:
end
</syntaxhighlight>
But Oz also provides a facility in case a function must not return values. Such functions are called procedures.<ref>{{Cite web|url=https://mozart.github.io/mozart-v1/doc-1.4.0/tutorial/node5.html#control.procedure|title = 5 Basic Control Structures}}</ref> Procedures are defined using the construct "proc" as follows
<syntaxhighlight lang="erlang">
declare
Line 181 ⟶ 184:
</syntaxhighlight>
 
Because 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.<ref>{{Cite web |url=http://www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency |title=Archived copy |access-date=29 November 2008 |archive-url=https://web.archive.org/web/20150224185115/http://www.mozart-oz.org/documentation/tutorial/node8.html#chapter.concurrency |archive-date=24 February 2015 |url-status=deadusurped }}</ref>
 
===Example: Trial division sieve===
Line 198 ⟶ 201:
Oz uses [[eager evaluation]] by default, but [[lazy evaluation]]<ref name="Lazy Programming">
{{cite journal
| author = [[Paul Hudak]]
| author-link = Paul Hudak
| title = Conception, evolution, and application of functional programming languages
| journal = ACM Computing Surveys
Line 205 ⟶ 209:
| number = 3
| pages = 359–411
| doi=10.1145/72551.72554}}| s2cid = 207637854
}}
</ref> is possible. Below, the fact is only computed when value of X is needed to compute the value of Y.
<syntaxhighlight lang="erlang">
Line 217 ⟶ 222:
</syntaxhighlight>
 
[[lazyLazy 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:
<syntaxhighlight lang="erlang">
declare
Line 244 ⟶ 249:
{{cite journal
|author1=Rao, AC |author2=Varada Raju, D
|lastauthorampname-list-style=yesamp | title = Application of the Hamming number technique to detect isomorphism among kinematic chains and inversions
| journal = Mechanism and Machine Theory
| volume = 26
Line 254 ⟶ 259:
 
=== Message passing concurrency ===
The declarative concurrent model can be extended with [[message passing]] via simple semantics:
<syntaxhighlight lang="erlang">
declare
Line 277 ⟶ 282:
=== 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:
<syntaxhighlight lang="erlang">
local A X in
Line 286 ⟶ 291:
</syntaxhighlight>
 
With these simple semantic changes, the whole object-oriented paradigm can be supported. With a little [[syntactic sugar]], OOP becomes well integrated in Oz.
<syntaxhighlight lang="erlangvisualprolog">
class Counter
attr val
Line 309 ⟶ 314:
 
==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 [[The Computer Language Benchmarks Game|set of benchmarks]] it averagesaveraged about 50 times slower than that of the [[GNU Compiler Collection]] (GCC) for the C language, solving the benchmarks-tasks.{{when|date=September 2017}}<ref>[https://archive.today/20120713231944/http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php?calc=chart&gcc=on&oz=on The Computer Language Benchmarks Game]{{Dead link|date=April 2020 |bot=InternetArchiveBot |fix-attempted=yes }}</ref>{{failed verification|date=February 2014}}
 
==See also==
Line 329 ⟶ 334:
* [http://www.informatik.uni-trier.de/~ley/db/conf/moz/moz2004.html ''Multiparadigm Programming in Mozart/Oz: Proceedings of MOZ 2004'']: Conference which gives a snapshot of the work being done with Mozart/Oz
* [http://people.cis.ksu.edu/~xou/505f10/slides/oz.pdf Programming in Oz]
* [httphttps://strasheela.sourceforge.net/strasheela/doc/01-Basics.html Oz Basics]
 
{{DEFAULTSORT:Oz (programming language)}}