Archive for the ‘Curl Surge’ Category

Curl Enterprise Framework: refactoring and sub-applets

Sunday, September 28th, 2008

At LogiqueWerks I have replaced the first Curl 6.0 revision of Paul Sheehans ‘Curl Enterprise Framework’ by a slightly re-factored version which uses only the documented sub-applet API’s of Curl 6.0

The original code accompanying the book ‘Enterprise Curl‘ relied on a package ‘IPC’ for inter-process communication which relied on largely undocumented Curl internals. One problem not solved in the port of the framework to Curl 6.0 was that of communication with such transient items as the ’splash screen’ when launched from HTML so as to avoid

Error: InvalidAppletException: Unsupported content-type 'application/octet-stream'

arising from the internal Curl call to Applet.load-next-aux

In the most recent refactoring, launching ‘enterprise-parent.curl‘ results in parent-child calls between that applet and the AppletData of enterprise.curl. However, launching ‘enterprise.curl’ from HTML proved more of a challenge. To allow a simple callback, the package ‘logon’ has now moved within the ‘VMS-MOTORS’ package as has the one ’splashscreen.scurl’ formerly located in a SERVICES package.

In the case of ‘enterprise-parent.curl‘, a parent-callback is used to launch the logon dialog once the splashscreen has run its course. In the case of embedding in ‘enterprise-curl.html‘, the child applet is controlled from a JavaScript function with a call to ‘applet_invoke‘.

The one drawback is that now the Help menu cannot call upon the same SplashScreenManager class to provide the ‘about’ dialog.

The framework is now reduced from 13 to 11 packages. The logon.scurl arguably belonged with the SplashScreenManager in the application code found in VMS-MOTORS where both now reside so as to avoid circular imports from the WINDOWS package.

While the splash screen for ‘VMS MOTORS’ may not be the best illustration of the sub-applet model in Curl, the upside is that there is now a working example which does not use imports from CURL.REMOTE or make explicit reference to ‘remote-connection’ and undocumented Curl such as
{import * from CURL.REMOTE}
{define-remote-class public abstract open ParentInterface
{define-remote-proxy-class ParentProxy}
{define-remote-yxorp-class ParentYxorp}
{remote-method public abstract open {mention-string str:String}:String}
}

