Archive for July, 2007

A little Lua Datalog

Saturday, July 21st, 2007

What a pleasure.
There is a little Lua Datalog implementation which has gone from version 1.2 to 1.3 so I scrambled to download it. I had just downloaded a newer version of ConceptBase so I was anxious to make a few notes.

And what a pleasure it was: unzip and then launch Cygwin, cd to the dir and one ./configure and one make followed by one make install and then 7 keystrokes to a Datalog shell prompt.

It is great when things build as intended and then actually run when launched.

Lua is widely recognized as a language for managing configuration and the match of Lua with Datalog could only be beat by Rebol or Oz alone. Rebol plus Datalog is that horse-of-a-different color of which you may have ‘erd.

So I have started a page on Datalog and minor SCM issues. I still don’t have my pages up at www.make-config.net so I will link in a few pages here.

If you have worked in JSON or JavaScript or Rebol you will find nothing very unusual in employing Datalog. So don’t shy away because you didn’t like Lisp or Prolog way-back-when. This stuff can be useful. It is supposed to be useful. Think of it as smart-tagging. We will not use any XML. Promise. But you can use it where it is useful. Try not to let it get in the way and use Yaml + reSt if it does.

PS. There is also Datalog available for education: DES. If you remember Turbo Prolog, it is alive and well as PDC Visual Prolog and has an External Database framework that may be of interest to you if Datalog does not meet your needs. PDC need not be daunting if you opt for EZY Prolog as your frontend.

Curl as a Web Content Language

Saturday, July 14th, 2007

You could view the Curl/Surge RTE as a runtime environment to host a domain specific language: a web content language.

Viewed in that light, it is not surprising to find the class

TableContentPrototype

in the package CURL.GUI.BASE

Using the page for the topic ‘Reflection’ in the Curl Documentation Viewer you can modify and execute the following code snippet:


{value
    let p:Package =
        {import-package
            {ComponentSelector name = "CURL.GUI.BASE"}
        }
    let members:VBox = {VBox}
    {for m in {p.get-members} do
        {members.add {String m}}
    }
    {VBox
        {HBox
            {String p & ".get-members : "},
            members
        }
    }
} 

to view the members of CURL.GUI.BASE

But it would be fun to use concrete subclasses of the abstract class TableContentPrototype to explore the parent class.

{import * from CURL.GUI.BASE}
{value
    let t:ClassType = TableContentPrototype
    let members:Table =
        {Table
            {row-prototype
                {cell-prototype t}
            },
            {row-prototype
                {cell-prototype "member"},
                {cell-prototype "name"}
            }
        }
    {for m in {t.get-members search-superclasses? = false} do
        {members.add
            {row-prototype
                {cell-prototype m},
                {cell-prototype m.name}
            }
        }
    }
    members
} 

We are able to use the procedures row-prototype and cell-prototype from the GUI.BASE package to expose the class. The package procedure row-prototype itself returns an instance of a subclass of TableContentPrototype because that is what the package procedure cell-prototype returns. Curl is highly-modular but sensibly so: there are alternate packages and super packages.

To see this all in action, download the Curl RTE and save either code snippet as a .curl file. Add a ‘herald’ at the top of the file as follows:

{curl 5.0 applet}
{applet license=”development”}

Load the file into your browser address field using

file:///C:/any-directory/my-curl-file.curl

and substitute your drive, directory and filename.
Or you can open the file using the FILE menu on your browser’s menu bar.

Or you can simply paste the code snippet into any Curl tutorial or documentation code widget which has an EXECUTE button.

The point of this? Curl is a web content language designed for the internet and intranets. It provides all of the services that are usually obtained with a mix of Java, HTML, CSS and JavaScript. Instead of requiring the Java runtime, it requires the Curl runtime. It is ready for SOA and it was RIA from the get-go.

There are other alternatives but they tend to involve a language + a layout language. Two notable exceptions are Seaside for Smalltalk and Rebol.

But what distinguishes Curl from Smalltalk is what the team at MIT dubbed ‘the gentle curve’ in learning Curl and using Curl. Many software development managers consider JavaScript to be ‘just’ scripting to be done by a ‘web developer’. The perceived need for Google’s Web Toolkit to cope with Java and JavaScript in the Eclipse IDE should give us pause. JavaScript is a very rich language with a capacity to boggle known as ‘unintended closures’. It has been ill-served by the notion that it is a kind of web-Basic script and was completely mis-named by SUN marketing.

Of course there is Ruby on Rails, but if you are going to use Ruby, what was it that decided you against Smalltalk and a mature virtual machine? Seaside with Smalltalk is just hard to beat. The tough call would be Rebol. Rebol is as deep a language as Smalltalk or JavaScript and like any such language, it is a way to express thinking about a problem. It is a software development language which happens to be ideally suited to the internet. It should lead to an OS just as Smalltalk is leading to Croquet. It already boasts an ‘IOS’.

Curl is different. Curl was designed as the language for www. Like JavaScript, it was international from the start by being built for UNICODE. It is most widely used in Japan and Korea to exploit the web in business settings.

