Archive for the ‘Oz-Mozart’ Category

Falcon Programming Language advancing

Saturday, June 27th, 2009

I had a note from Giancarlo Niccolai bring me up-to-date on Falcon which has now reached version 0.9.2

Falcon is a multi-paradigm language – not yet as multiply gifted as Oz, but on its way.

The plans for Falcon from here to 1.0 are very ambitious: like Io, it is a language to keep an eye on. Are you coming with?

Oz 1.4.0 released at mozart-oz.org

Sunday, August 10th, 2008

Oz 1.4.0 was released about a month ago at mozart-oz.org but there are as yet few changes evident at the web site.
For example, the documentation still discusses enabling Oz applets for Netscape … with no mention of any other browser.
The Oz team has been working on enhancing Oz as a language for distributed systems. Here is a quote from mozart-oz.org:

The Mozart system provides state-of-the-art support in two areas: open distributed computing and constraint-based inference. Mozart implements Oz, a concurrent object-oriented language with dataflow synchronization. Oz combines concurrent and distributed programming with logical constraint-based inference, making it a unique choice for developing multi-agent systems. Mozart is an ideal platform for both general-purpose distributed applications as well as for hard problems requiring sophisticated optimization and inferencing abilities.

Oz may be best-known through the MIT Press book by Peter van Roy, known on lambda-the-ultimate as CTM. You can find a list of related papers on Oz at http://www.ps.uni-sb.de/Papers/ among other work of his colleagues. If you have Joe Armstrong’s book on Erlang or remember any Prolog, you might like this book on Oz as a multiparadigm language.

The programming interface of Mozart remains Emacs. After installing Oz, the Oz menu on your Emacs toolbar will now include a Distribution Panel in addition to the debugger and profiler.

O’Reilly has a book coming on real-world Haskell: a book on real-world Oz is over-due.

The next major Oz event will be the (eventual) release of Oz 1.5.0 by which time we should have Rebol 3.0 and a new version of dataflow for Rebol from Liquid Steel tools.

Oz, Ocaml, Alice and Fsharp

Monday, July 9th, 2007

The availability of F# for VisualStudio.net (for now only available in the VS tool window) raises the prospect of multi-paradigm programming on the CLR.

We already have a Haskell for VS and now a variant of Ocaml. There are prolog implementations, a Smalltalk+Lisp, a pascal and so the possibility of a new edition of the CTM book.

In 2004, Peter Van Roy’s excellent, balanced text was only missing C# delegates and attention to Javascript as prototype-based programming. With a few additions it would be an easy re-write for .NET – once there is a version of Alice.NET to stand in for Mozart-Oz.

CTM systematically covers the design decisions that went into multi-paradigm programming in Oz. Along the way there are sections on prolog, pascal, java, C++ and Erlang. But Mozart-Oz has never had an IDE beyond emacs+Tk ( and even without linking in QTk on windows XP, the Oz interactive programming environment sometimes allows a mouse click on the Browser window to send either tk.exe or ozengine.exe into chewing up all the cycles of my CPU.) In fairness, Alice is Gtk. And not to knock Tcl/Tk which I just love regardless. And there is no chapter section on Rebol or domain-specific languages (SQL, XSLT) and no index entry for ISAM. Or M.I.T’s own Curl. Or CLU.

It is just that CTM is not a language book: it is about Concepts, Techniques and Models. There is likely no more even-handed treatment of declarative, imperative and object-oriented programming. And what you get is a thorough introduction to a concurrent form of data-flow programming. The sections on topics such as composition versus inheritance are very fair. Even then, the Beta inheritors of Simula will feel neglected. But they have their own books. As do Scheme and LISP, whose followers might also feel slighted. But Oz flows from Mercury which was pure prolog.

CTM for Alice-on-CLR could also use a chapter or section on Smalltalk/SOUL, SmallInterfaces, Strongtalk, Self and Slate to fill the gap in its benign neglect of Javascript. After all, what’s a thousand pages once you are over the 900 mark … by adding a bit on Joy, the language and Io, the language, and Cecil/Diesel. Oh, not to forget Squeak/Traits and Croquet, the OS.

The only other thing to make me happier would be to see Pragmatic Programmer have an Oz book to match the Erlang book.

Btw, the Prentice-Hall India version of CTM is on thin paper in mimeo quality (very transparent) but also very affordable.

But the worst of it will be google: just try a search on F# and Alice. Arghhh…

A second edition of CTM will be welcome given the number of relevant developments since its publication by MIT Press (when in Boston, do visit the MIT Press bookstore: it is a treat.)

