Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 4020 Oz Programming Language Presentation Chris Savela Zak Roessler.

Similar presentations


Presentation on theme: "COP 4020 Oz Programming Language Presentation Chris Savela Zak Roessler."— Presentation transcript:

1 COP 4020 Oz Programming Language Presentation Chris Savela Zak Roessler

2 COP 4020: Oz Programming Language page 2 Oz: Table of Contents History of Oz Origins of Oz Foundations of Oz Versions of Oz Applications of Oz Oz Language and Basics Programming Conclusion

3 COP 4020: Oz Programming Language page 3 Oz: History History of Oz Oz was conceived in 1991 by Gert Smolka at Saarland University in Sweden Development continued in collaboration with Seif Haridi and Peter van Roy at 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

4 COP 4020: Oz Programming Language page 4 Oz: History History of Oz 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 different flavors of Unix, FreeBSD, Linux, Microsoft Windows, and Mac OS X.

5 COP 4020: Oz Programming Language page 5 Oz: Origins of Oz Oz is an experimental language and draws from experience in programming languages such as: Prolog - general purpose logic programming language associated with artificial intelligence and computational linguistics Erland - is a general-purpose concurrent programming language Lisp/Scheme - is a functional programming language and one of the two main dialects of the programming language Lisp

6 COP 4020: Oz Programming Language page 6 Oz: Foundations Foundations of Oz Oz combines the most important features of object-oriented programming, by providing state, abstract data types, classes, objects, and inheritance Oz provides the most important features of logic programming and constraint programming by providing logic variables, disjunctive constructs, and programmable search strategies.

7 COP 4020: Oz Programming Language page 7 Oz: Foundations Foundations of Oz Oz provides the most important features of functional programming by providing composition syntax, first-class procedures, and lexical scoping. Every entity in Oz is first class including procedures, threads, classes, methods, and objects. A programming language is said to have first-class functions if it treats functions as first-class citizens. Specifically, this means that the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.

8 COP 4020: Oz Programming Language page 8 Oz: Foundations Foundations of Oz Oz is a concurrent language where users can create dynamically any number of sequential threads that can interact with each other. Each thread in Oz is a dataflow thread Executing a statement in Oz proceeds only when all real dataflow dependencies on the variables involved are resolved.

9 COP 4020: Oz Programming Language page 9 Oz: Foundations Foundations of Oz Using the Mozart development environment for Oz one can create a distributed environment for Oz computations. Multiple Oz sites can connect together and automatically behave like a single Oz computation sharing variables, objects and classes and procedures. Sites disconnect automatically when references between entities on different sites cease to exist. In a distributed environment Oz provides language security.

10 COP 4020: Oz Programming Language page 10 Oz: Versions of Oz Oz 1 Supported a fine-grained notion of concurrency where each statement could potentially be executed concurrently. Fine-grained model similar to actor model This model was theoretically appealing, but it had drawbacks: Very hard for the programmer to control resources of the application Very hard to debug Object model was unnecessarily awkward

11 COP 4020: Oz Programming Language page 11 Oz: Versions of Oz Oz 2 Introduced a thread based concurrency model with explicit creation of threads to remedy issues with concurrency from Oz 1. A powerful new object system was introduced that included traditional exception handling. Also constraint solving and search capabilities were enhanced

12 COP 4020: Oz Programming Language page 12 Oz: Versions of Oz Oz 3 – Current version Conservatively extends Oz 2 two new concepts: Functors Software components that specify a module in terms of other module needs Supports incremental construction of program components that may be addressed over the internet by URL’s Futures Logic variable that can be read but not written Allows safe dataflow synchronization over the internet

13 COP 4020: Oz Programming Language page 13 Oz: Applications Applications of Oz Teaching language Developed as a way to teach programming by gradually introducing new concepts and showing what they are good for. To show how all major programming paradigms fit in a uniform framework. Simulations The imitation of the operation of a real-world process or system over time

14 COP 4020: Oz Programming Language page 14 Oz: Applications Applications of Oz Multi-Agent Systems System composed of multiple interacting intelligent agents within an environment. Multi-agent systems can be used to solve problems that are difficult or impossible for an individual agent or a monolithic system to solve Natural Language Processing The process of a computer extracting meaningful information from natural language input and/or producing natural language output. Virtual Reality Applies to computer-simulated environments that can simulate physical presence in places in the real world, as well as in imaginary worlds

15 COP 4020: Oz Programming Language page 15 Oz: Language Basics Language Basics Oz language referred to as syntactic sugar Syntactic Sugar refers to syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for humans to use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer

16 COP 4020: Oz Programming Language page 16 Oz: Language Basics Language Basics Oz is referred to as a small kernel language Oz execution model Consist of dataflow threads observing a shared store. Threads contain statement sequences and communicate through a shared references in the store. A thread is dataflow if it only executes its next statement when all the values the statement needs are available. If a statement needs a value that is not available yet, the thread will block until it can access that value.

17 COP 4020: Oz Programming Language page 17 Oz: Language Basics Oz Data Availability Implemented using logical variables The shared store is not physical memory The shared store is an abstract store which only allows operations that are legal for the entities involved There is no direct way to inspect the internal representations of entities