JavaScript can be viewed as a branch of Self, which was the next generation of Smalltalk which SUN kept to itself as they did Strongtalk, the typed-Smalltalk. As ECMAScript, JavaScript may soon cease to be a dynamically-typed, prototype-based language. At that point it may be a better language for some web development or simply be overtaken by Adobe ActionScript and FLASH.

Almost any programming language can fade in a comparison: Rebol fades when compared to Oz as does Ruby when compared to a mature Smalltalk implementation. But Curl can stand on it’s own as a web content language. Rebol’s strength is in it’s ease of parsing, its dialects and its internet savvy. And its European community and US leader, Carl Sassenrath. Curl’s strength is in the breadth of its code packages and the ‘gentle curve’. And the number of its core team members who have been with Curl since it spun-off at MIT. And the number of its team members from the Far East. Its few annoyances could be readily addressed with a little syntactic sugar. It is a one-stop web language. And it is cool to Curl.

Early adoption of Curl in the LATIN-1 world may have been delayed by the dot-com crash: it was not hurt in countries where UNICODE matters to business. If you are looking to build a rich internet application, Curl5 deserves consideration. Besides, Rebol3 is still a few weeks away …

Curl IDE and the Curl Documentation Viewer

Friday, July 13th, 2007

With an effort underway to create more visibility for the Curl/Surge RTE as a strategy and a language for Web 2.0 with RIA and SOA, you might find yourself looking for a book on Curl. You are not likely to find one at your local bookstore.
The very readable Enterprise Curl book by Paul Sheehan is available as an e-book online at Safari with the source ZIP file at PTR. The book is not the best place to start Curl and dates from 2003 so you will want to keep the Curl Documentation Viewer open and handy. Or you could look for a copy of Kevin Hanegan’s Practical Guide to Curl. Even then you will be well-served by the Documentation Viewer.
The reason is that the pages contain embedded Curl text widgets with code snippets which you can modify and execute right there in the document. If the folks at Mozart-Oz ever look to redo the Oz documentation using their .oza applets, they could not go far wrong to follow this model. I can only hope to see the same for Scala and JavaFX. There is something similar for JavaScript at the the W3C tutorial but those web pages lack the structure of the Curl application.

You see, the Document Viewer is also a folding-outline browser which allows you to control what is presented and to what depth.
For example, none of the available books cover Curl5 which has added many new packages and elaborated still more of the pre-existing packages. Take a quick search for Sequence-of. The result is a page where one click brings us to

CURL.LANGUAGE.CONTAINERS (package)

Purpose: This package contains most of the container classes in the CurlĀ® language. The entire Aggregate-of hierarchy is included in this package.

Notes

A notable container class that is not in this package is FastArray-of.

with its two very pertinent annotations. Had we stayed on the Sequence-of page, a single click on the folded-outline arrowhead at methods would have exposed the API. If you have used Microsoft OneNote you will appreciate the several buttons on the toolbar for controlling the folding outline.

What I do miss is what I had years ago in Microsoft’s old QuickHelp format used with QuickC with Assembler and such: the ability to add my own notes and tags to the documentation. But Curl is highly extensible, so I will look into doing just that!

The other thing that I have done for my work in Curl is to adapt an ‘ASP-JScript’ .syn file for TextPad5. I have not yet seen an .scurl file for JEdit and I am yet to assemble a template TCL file for TextPad5 (which does not do code-folding) but a good editor is hard to let go of when browsing code… especially if you like to be able to flip between an implementation in one language and a similar implementation in another. It is only when code is being maintained, packaged or versioned that the IDE is the place to be … whether VisualStudio or Eclipse, JEdit or JetBrains Idea for Java or the Dolphin Smalltalk Packages Editor.

If a Curl for Dummies should appear this year, some JavaScript AJAX developers may have a chance to explain to management why it is not also necessary to GWiT their day jobs.

tip: if using TextPad always save your Curl .scurl source files as UNIX file format and UTF-8 encoding.

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?

Rebol 3.0 and join with URL!

Monday, July 2nd, 2007

The Rebol list has rejected this post:

; there is an opportunity to review
; join a-url value-or-block
join http://www.rebol.com/request 42
; == http://www.rebol.com/request42
; this might be more useful as
; == http://www.rebol.com/request?42
: so as to permit
join http://www.rebol.com/request [refid store]
; http://www.rebol.com/request?refid=1253df&store=135

Just ask what kinds of values can join to a valid url to give a valid url

This arose from the consideration that

>> join <p> “/” ; result == <p/>
; makes sense, but
>>join <p> <div> ; == <p<div>>   does not make sense
; and that today our
join <> 1 2 (<> 1 2) ; == truetrue
; but requiring join op to be join parens op, i.e.,
join (<> 1 2) (<> 1 2) ; would then permit
join <> p
join <p> {color=”red”} ; etc etc
join <p/> {color=”red”} ; is currently silly result <p/color=”red”>

; or drop join for the tag! datatype ( join is any to any at present )

join <p> ["color" "red"] ; I rest my case as far as Rebol/core is concerned

; Rebol/command is the horse of another color (green when USD)