And if we can not get another edition of CTM, then perhaps a future-of-the-book project would be to have CTM, well, not evolve, but adapt over time … well, Sophie?

Scaling the outer walls: Oz/Mozart, osc and ozengine

Wednesday, June 13th, 2007

Positive: There is an Oz tutorial started at eclectic

Warning: since Unicode there is no longer a single quote and a dbl-quote character: just as the left-Alt key was never the same scan code as the right-Alt key. In all that follows, copy the code into a reliable ANSI code editor and flip all ’single’ quotes to an ANSI apostrophe as on an American ASCII QWERTY keyboard and all dbl quotes to a SHIFT-apostrophe. Otherwise you are left with left single quotes, right-single quotes, left-dbl-quotes and right-dbl-quotes which will cause errors in Mozart. Do not use ‘back-tick’ (unshifted-~) as your apostrophe character.

You should not have to be a Prolog programmer to learn Oz, but short of being one already, what sense could you make of the errors you will encounter trying to follow the introduction to compiling an Oz application? The ‘Aufhebung’ issue again. Or you must almost know it just to learn it.

Here goes.

In Rebol you would just script it so:

write %dump.txt read http://localhost:8080/perl/get_env.prl

But in Oz you will need to compile to a functor, so let’s get started on the tutorial’s Webget.oz

You will need to wrap the file as a functor, so we start with

functor

end

We will open STDIN and STDOUT so we need Open and this will be an Application so we will import both:

functor
import
   Application
   Open
end

What follows is the code from the tutorial which will not compile (not in OPI, not on a cmd line):


functor
import
  Application
  Open
define
   Args = {Application.getArgs record('in'(single type:string)
                                  'out'(single type:string))}
   Status = try
	I={New Open.file init(url:  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
	       end
	    in
	{ Copy}
    end
	catch _ then 1
	end
{Application.exit Status}
end

The warning we will receive will be an arity mismatch for Copy.
I experimented with {CopyWWW _} and with {CopyWWW X} in place of {Copy}
Running ozc -c in TextPad compiles succesfully by using {Copy _} in the first 2 occurences of {Copy}. Ditto for selecting ‘Compile File’ on the emacs oz menu.
Now on to compiling that oza file.
To get the oza file I had to use a cmd session:

ozc -c Webget.oz -o Webget.oza

Otherwise compiling (in TextPad or emacs) gave me just Webget.ozf
Now I could run the ozengine against a web page:

ozengine Webget.oza --in http://localhost:8080/perl/get_env.prl --out dump.txt

The program will only exit with CTRL-C CTRL-C and leaves file handles open but if you are content to run it just once

type dump.txt

Oops… no file?

We back track by revisiting the code.


functor
import
  Application
  Open
  Show           ; we will try to Show Status
define
   Args = {Application.getArgs record(
                'in'(single type:string)
                'out'(single type:string))}  ;; variable names are words
   Status = try
	In={New Open.file init(url:  Args.'in')}
	Out={New Open.file init(name: Args.'out'
        flags:[write create truncate])}
	in
	  local
	      proc { Copy}
	          Str={In read(list:$)}   ;; lhs var name is now a word
	       in
	          if Str=="" then
	             {Out write(vs:Str)} { Copy}
	          end
                     {In close}
                     {Out close}
	       end
	    in
	{ Copy}
    end
               0   ;; this was a missing ZERO as in 'success' ?
                    ;; (given that a ONE follows next on error)
	catch _ then
                    {Show Status}
                    1   ;; any exception is failure -
                        ;; was the file readonly?
	end
{Application.exit Status}     ;; Status remains unknown
end

Now we compile without ARITY issues … but still fail to write a file …

So now to look at file IO.

Hmm. The file io.oz offered for our edification has no error handling.

We try Webget2.oz for local disk files as follows:


functor import Application Open define Args = {Application.getArgs record('in' (single type:string) 'out' (single type:string))} Status = try In={New Open.file init(name: Args.'in')} Out={New Open.file init(name: Args.'out' flags:[write create truncate])} in local proc { Copy } Str={In read(list:$)} in if Str=="" then {Out write(vs:Str)} { Copy } end {In close} {Out close} end in { Copy } end 0 catch _ then 1 end {Application.exit Status} end

Which works great so the issue is reading the URL … It comes up in the browser and Rebol reads it fine as follows:

write %dump.txt “” ; we nix that file
write %dump.txt read http://localhost:8080/perl/get_env.prl

in a Rebol shell. So

if Str\=”" then

must be non-terminating for some URL’s on Win32. So we will read the whole URL first.
Now, how to iterate over a list … and then we start back at Lists and progress to the list module