18 COP 4020: Oz Programming Language page 18 Oz: Language Basics OZ data store can contain Bound and unbound logic variables Cells which are mutable pointers which points to variables Procedures Variables can reference the names of procedures and cells Variables can be bound to any entity, including other variables Variable and produced stores are monotonic, i.e., information can only be added to them, not changed or removed.

19 COP 4020: Oz Programming Language page 19 Oz: Base Environment A mapping of identifiers to values Organized in modules Available via field selection.

20 COP 4020: Oz Programming Language page 20 Oz: Base Environment

21 COP 4020: Oz Programming Language page 21 Oz: Base Environment Module Value Contains procedures that con operate on many types {Value. ‘=‘ X Y}  Unifies {Value ‘==‘ X Y ? B }  Equality {Value. ‘\\=‘ X Y ? B }  Not Equal

22 COP 4020: Oz Programming Language page 22 Oz: Base Environment Module Numbers Contains procedures operating on numbers {Number.is +X ? B }  IsNumber {Number. ‘+’ +FI1 +FI2 ? FI3 }  Sum {Number.pow +FI1 +FI2 ? FI3 }  FI1 to power of FI2

23 COP 4020: Oz Programming Language page 23 Oz: Base Environment Module Floats Contains procedures operating on floats {Float.is +X ? B }  IsFloat {Float. ‘/’ +FI +F2 ? F3 }  F1 divided by F2 {Float.sqrt + F1 ? F2 }  Square Root

24 COP 4020: Oz Programming Language page 24 Oz: Base Environment Module Functor Support for module specification Expression that specifies components of a module

25 COP 4020: Oz Programming Language page 25 Oz: Base Environment Type Oz is dynamically typed A variables type and value are unknown until it is bound to an Oz value. Shares a common structure Float < Number < Value Array < Chunk < Value

26 COP 4020: Oz Programming Language page 26 Oz: Programming Basics Computations performed by a sequential process, executing one statement after another. Process is a thread

27 COP 4020: Oz Programming Language page 27 Oz: Programming Basics Simple programs local X Y Z in s end  Execute s in the scope of X Y Z Another local I F in I = 5 F = 5.5 {Browse [ I F C] } end

28 COP 4020: Oz Programming Language page 28 Oz: Programming Basics - control If Statement if B then S1 else S2 Procedure Can be defined, passed as argument or stored in a record Unique proc {P X1 … Xn} S end

29 COP 4020: Oz Programming Language page 29 Oz: Programming Creating a program that copies files First things first Download and intall Oz environment  Compile with ozc.exe  Run with ozengine.exe

30 COP 4020: Oz Programming Language page 30 Oz: Programming functor end

31 COP 4020: Oz Programming Language page 31 Oz: Programming functor import Application Open end

32 COP 4020: Oz Programming Language page 32 Oz: Programming functor import Application Open define Status = try in catch _ then 1 end end

33 COP 4020: Oz Programming Language page 33 Oz: Programming functor import Application Open define Args = {Application.getargs record(‘in’ (single type:string) ‘out’ (single type:string))} Status = try in catch _ then 1 end end

34 COP 4020: Oz Programming Language page 34 Oz: Programming functor import Application Open define Args = {Application.getargs record(‘in’ (single type:string) ‘out’ (single type:string))} Status = try I = {new Open.file init(source: Args.’in’)} O= {new Open file init(name Args. ‘out’ flags:[write create truncate])} in catch _ then 1 end end

35 COP 4020: Oz Programming Language page 35 Oz: Programming functor import Application Open define Args = {Application.getargs record(‘in’ (single type:string) ‘out’ (single type:string))} Status = try I = {new Open.file init(source: Args.’in’)} O= {new Open file init(name Args. ‘out’ flags:[write create truncate])} in local proc {copy} S={I read(list::$} in if S\=“” then {O write(vs:S)} {copy} end in {copy} end catch _ then 1 end end

36 COP 4020: Oz Programming Language page 36 Oz: Programming functor import Application Open define Args = {Application.getargs record(‘in’ (single type:string) ‘out’ (single type:string))} Status = try I = {new Open.file init(source: Args.’in’)} O= {new Open file init(name Args. ‘out’ flags:[write create truncate])} in local proc {copy} S={I read(list::$} in if S\=“” then {O write(vs:S)} {copy} end in {copy} end catch _ then 1 end {Application.exit Status} end

37 COP 4020: Oz Programming Language page 37 Oz: Programming File AFile B

38 COP 4020: Oz Programming Language page 38 Oz: Conclusions How do programming languages get their power? Traditional languages use libraries to proivde extra functionality. The library approach soon hits a brick wall by the limits of its underlying language. Oz has been designed such that has a small number of concepts can be combined in many ways. The designers of Oz believe the concept approach can go much further and have used this in their design. Oz provides a large set of basic concepts and allows the developers to choose the paradigm needed to solve the problem.

39 COP 4020: Oz Programming Language page 39 Oz: Conclusions Flexibility comes with a price. The execution of OZ is very slow compared to other languages. On a set of benchmarks it about 50 times slower then that of gcc compiler for C.

40 COP 4020: Oz Programming Language page 40 Resources

41 COP 4020 Oz Programming Language Presentation Chris Savela Zak Roessler


Download ppt "COP 4020 Oz Programming Language Presentation Chris Savela Zak Roessler."

Similar presentations


Ads by Google