But what is available by running ‘enterprise-parent.curl’ with a breakpoint at
set ad.applet-invoke-ready-callback
in the Logon method
{method public {startup-with ad:AppletData}:void
is a view of the underlying sub-applet API features of Curl 6.0 such as
the connection – a TunnelRemoteConnection
the proxy – a TunnelRemoteProxy
none of which are exposed in using only the published API found in the IDE documentation and illustrated in the IDE extended examples.

The LogiqueWerks page also has a link to the example ’shape.curl’ and the various JavaScript tips to be found in ’shape-parent.html’ for the use of AppletData.

The new EnterpriseFramework code now contains an example of a subclass of AppletHistory which might also be of interest.

Several cosmetic features of the example UI for ‘VMS MOTORS’ will see a re-work in the days and weeks to come as my work commitments permit.

Really cool Curl

Thursday, September 13th, 2007

I was pointing out JSForth to a developer on-line (Forth interpreter in JavaScript) which I thought was cool but then I see this in Curl: a folding coding window in a web page.

Here is the Curl 5.0 code for the applet:


{curl 5.0 applet}
{curl-file-attributes character-encoding = "windows-latin-1"}
{applet manifest = "manifest.mcurl"}

{include "./utils/guide-header.scurl"}
{include "./utils/support.scurl"}

   {x-example-ref
        title = "Folding Tree example",
        {url "./examples/RIA_with_Curl.curl"}
    }

What this does is create a labeled hotspot on my page: with one click an entire Curl client-side scripting environment opens. The running example is there; the code that is running is there; buttons to execute, save applet; revert changes; close popup – and the panel allows editing the script.

Clicking on ‘Execute’ causes a popup version of the script to run with your changes.

I had seen this cool way of working with code as part of the example macro

{example

}

What was new was the ‘expandable’ and ‘collapsible’.

I cannot imagine this being more concise in JavaFX or in Groovy. Here is the Curl procedure from the include file:


|| Copyright (C) 1998-2006, Sumisho Computer Systems Corp.
|| All Rights Reserved.
{define-proc {x-example-ref
                 title:String = {message Example},
                 href:Url, ...}:Visual
    let display:Graphic = {example-ref title = title, href, ...}
    {for-each-graphic
        {proc {g:Graphic}:void
            {type-switch g
             case g:TextEditPanel do
                || consume right click, so TreeControl ignores it
                {g.add-event-handler
                    {on e:PointerPress do
                        {if e.button == right-button then
                            {e.consume}}}}}},
        display}
    {return
        {text-width-display
            {expandable
                border-width = 2px,
                {bold {value title}},
                display}}}
}
|| *** calls the following ***
{define-proc public {example-ref
                        loc:Url,
                        title:#String = null,
                        base-url:Url = {get-base-url},
                        manifest:ComponentManifest =
                           {get-default-manifest},
                        package:OpenPackage =
                            {OpenPackage
                                CURL.IMPLICIT.APPLET,
                                CURL.IDE.DOCUMENTATION,
                                manifest = manifest},
                        ...
                    }:Graphic
    let result:any =
        {try
            {evaluate
                base-url = loc,
                package = package,
                {format "\{example title = %w,\n %s\}",
                    title,
                    {read-from loc}}}
         catch e:Exception do
            {paragraph
                Error in {bold {value loc}}:{br}
                {text color = "red", {value e}}}}
    {return {Frame result, ...}}
}

It is perfectly readable. When you see ‘…’ inside { } what you are seeing are rest arguments, or unnamed arguments for variable parameter procedure calls. And then again in the

{ return {Frame result, …} }

– these are not code elisions! The critical {example } macro is in the evaluate block. Dynamic language fans will note that the result is their preferred type: any.

And to learn to use this expand/collapse ‘live’ code environment/widget all I had to do was right-click on a folding code-editor page in the Curl Documentation Viewer which is itself Curl. I copied in the files to include for my applet and set a few imports in my ‘manifest.mcurl’ file. No CLASSPATH to look at, no question of which JARs are where. No JavaScript library required. As cool as Smalltalk, Strongtalk or the XOTcl IDE.

To see one in action, you will need the XML Document Model for Curl 5.0 from curl.com
Just install the RTE, then the IDE and then the XDM. Open your Documentation Viewer and search for ‘WSDK XML Document Model’ or just ‘build-xml

The proc identifies an anonymous procedure and we pass in what Groovy calls a ‘closure’ at on e:PointerPress do or what would likely be an inner class Listener in Java.

If you know something as cool using FLASH with ActionScript, post a snippet or a link to same.
Of course you could do this using AJAX with Prototype and Scriptaculous. But I got this page out in a matter of minutes. Oh yes, Sun says JavaFX is not about ‘throwing up pages’ …

Imagine that you are working on a problematic page. You drop in a gem like this and now you are displaying and experimenting with your code. Only Seaside for Smalltalk can rival this as far as I am aware but that requires some understanding of Smalltalk. I love Seaside, but I know of nothing that can beat this. Of course Rebol 3.0 is on the way …

As for snide remarks from Sun in their JavaFX promo, there are quick ways to throw up a web page… I like blocknote and there is the Meta/HyperCard Revolution product or even MS Word or FrontPage in a pinch…

The Curl IDE in the context of a web page versus Seaside ‘halos’

Sunday, August 12th, 2007

Over at blogspot I have a post on inspecting objects ‘live’ in web pages.
What I neglect to mention there is what is really nice if you are used to using Mercury Interactive and that is the fact that inspectors allow you to flip some properties of an object ‘live’ in your web page.

Suppose you have an inspector open on a widget which occurs more than once on your page. With one click on the inspector’s toolbar you get a color-picklist. You can flip the color of the inspected widget’s background or border ‘live’ on the web page in your browser. Ah … that ListBox!

Curl does not use <FORM> elements in web pages; instead, Curl uses the GUI widgets familiar to anyone who has been building Rich applications in Tk, Smalltalk, Swing or most any other GUI framework.

Once you Ctrl-Right-Click on a Curl control on a web page you will see why I now rank the Curl IDE up there with Seaside for Smalltalk or XOTclIDE (the extended OTcl IDE.)

In the Curl web framework a CONTROLLER represents a joystick-type device and a ‘control’ such as a TreeControl is a CONTROL. No “let’s all pretend this is MVC because that is the OOP TLA” mantra. But with anonymous procedures and macros. As I said, COOL. Maybe not REST, but COOL enough with SOAP or XMLHttpRequest. As those of us with teens have had occasion to say, ‘Give it a rest, will ya?…’

PS Comes with built-in profiling, test coverage for QTP and even HTTP monitoring. A web content language from MIT with lambda functions that does not even look like LISP. Not bad. Readable code for literate web programming. Nothing clever embedded in HTML comments.

|| COOL
|| web2.0
|| comments

and

|COOL-tag
|| web2.0
|| documentation
COOL-tag|

Not a kluge and most have not a clue. Oh yes, MIT. CLU. What was her name?

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.

LRcurl Curlr, LcurlR and (CURL) parentheses

Sunday, June 17th, 2007

LRcurl would be the application of a Right and then a Left curly brace to a CURL expression.

Curl is proud to be LISP-like without the parentheses.

But it is sometimes less than clear how parentheses are to be interpreted in CURL.

It is clear enough how parentheses affect the application of mathematical operators.

But consider this: {let t1:int, t2:int = 42}

You may be aware that this leaves the value of t1 as zero.

So consider this: {set (t1, t2) = (1, 2)}

How are we to understand this as a CURL assignment statement?

The index to the on-line CURL documentation is resoundingly silent on the rationale for this syntax.

Set with parentheses is a fact. Is it because () is an operator?

But why should it not be the case that after {set (t1, t2) = 42} both t1 and t2 are 42 instead of this being a syntax error?

In the case of {set (t1, t2) = {my_func}} we know that the number of values returned by my_func must be two values.

You may want to guess at these values: {let t3:int, t4:int = (3,4)}

If you guessed 0 and 3, can you also tell me why this was not also a syntax error? It is enough to make my curly hair, well, curl left then right.
LcurlR