Thursday, September 13, 2007

Cool Curl 'live' code widget

Over at eclectic-pencil I have a post on a very cool Curl widget that rivals almost anything I have ever seen expand and collapse on a web page.

What I neglect to mention is that in the example, the only code to create the XMl tree is this:
   let xmldoc:XDMDocument =
{build-xml preserve-whitespace? = false, loc}
|| ...
{XDMTreeControl open? = true, xmldoc.root}

Which you would be hard-pressed to beat in Seaside for Smalltalk or in Groovy. Concise.

TiScript also has an alternative DOM and some nice features as a JavaScript alternative, but Curl 5.0 is a mature, full RIA product with 'live' code for inspection and a focus on the client-side. It is almost Smalltalk but it was also built for the web (in fairness, Curl goes about as far back as Smalltalk VisualWave.)

The only cool but alive technologies as neglected as Curl 5.0 must be Gemstone/S and Rebol 2.6.3 ... and the latter is soon to be 2.7.x with 3.0 in the wings ...

Watch for a Seaside for Gemstone/S beta in the news soon ...

PS For people living on AIR and FLASH, Rebol/FLASH went 2.0 today ...

Saturday, September 8, 2007

Curl and Occasionally Connected Computing

I have added a page on OCC at wikipedia. What is really interesting to me is the use of a custom URI scheme in Curl. Such a scheme might be
curl://occ/this-redirects-as-needed
which could be used to redirect to a resource depending on whether the user is connected.
If you have experience with OCC, please do contribute to the article. When I have some experience with Curl OCC I will add a page at eclectic-pencil with details and caveats.
To complement the article, I also opened one on CSPD. There are trolls at en.wikipedia.org who delight in suggesting page deletions so your contributions to articles to maintain NPOV or to suggest sensible article merging and separation are much appreciated. No edit wars, please. Solid references for articles are usually the key to survival of any given contribution in my experience.

Monday, August 27, 2007

Links relating to Curl 5.0 as RIA + CSPD

Client-side persistent data or CSPD may be out of favor in the current "I'm OK, stateless's OK" buzz but I like the 'public library' model: I return a book and the only record of my having borrowed it is my own record. Just try to sell that to the Barnes&Noble / Borders / Amazon / BlockBuster / BestBuy / NetFlix "we've got your number crowd". The more radical option is the 'purchase' card whose record does not belong to a bank or credit card conglomerate: I pick the 'bank' for transactions based on interest rate. Talk about competition! Having data 'client-side' need not mean 'local to this box' but rather, "not on your server". On this model your medical records would not be held by doctor PA's, hospitals or insurers. And your privacy could be in much better hands. Ok, I'll give it a REST ...

But my links to Curl which are not links to cURL are slowly coming alive ... and Curl is CSPD friendly. It has not yet seen that client-side 'store' should be opaque to the server, but it may get there. Not middleware. Call it 'periware' and 'exolayer'.
Buy a book at Borders and then go borrow a book at your library. Now make a return at each (don't cheat and read that new book!) Now ask where your medical records belong ( "we know you are in pain, but we need at least 24 hours notice to have your records sent up." I only had to hear it once.)
Having my records at my beck-and-call does not mean that I can 'access' them. It means that I decide who can access them short of a court order. And when. And where. And that is just my medical records.
The fine print on your savings account book may explain that your money is not always available for withdrawal. And in some countries you pay to have an account and fill out forms to make any withdrawal. PayPal is as foreign to those 'service' banks as is client-side data in the current praise for HTTP.
Many years ago, when TCP/IP turned 15, we were asking when the protocol would be replaced altogether. About the same year as we asked 'Is this the year of Unix?' Perhaps the year that I finally see overhead wires go underground, I will see the system of record no longer be the central system, but the peripheral system. Periware. Exolayer. The Exonet, adumbrated. How apposite.

Friday, August 24, 2007

Rebol dialects and Groovy builders

I am working on a blog post over at eclectic-pencil on DSL (domain-specific languages) in Rebol and Groovy. It is an area that the folks at PDC Prolog got into a few years back and that I first explored using Java + Amzi! Prolog with DCG's in Eclipse. I hope to get a piece up on Groovy and categories as mix-ins in comparison to exploring categories and protocols in Logtalk. In the meantime there is a great deal of activity on the SWI-Prolog mailing list often relating to their Java programming interface. And Plone has a new release just as I wait for Rebol3. And I have a new version of the Curl 5.0 Web SDK to check out. And the MindTouch Deki-Wiki up on VMWare as I watch for the Gemstone/S + Seaside beta. Too much!
My opinion of the out-of-print 'Official Guide' to Rebol 2.3 keeps improving: I wish I could say the same of Manning's 'Groovy In Action' or the APress 'Grails' book. Neither of my favorite bookstores had 'Programming Groovy' on the shelves, which might have been a better choice than the former. Of course there is no book on Logtalk to recommend ... yet.

Sunday, August 12, 2007

Documenting a Curl Surge Lab Interface class

Surge Lab had been marketed as the name for the Curl IDE. The IDE has a feature that you may recognize if you use eclipse or Aptana: you can flip from one perspective to another. But the IDE gives only a glimpse of Curl interaction for the developer because, like Smalltalk Seaside 'halos' on a web page, Curl offers a Ctrl-Right-Click which opens text and graphic inspectors on objects embedded in a 'live' web page.

The ctrl-right-click pop-up menu includes viewing and editing the Curl source, inspecting objects and both 'Start Profiling' and 'Start HTTP Monitoring'. (Curl also offers test-coverage tools for HP's Mercury QTP.)

The inspectors are toolbar driven and almost feel like a Smalltalk object inspector becuase one toolbar item is 'Evaluate' which is just like the JavaScript popup in FireFox developer tools. Unfortunately, the inspectors lack some features of a typical Smalltalk inspector. The first that I would add to be Curl-ish would be a 'select-text-F1' event-handler to get the fine Curl doc viewer to popup.

What I will do this morning is include a Curl snippet of what you might browse in such a popup; it demonstatrates how the doc viewer is driven.

The following snippet is copied from

I:\Curl RTE\Surge\6\ide\editor-interface
EditorInterface.scurl
Snippet:
{doc-next
{purpose
This class defines the interface that an editor must support
to be integrated with Surge Lab.
}
{details
An external editor needs to implement this class, and define
a top-level variable named {monospace surge-lab-editor} which
is an instance of its implementation of this class.
}
}
{define-class public open abstract EditorInterface

{doc-next
{purpose
Initialize the editor.  An interface back to Surge
Lab is provided for the editor.
}
}
{method public open abstract {initialize
surge-lab-interface:SurgeLabInterface
}:void
}

The behavior of the default Curl editor is not my favorite side of Curl at the moment: high-lighting a '{' offers a context popup to view the '{' in a class browser instead of the handy behavior when you add a '}' which is to blink the matching '{' in red.
Adding a '}' and then placing a CR in front has the disconcerting behavior of aligning the '}' with the matching '{'. This is annoying if it is your habit to end a line using a 'do' with an opening brace ( as required by many script interpreters such as Tcl and which is {script-style} for many programmers.)

But the little annoyances in the default editor come to nothing because there is an interface for external editors.

Over at eclectic-pencil I will add a page with a working HTML example of an embedded Curl {example} macro using a TreeControl object. Install the plugin and Ctrl-Right-Click. Cool.

Tuesday, August 7, 2007

GRAILS and Groovy tip

If you try out groovy Grails on Windows as an open-source web application framework, I suggest you install it as a sub-directory of your Groovy directory.
You will want to knwo that your groovy is running fine: in my case I added
set CLASSPATH=I:\groovy-1.0\groovy-1.0.jar;%CLASSPATH%
to my groovy-1.0\bin\groovyConsole.bat I also have three ENV variables defined: GROOVY_HOME, GROOVY_JAR and GRAILS_HOME and both HOME var's are in my path with \bin appended to them.

With that done, you can go into the Grails bin and edit the
grails.bat
I think that there is no point avoiding at least this much:
set CLASSPATH=
because even with my own classpath tool it is just too much grief. Grails does not need your classpath but having one is a problem. The top of my grails.bat now reads
REM set groovy_home=I:\groovy-1.0
REM set GRAILS_HOME=%GROOVY_HOME%\grails-0.5.6
REM set path=%groovy_home%\bin;%grails_home%\bin;%PATH%
REM set GROOVY_JAR=groovy-1.0.jar
set classpath=
To test that things are running start in the grails\bin with
grails help
which should run error-free and list the grails commands. From there you should be OK following the Grails Quick Start steps. Until help comes up error-free, you have an issue.

One last tip: Grails will create your web app root directory in the directory you are in at the time you execute
grails create-app
which in my case is running
I:\groovy-1.0\grails-0.5.6\scripts\CreateApp.groovy
so you do not want to be in .\grails\bin on your command line. If you have not installed the Microsoft Power Toy Open Command Window which launches CMD.exe from any folder in the file explorer, you will want to do so ... whether you are using Grails or Rails without an IDE.

RIFE-Jumpstart

RIFE is such a terrific example of using continuations in a web application framework that it is too bad if giving it a try has glitches from the get-go.
The RIFE-Jumpstart will use Jetty so you will want to go into the Jetty subfolder and edit the jetty.xml such that the port value is something other than 8080. After that you will reach RIFE as something like
http://localhost:28282
You simply must confirm that your OS has the JAVA_HOME env variable set to a JDK. I am using RIFE for Java5 so mine set to
i:\java5\jdk
I tried using my own ClassPath tool from LogiqueWerks to get around this by being sure to hit the right tools.jar and javac.exe but I could not escape
class file has wrong version 49.0, should be 48.0
when launching from the RIFE-JUMPSTART directory with
ant run
This also means that you must have ant in your path.
It is annoying that most HTTP frameworks install without politely asking for an alternative to port 8080. OracleXE and SUN Application Server are the latest to do this to me.
There are some good video podcasts on RIFE - one at Google is about an hour long.
If I add some RIFE pages they will be over at eclectic-pencil.com Useful links include rifers.org and a Confluence link on DWR.

Tuesday, July 31, 2007

Windows and the Tea Shell

The Tea shell for the JVM has been available as version 3.2.2 for some months now.

There is no problem running the shell under Windows if you had Tea 3.1.0 up and running.

The first problem is that 3.2.2 includes no TEA.BAT in the tgz file. Just get the old 3.1.0, extract the bat file and update it to suit your install.

Tea must find a GNU jar for regexp and a Xerces jar for XML parsing. I reference them explicitly in a temp CLASSPATH in that BAT, e.g.,
set CLASSPATH=%TEA_BASE_DIR%;%TEA_BASE_DIR%\xerces-1.4.4.jar;%TEA_BASE_DIR%\gnu-regexp-1.0.8.jar;%CLASSPATH%

Tea is intended to bring multi-paradigm programming to the JVM. It is a java-based functional langauge with extensions for procedures and classes. This is another language intended to be component 'glue'. The selling point is that it is in java.

Other multi-paradigm languages either have their own compiler written in C or are using libraries implemented in C. Tea is java so one positive is that you get javadocs. The tea reference javadoc lists about 20 functions as the language core.

As a functional language Tea is intended to make the use of closures easy: functions are first-class objects as in JavaScript. In many respects the object system is like Smalltalk: members are private; methods are public. Code blocks in {} come with their contexts as closures. Every statement is at least a word which invokes a function. Lists are like Smalltalk collections: they can contain objects of mixed types. Unlike JavaScript, there is no literal notation for functions, but they can be loaded at will from jars or from raw source files using the source word.

Variables are not pre-typed, but they must first be declared with a define. The define word is over-loaded 3-fold: define a variable; declare a variable to have a value; define a variable to be a function as declared. The define word returns what it defines (it, too, is a function.) The set! function is used to re-assign a variable and anonymous functions can be had using the lambda function. Much like Smalltalk's collect: there is a map function to iteratively apply a function to a list. For lists of lists there is the function map-apply. Unassigned vars are returned with the value null. But note this sigil use:
define nativeParser $null

The syntax is very simple. Statements end at end-of-line. Comments start with octothorpe. You get variable values with a prefixed $ sigil. Other scripters will feel comfortable. The type tests use function? string? symbol? int? pair? which is extended to boolean tests as same? not-same? null? and not-null?. Lists use parentheses and, thankfully, no commas.

Lists are very much Scheme, as in
define testPair [cons "first" "last"]
where [car $testPair] gives "first and [cdr $testPair] give "last".
List are built from such pairs; the last pair in the list references a pair where both slots are null. With syntactic sugar our test list can be declared as
define testPair ( "first" "last" )

The Smalltalk procedural style is made possible by using the $ sigil.
For example, if you have a database connection in variable conn then
define sqlStmt [$conn statement]
returns a statement. The difference from Smalltalk can be seen when the query is created: there is no need for a colon, as in
define dataSet [$sqlStmt query "SELECT client_id FROM new_customers"]
but what is different is the use of [...] and not as a code-block { expression }. What is happening, of course, is a command substitution as in Tcl. The {} are used to defer evaluation as in a while loop.

The load function is rather like Jython: it gives access to java classes including Tea functions in those java jars.

But why would you use Tea? One possiblity is that you already know Scheme and Tcl or need a rapid way to work with closures in the JVM. But why not simply use JavaScript? One curiousity is that Tea is promoted as a language for rapid-prototyping, but in Lisbon it has been used for major banking and telco systems. But was it used only as glue code? Not at over a million lines according to Tea's own 'whitepaper'.

One observation: Tea is almost the opposite of Curl and Rebol. It is only now adding GUI and networking. But why add them if this is a scripting language for the JVM? It must be irresistable. Some people spoil their kids; some people spoil something else. And most of us seem to bloat if we are not kept on track ... and reminded that what we leave out can be as important as what we put in.

In Tea you get a hint of what the future holds if we shift away from 'C' and the OS to life with a VM.

Likely Tea will never have the momentum to break into North American markets unless it is embraced by a major player. It does have an advantage over Jython: there is no shifting Python beneath it. Then again, functional may becoming fashionable... even at Microsoft.

If you are a secret Schemer masquerading in Java or someone who can't thrive without a little Tcl, you may want to have some Tea... and lemon? Ah, right. They already added the syntactic sugar ...

PS There is another TEA which is the Tiny Encryption Algorithm and yet another Tea that is a strongly-typed templating language for managing servlets from the Disney TeaServlet project at what was once GO.COM Green tea. Black tea. Chá, anyone?

Monday, July 30, 2007

The Zend of PHP

July 2007 saw the release of the 1.00 'production' release of the Zend Framework. To quote:
The Zend Framework project has developed solutions to solve frequent needs of web application developers, including the following areas:

* Powerful MVC framework
* Database access solution that balances ORM with efficiency and simplicity
* Lucene-compatible search engine
* Advanced I18N support
* Robust authentication/authorization classes and input filtering
* Rich web services client interfaces, including Google Data APIs and StrikeIron
* Many other useful classes to make you as productive as possible
* Thorough and high-quality test suites and documentation
* Open-source development process with an active community provides continuous review and testing


One of the many criticisms of PHP as a scripting language for web development is the lack of enforcement of separation of content from logic. Now Zend proposes an MVC framework for PHP.

MVC (Model-View-Controller) is usually associated with Smalltalk and the thick client even before client-server, let alone the web and RIA. MVC used in conjunction with frameworks such as Struts for J2EE is MVC in name only. The concern is this: keeping domain models and business models from being entangled in presentation issues. The web MVC variant is usually called Model 2 MVC. In Smalltalk, the evolution of MVC to Morphic (from Self) or to M/V without controllers (Cincom Smalltalk Widgetry) is a topic in itself. Dolphin Smalltalk has MVP (Model-View-Presenter) and provides a nice introduction at their Object-Arts site.

PHP starts with a bad rap for not having adequate modularity: it still lacks namespaces. Smalltalk itself is evolving to embrace namespaces and away from classic MVC so we have something curious occurring.

Here is what the Zend Framework appears to offer. I quote:
<qt>
Put simply; models contains your domain specific code such as a user class, views contains your templates, or view scripts as they are called, and controllers contains the files that process data to and from the models and views. Following this simple practice not only introduces a design pattern into your programming arsenal, but also organizes your code in a way that makes it more maintainable than a great many existing PHP applications.
</qt>
What we really have here is the front controller pattern that arose in J2EE in frameworks such as Struts where it is combined with a Command pattern.

In terms of security, PHP with the Zend Framework remains a filtering approach. What is not yet clear to me is how this chaining of filters and validators constitutes a framework. A Framework is not just a library of classes and certainly not a cookbook of recipes. A Framework can usually be understood as providing for the interoperation of services identified with components by enforcing constraints. The constraint might be: this service must be presented as an interface (now you are constrained to implement against a minimal abstraction.)

To have a framework it is not enough to have a class library providing a mechanism which removes ? and & from PHP URL's or adding more filtering.

You may want to check out the Zend Framework site with its webinar and demo wiki application. The site also links to manuals for the API and a developer reference. The latter opens on Access Control Lists; scroll down to find Controllers. What is missing is an overview of the framework such as is readily communicated by the Rails folks promoting Ruby. Having the familiar directory structure in itself does not establish 'convention-over-config'.

Perhaps whether you have 'c-over-c' comes down to 'GUI-shootouts', but that sort of thing does not impress architects concerned about security+maintainability. Saying you are using a 'framework' only goes so far. If what you meant is a library of classes that will be familiar to Struts developers, then why not Java with JavaServer Faces with jars, ears and Maven with the Spring 2.0 framework for security? What ties anyone to PHP in a business setting?

PHP has likley gotten to where it is because it posed no steep learning curve. And then it got a bad case of bloat. What results could be called 'wading through muck' rather than 'slogging uphill'. But when I arrive to perform on a maintenance contract, knowing what the framework was and that it was respected means a whole lot. Knowing what libraries were used gives very little indication of what you are in for.

Saturday, July 28, 2007

Example is the Curl developer's example macro


This little Curl script could be the web developer's best friend.
As a web content language, Curl 5.0 provides a powerful RIA platform. This applet using the macro 'example' might convince you.
The macro 'example' creates a live code example in your browser which will open a child applet window.
First we run the following code snippet as an applet in the Curl IDE, embed it as a web applet or launch it with the Curl RTE with a dbl-click in a file explorer.
{curl 5.0 applet}
{applet license="development"}
{curl-file-attributes character-encoding = "windows-latin-1"}
{import * from CURL.DOC.CONTENT.ACCESSORIES}
{example 
{bold Hello {italic there}! }
}

Example is a Curl macro. The result is a web page in which to execute Curl, revert and save Curl applets. It you know something slicker than this, I would want to see it.
You may notice that in my example I have thrown in a {VBox }
I could hit REVERT and I would be back at the original. Here is the result:



If I like my changes, I can save the code from the web page with 'Save Applet'.
In practical terms this also means the ability to create web-based developer documentation with 'live' code snippets. And the eample maco nests: you can have a nippet which is used to demonstrate another snippet.
Curl comes with a visual test framework, but this little 'example' macro should give you a hint of what is possible in Curl 5.0
Note that 'example' is made available by importing the Curl package
CURL.DOC.CONTENT.ACCESSORIES

Tuesday, July 24, 2007

PDC Visual Prolog 7.1 released

If you recall the days of Borland Turbo Prolog (there were books on Turbo Prolog in bookstores and libraries back then) you may not be aware that it lived on as PDC Prolog (Prolog Development Center)

Much like the first home of Prolog at prologia.fr, this is a web site that does no appear to be the site of a language implementation, let alone Prolog.

Prologia IV is a language for Constraint Logic Programming in which Prolog is a limiting case. The company now focuses on industrial applications. The same is true at PDC. The other notable company with a Prolog more widely used is ILog with JRules.

PDC has focused on domain specific languages (DSL). Visual Prolog itself has fostered another company, EZY Prolog which looks to simplify using VIP.

Visual Prolog for Windows GUI has always required as much knowledge of Windows GUI programming as would be required of a C++ developer although much better suited to RAD.

What makes Visual Prolog worth exploring is the way in which OOP has been brought to a declarative language with hooks to user interaction. It is an implementation which continues to evolve as an industrial strength framework. It is worth comparing to the Logtalk framework which brings a remarkably flexible OOP option to almost any Prolog implementation (PDC and Strawberry are notable exceptions.)

Logtalk can be employed to specify a prototype-based framework: it lives in symbiosis with a prolog implementation. PDC Prolog is fundamentally class-based, but its specification of interfaces is so flexible that nothing much is lost: a interface can be used in an implementation of a class even if not declared by the class - which provides almost as much as working with objects as prototypes. There are other type-based OOP projects with a similar strength: TiScript and the XOTcl extension to Tcl which allows an object of a class to also declare its own attributes.

Some years ago I built a dynamic aerobatic squadron generator for a flight simulator in PDC Prolog without objects ( takeoff from any airport, perform manoeuvres, land at an airport. It used to run at the home airfield museum display of an aerobat team. That was done in Prolog without an object-framework or constraints (but at least did not require XML, being in Prolog.) If I ever find time or a sponsor to re-write it, it would be hard-sell to move to Oz if that meant losing the object-flexibility of PDC7.1 or Logtalk with any Prolog with constraint resolution.

The PDC install ran flawlessly (an installer for a smart language should be as smart) which certainly is not always the case with interesting languages, e.g., Python or its CMS, Plone.

PDC also comes with its own external database framework which has always been a favorite feature with me and worked very well for my dynamic squadron generator.

Even if you don't remember Turbo Prolog, check out PDC. If you use Eclipse, checkout AMZI! Both sites have great instructional resources. If you need open-source, there is, of course, Logtalk+SWI+java

halt.

Sunday, July 22, 2007

XOTclIDE: the IDE that is almost Smalltalk

I copied XOTclIDE82.kit into my \kits directory for ActiveState Tcl/Tk for Windows.
A double click on the kit ( I already had Tclkit in the PATH for Tcl\bin ) and I was politely asked whether to launch Simple or with Version Control. Simple was fine for now.

The result was a Transcript, a ClassBrowser and I was one click from a WorkSpace.

If you have ever used Smalltalk, this will sound very familiar.

And if you have never used Tcl with the GUI Tk you deserve to take an hour or two and see what simple GUI-driven control of admin tasks can be like.

XOTcl is extended MIT OTcl. There had been a few GUI extensions to Tcl rather as there have been for Python. But these extensions are principled: they do not simply provide a wrapper to a GUI library. The Mozart-Oz system is very much built on principle and exploits Tcl/Tk in its QTk, but lacks an IDE (SICStus Prolog also has a Tcl interface.). Tcl upvar and uplevel are not a replacement for the Mozart implementation of Oz, so my question becomes: does this rich environment impede or foster useful Tcl scripting?

An IDE as rich as that found with most Smalltalk implementations tends to be only as useful as its GUI layout tools and/or GUI specification framework. If it is awkward to tie event handlers and callbacks to widgets and worse to edit or maintain them, then little is gained by having object inspectors and dynamic workspaces. Tcl/Tk itself is marvelously simple (Jython comes to mind by way of comparison - or Rebol or Curl RTE's.)

The XOTcl documentation presents a very flexible, dynamic object framework, but the XOTcl components are file-based Tcl packages which must be registered with Tcl. Tcl is about component integration, but it's own integration of packages is a weak point, which is not to say that packaging and load dependencies cannot also be a headache in Smalltalk.

If I find the learning curve not too steep ( if Curl, the MIT web content language, has a gentle curve then Rebol is like learning to surf: anyone can paddle out ... ) then I will add a header page at eclectic-pencil and see if I can't put up a few useful markers across the terrain.

If you have a favorite language with no non-commercial IDE and are not in love with Eclipse, XOTclIDE does show what a mature IDE can offer a developer in a dynamic language. The only development environment to interest me as much as this was the outline-browser of Strongtalk.

PS Eclipse, of course, evolved from IBM VisualAge Smalltalk ...

Saturday, July 21, 2007

Array-like objects in prototype-based JavaScript

In the course of a recent exchange on what constitutes prototype-based as opposed to class-based in OOP, I took a moment to look at a few neo-JavaScript interpreters.

An array-like object is an object which satisfies some part of the interface which an Array prototype would specify. First create an object obj = {} and then add to the object with obj[0] = 1 and finally test the object for type, length, constructor and prototype.

All of the interpreters respond that obj is of type Object. One reports that obj now has a length of 1 with no constructor and Object as prototype. The others responded that length was undefined with no prototype but a constructor of type Object.

The downside of this little exploration has been a re-reading of Chapter 7 on OOP in Peter Van Roy's CTM. My estimation of that otherwise fine book has suffered.

It seems that the first thing that goes wrong in Chapter 7 is the good intentions.
One good intention is to warn you that object-purity is not the answer and another that class inheritance is not the answer if the subclasses violate the type of the superclass. If type offends you, then substitute "fails to respect an invariant of a superclass". And in passing, if you have multiple inheritance, only inherit from unrelated classes.

Anytime inheritance trumps composition or runs deep where it need not do so, a design suffers and maintenance and evolution become problematic. Classes for a GUI framework where inheritance may naturally run deep can be the worst place to learn OOP. Ditto for collections and containers. The ease of subclassing is the undoing of many projects. And the ease of extending base classes. And failing to respect a separation of concerns.

However, Class itself typically has only one subclass: Metaclass and Class itself likely lies only 3 or 4 classes deep in the Object hierarchy.

Peter Van Roy fails by misconstruing object-oriented as class-based and ignoring prototype-based. Had the author given any attention to Self, JavaScript or Logtalk, this could not have happened. Instead we have Smalltalk-80 and Java with a very short note on object-based. There is nothing about "add-on" OOP although it is common as rain in Prolog itself (perhaps because it was such a vice in C++.) When it comes to his reports of failures, just remember all of those industrial-strength Prolog apps which have been re-written by imperative programmers. A grain of salt is in order.

The use of Smaltalk-80 is problematic because Smalltalk has no ISO standard as does Prolog. What Smalltalk has are implementations. Had the author looked at VisualAge Smalltalk he could have cited a plethora of types: IBM Smalltalk came with 5 types of subclasses. Not to mention that a subclass of nil ( Object and any light-weight objects which serve as proxies) form at least two types as does any object implementing >>doesNotUnderstand. You could argue the same for classes with class instance variables as opposed to those with only instance variables or class variables. Smalltalk has runtime dynamic type-resolution and so is not strongly-typed in the sense of the compile-time type resolution of many other languages. An untyped language would not be more powerful than the alternatives: it is in theory more restricted, being the language with one implicit type, the 'any' type or the 'just-cannot-say-yet' type. It certainly could not easily implement the power of multiple value-side datatypes for single-type variables.

So one suspects that the consideration of Smalltalk-80 is consideration of a strawman. Indeed the dangers of subclassing for inheritance are presented as the dangers of side-effects and an opportunity is missed.

The object-orientation that is presented is a minimalist class-based approach with no method overloading within a class. This should have struck me as absurd in a language inspired by Prolog.

One suspects that the target is the unnamed sin of C++. But Objective-C is ignored, as is Lua and embedded scripting in general. Java is given the most attention and C# is ignored, itself a regrettable choice.

That the entire book ignores JavaScript may be a symptom of ignoring scripting. But this is a book on techniques and not just algorithms: Concepts, Techniques and Models.

The warning against 'structure' versus 'type' inheritance is just hollow. Substitute 'module' for 'class' and 'dependency' for 'inheritance' and try to convince yourself of this in a book that stresses the importance of modules and in light of the importance of modules in Prolog and imperative languages. The reader would be better served to look at class-type declarations that permit 'mixed' and 'convenience' modules to be constructed ( something more awkward in languages where module equates to physical file directory ). Of course what is a directory, but just the kind of unprincipaled 'structure' which the author deplores. One might as well deplore the use of 'path' in navigating these structures as 'path' has an equally unprincipaled order (but putting '.' at the head of classpath is deplorable.)

What is curious is that Van Roy ignores significant similarities between Oz and Smalltalk in the area of overloading methods within a class. Smalltalk with optional Types, Strongtalk, does provide overloading. The need for overloading in Smalltalk is revealed by counting calls to >>class or indexing into the Smalltalk SystemDictionary with symbols or calls to >>isKindOf: It is an aspect of polymorphism that should not be ignored. It is present in typed Prolog.

If MIT Press goes for a second edition of CTM, here is hoping that this entire chapter gets a re-write ( including the tell-tale editing error which seems to reveal that some material in the chapter was destined for another location in the book.) By that time it may be the JVM and .NET who deserve attention if Scala develops a following. A book with chapters on declarative and OOP cannot plausibly ignore Logtalk.

Objects alone are not the answer for distributed or concurrent or collaborative computing. Nor is class-based object orientation. But objects, whether referred to as records or associative arrays or hashtables are part of the answer wherever functions are first-class objects.

Oz is just too important to the case for multi-paradigm programming to have its only book and such a significant book marred by such a treatment of object-orientation. Had the author gotten past Smalltalk-80 to Self and JavaScript, the objectives of CTM would have been better served. As it stands, the book ignored distinctions between Java4 and Java5 which cannot be ignored as we move to Java6. If ECMAScript leaves prototype-based and Rebol3 leaves prototype-based it will be all the more important to assess the extent to which class-based is the answer for effective object-orientation.

A chapter on Logtalk could be the framework on which to hang the trio: Concepts, Techniques and Models. There is no need to hang the strawman.
PS
Oz itself has been called 'concurrency-oriented'; nothing prevented Oz from being prototype-based as was Rebol (prior to Rebol3) and with the flexibility of Logtalk+Prolog.
For discussions see Crockford and OZ Classes on principal

Thursday, July 19, 2007

Dialogs in Curl and in the Curl Documentation Viewer

The Curl Documentation Viewer can be a bit of a challenge if you lack a Curl book.
Here is a translation of the code docs for showing a Dialog as found in the Dialog (class) item.

show  : Show a dialog in its own window.
public  
{Dialog.show
title:String = {host-localize "Pop-up Window"},
modal?:bool = true,
center?:bool = true,
owner:#View = {View.get-default-owner},
style:DialogStyle = DialogStyle.standard,
large-icon:#Pixmap = null,
small-icon:#Pixmap = null
}:void

The first thing we need is an instance of a Dialog which we can show.
We get that with {Dialog new} or the short-cut, {Dialog}

So we can attempt to execute the documented method in the Curl IDE as
{{Dialog}.show
title = {host-localize "Pop-up Window"},
modal? = true,
center? = true,
style = DialogStyle.standard,
large-icon = null,
small-icon = null
}

You may notice that I have torn out the option for the default view owner when I tore out the type declarations.

But the Dialog is not very promising when you execute it: it is barely visible.
Try this.
{let vbox:VBox = {spaced-vbox width=2in, margin=5pt}}
{{Dialog vbox}.show
title = "Pop-up Window"
}

Now we almost have something like a Dialog to show. Add {text as follows:
{let vbox:VBox = {spaced-vbox width=2in, margin=5pt,
{text "Give us a Dialog to show"}}
}
{{Dialog vbox}.show
title = "Pop-up Window"
}

As my Grandpa would say, "Now you're cooking with gas!"
And hopefully the class-side documentation makes a little more sense to you than it did before.

The expression {Dialog vbox} is not the most common idiom.

More common might be
{let dialogTest:Dialog = {Dialog vbox, border-width = 2pt}}
{dialogTest.show
title = "Pop-up Window",
center? = true
}

And perhaps we should be using
{let dialogTest:Dialog = {Dialog vbox, border-width = 2pt}}
{value
{dialogTest.show
title = "Pop-up Window",
center? = true
}
}


{Dialog vbox} is a curious expression. It can be used because the default constructor for the class Dialog is defined with '...' for rest arguments.
In our case, the 'rest' of the arguments is a VBox. Dialog itself inherits from classes designed to provide functioning for graphics containers and for traversals.

It is curious to note that MessageDialog is not a subclass of Dialog, but a subclass of one branch of the multiple-inheritance tree of Dialog: the class StandardActiveTraversalContainer, which inherits from Frame and thereby BaseFrame which is itself the super class of MessageDisplay, the parent of MessageDialog.

FileDialog may also surprise you: it is not really a class so much as a module ( there is a variant of JavaScript, TiScript, where a Type can also be used in just this way.) It is both abstract and final.

This may be worth noting if you are interested in running Curl outside the Browser in the way that Mozilla XUL applications run outside the browser. In this case sub-applets and multi-applet behavior become important, not Dialogs. In Microsoft Windows, modal Dialogs have a troubling past. They have their counterpart in the MDI 'solution'. It is reassuring that in Curl we will be working with smart Frames and Boxes instead.

See the notes on detached-applets and the use of View. For a minimal detached-applet, you can simply use a CommandButton as follows:
{curl 5.0 applet}
{import * from CURL.GUI.BASE}
{import * from CURL.GUI.CONTROLS}
{View
{CommandButton
label = "&Click Here",
style = "standard",
{on Action at btn:CommandButton do
set btn.label = "Test with a &Click."
}
},
visibility = "normal",
{on WindowClose do
{exit}
}
}

If you are using the IDE, save the file as a detached applet with the .dcurl file extension.

To run a script using
curl.exe -l myscript.xcurl
use
{curl 5.0 script}
{import * from CURL.GUI.BASE}
{import * from CURL.GUI.CONTROLS}
let win:View = {View
{CommandButton
label = "&Click Here",
style = "standard",
{on Action at btn:CommandButton do
set btn.label = "Test with a &Click."
}
},
visibility = "normal",
{on WindowClose do
{exit}
}
}
{win.show}
{event-loop}

If you are using the Curl shell console, you will have to click back into the console after sending >>show in order for Curl to evaluate {event-loop}

Tuesday, July 17, 2007

Curl and Perl regexp

One of the nice thinga about Curl, the web content langauge, is that when you use {regexp-match ... you will be using the regexp flags that you know from Perl.

I will put a page on Curl regexp over at eclectic-pencil under the Curl/Surge RTE pages and {import * from CURL.LANGUAGE.REGEXP }

My document links for Curl are also kept there.

Sunday, July 15, 2007

a note on Polymorphism in Rebol and Oz

I have put a page on Polymorphism in Rebol and Oz with some mention of Strongtalk at eclectic-pencil

It really does not do justice to the richness of Rebol and may presuppose some familiarity with Smalltalk. All are available as freeware on the web.

If you work in JavaScript or C# there will be a lot to interest you in the trio of Oz, Strongtalk and Rebol. TiScript, for example, is a JavaScript variant which rejects prototype-based in favor of simple modules.
If you are looking at the new languages coming available for .NET and VisualStudio and want to see multi-paradigm programming then Oz is the place to start.
If you find you don't quite get Oz and the whole Emacs thing, start with Rebol.
If you don't want another way to think about web programming, just an alternative to JavaScript+CSS+HTML+whatever, download the Curl RTE and IDE.
I had been almost sold on XUL + JavaScript or XAML + C# and then I took a look at both Rebol and Curl.
In the next few days I will post something on the beauty of "Quick" Tk in Oz. If you were ever taken with Logtalk+Prolog or Datalog+RDF you will appreciate td(...) and lr( ...) as td( lr( ... )) i.e. layout of widgets is top-down and left-right...

Saturday, July 7, 2007

Sciter, TiScript, DyBase and JSON

If you have ever looked at XUL for Mozilla, you owe it to yourself to look at an alternative way of declaring a UI with JavaScript.
TiScript is an extended-JavaScript with a few twists and it works with DyBase to provide scripting and persistence for Sciter.
Sciter is from Terra Informatica, whom you may know for BlockNote or their SqlLite wrapper.

What Sciter offers is an alternative to JavaScript+DOM. Instead of loading the DOM for an HTML page, the strategy is to use TiScript with a few extensions to CSS.

Sciter offers web developers 8 DOM and Window classes:
  • Element - DOM element. All HTML elements including the document root, frame, inputs, etc. are elements in Sciter.
  • Attributes - a collection of named attributes of any html element.
  • Style - a collection of style attributes applied to any element.
  • Image - bitmap image objects on which you can draw using Graphics methods
  • Graphics - an object wrapper for drawing primitives for drawing on any Element or Image
  • View - represents Sciter window (the main Sciter window and Dialog are views)
  • Event - represents the current UI event.
  • Sciter - a global object holding Sciter application specific methods.


Top level windows are represented by View objects in Sciter. Both the main window of the Sciter.exe application and the client area of the X-Sciter.dll sandbox window are views. Dialog windows also have their associated views.

Each view has a root property which is the root element of the loaded document. The root element in Sciter is the <HTML> element of the loaded document and there is no dedicated Document class because in Sciter the Document is an element tree composed of an element and its children.

Frames and framesets are also ordinary DOM elements. Each has a single child element: the root element of the loaded document. If the document is loaded into a frame, the parent property of the root element of the document will refer to that containing frame element.

These simplifications are intended to make up for inherent weaknesses in how CSS+Javascript is used in web layout to complement simple HTML.

This interests me while I am looking at the separation of concerns which is attempted by Mozilla with XUL for Firefox and for other XPCOM applications outside the browser which use the XPFE (Cross-platform front-end) framework. Sciter+TiScript+JSON is also interesting when contrasted to Rebol/View and the upcoming Liquid-GLayout marriage for Rebol (Rebol does not yet have a cross-platform IDE - which is something else Rebol shares with Oz and Mercury.)

The major change that you will find in TiScript is the use of type to define both classes and modules (namespaces) without the prototype-based emphasis of JavaScript. A class with a this() function has an instance constructor*. In TiScript the prototype field is a reference to a type or is undefined. TiScript also has a nice variant on C# properties to provide set and get accessors for field privacy. Sciter itself uses 'self' to refer to the root object as in self.myFunc()

Corporations in the far east which have used Curl will not want to migrate to XUL+rdf+dtd+css+js and it is hard to imagine ActionScript and Flash as being much more attractive. It would be interesting to know whether TiScript itself would obviate the need for the Google Web Toolkit as a JavaScript nostrum while also streamlining the scripting ( GWT is touted as a remedy for unintended JS closures causing memory leaks under IE - but I should add that GWT does have a fine inexpensive plugin to Eclipse by Instantiations.)

Another point of interest is that TiScript offers JSON persistence through a version of a DyBase library which has been modified to support 'native' TiScript. DyBase is said to have interfaces to PHP, Perl,Python, Rebol and Ruby but I could only find a Smalltalk alpha outside of the home archives of the DyBase author (and none at rebol.org, CPAN or the Python Cheese Shop and no RubyForge or sourceforge entries; the dybase site at garret.ru was off-line this weekend.)

Dybase could be as neglected as the database options offered by associative and hierarchical/network databases (MUMPS, DNS and LDAP are hierarchical) in the world of MySql and XBase. And there is Lazysoft, to which there are links at StumbleUpon and AboutUs.

Perhaps if an AltME group opens on DyBase there will be an opportunity to judge its merits across a few languages. Until then I will watch ltu.

* the author of TiScript is the author of Harmonia, an FLTK for the D language.

Thursday, July 5, 2007

exposing slim Liquid Rebol

The dataflow framework for Rebol is called Liquid and is available from rebol.org as a SLiM library.

If you are new to this as I am, it is not obvious how to proceed.

First you need both slim.r and liquid.r

Slim can be found at rebol.org in the scripts.
You can download liquid or retrieve it from the Rebol console by visiting Liquid
to either get the file or run the one-line script at the Rebol console.

Start by loading SLiM with
do %slim.r
and then try
do %liquid.r

The important liquid function is liquify. An attempt at
source liquify
or
help liquify
will show that nothing is yet available.

Start by checking the SLiM paths with
slim/paths
which should be an empty block.

I am using local code (liquid.r and slim.r are in my Rebol directory) so I just do this:
slim/paths: [%.]

Now I check my SLiM path to liquid this way:
slim/find-path %liquid.r
which gives me my Rebol path.
Now I can do the two key bits:
lq: slim/open 'liquid none ; gets any version
and then expose that lq library with
slim/expose lq none ; replace none later with a blk of funcs
Now you can test with a simple test for the liquify true? function with
source true?
You are now ready to use the liquid documentation at Steel quickstart or the Steel Liquid page.

Monday, July 2, 2007

A Name for Rebol 3.0

Now that Rebol 3.0 is in alpha, I feel some concern that a re-naming could be in the offing.
Rebol emerged from Lava. The great thing is that any google on "Rebol" is a fruitful google.
Just suppose that your interest is music and the Oz compiler named Mozart...

That a language called "Stockhausen" could reemerge as "Alice" might amuse.

But it is vexing to search for "io" as a language (it is a language, as was Icon.)

There were silly, ill-timed names: calling the new APL by "J" comes to mind.

A DOS language named "C#" could only have been worse named were it called "C:"
Then there is Obol. All three. And whatever all is named "Rio". At least three.

The worst case for me is Curl which is doomed to be confounded with cURL. When a hairspray named "Surge" appears, the Curl RTE will have to be re-named.

Nemerle has sagely chosen an off-spelling.

"D" is not "E"

Self has suffered through LiveScript, JavaScript, ECMAScript and may be swallowed by ActionScript.

Even Prolog suffers with the 'prolog' in XML.

But Rebol. Rebol is as well-named as Perl.

That is not the case for Cecil with Vortex or any talk of Cecil and Diesel.

Smalltalk was ill-named. Self was worse. Slate, well, we'll see. Then there is StrongTalk and MetaTalk and BackTalk.

So we take datatype+value+word+block+context. Hmmm. A Rebol function could easily give us

dat-vardock-XT
dat-woluock-XT
dat-blordue-XT

Perhaps Rebol/command is in need of a new moniker. REBOL is not, imho.

Friday, June 29, 2007

a Rebol tip

If you are new to the Rebol language on Windows you may have noticed that there are 2 files named rebol.exe
One is in \core and one is in \view
If you have followed the wiki-book you may be in the habit of running \core\rebol.exe in which case you may hit two oddities: first, that console does not know how to respond to
desktop
and, second, that it cannot respond to
editor ""
or the more interesting
editor system/view

The answer is to launch Rebol only using the home directory view.exe
From there you can go back and forth to console and then return to ViewTop using the command
desktop

While you are at it, try
source build-tag
or
source to-email
or
type? {this and that}
or
reduce [ 2 + 3 + 5 7 ]
or
compose ["this" (21 + 21) "that"]
or
parse {this that these those} " "
and enjoy!

PS. Here are 3 links to console info:
core
shell
quick-start

Saturday, June 23, 2007

Missing Curl links which could be Surge links

At http://plymouthreliable.com/blog/curl-links-which-are-not-curl-links/ I have posted a list of selected missing links

Many are lang-code.wikipedia.org pages which reference some programming languages but not Curl. Some links are offered in the hope that someone can sort things out. In one case, at de.wikipedia.org I had occasion to flip 'cURL' to 'Curl' in a 'Hello World' applet demo.

In any country in the world where English is not the second language, a modified Curl should be able to get a foothold as an alternative to using English-like CSS and JavaScript and Java and XHTML. In simplified-Chinese or in any ethnic-Sino setting, Curl would be a natural choice.
If there is to be a tidal Surge to raise the American barge, it may come only after the little boats have risen in the linguistic tributaries of the non-English world.

Wednesday, June 13, 2007

QTk scripting in Oz/Mozart

The relative neglect of oz/mozart compared to say, Scala, has an explanation.

Part of it must lie in the needless snags along the learning curve. Steep is fine; jagged bits, less so.

There is no learning Oz/Mozart without embracing their emacs mode. And tolerating their tutorial.

Do not begin with applications. An application will require at least one 'functor'.

Ignore the bits that say you are compiling. You are not. No tutorial code will compile. Just do as you are told (follow the instructions) and 'feed' in a line. Or 'feed' in a region. Or 'feed' in a buffer.

What they mean is pass a line, a selection or the file through the interpreter only.

Think of it as scripting in Oz/Mozart. Now you can open a window with widgets using an few lines of Qtk.

No language which interfaces to Tk should be hampered by such a tutorial or such documentation; the usual answer is to buy the somewhat pricey MIT book by Peter van Roy.

Try to understand that the people who are assessing the need to revise the on-line documentation already know oz/Mozart inside-out and cannot 'see' the bits that say 'compile' when nothing compiled at all. They think you know what they mean by 'pickle' and that you get the 'functor' jibe at Prolog. A module is a module. Sometimes in some language a class is just a module. And writing a fine tutorial is an art. If you can get the video intro to Revolution/Transcript/MetaCard to run under Windows using the required QT codec, you may actually see what I mean.

But hey, you could not script the Oz/Qtk way in C. The fact that it looks easier in Jython may be that you know java and python. But it is easier in Tcl/Tk wish. So the point must be what can be achieved in oz/Mozart and that may be as much as can be achieved with Scala and then some.

Watch this blog for a link to a tutorial and a concordance/commentary to their friendly-looking documentation. And just accept that all you need to know is in the oz/Mozart maillist.

Somewhere in oz, climbing a cliff on the way to the corner store.

Note: do try the QTk Prototyper.  The tutorial leaves out one essential: declare the Prototyper, as in

 declare Prototyper
[Prototyper]={Module.link ["x-oz://system/wp/Prototyper.ozf"]}
{Prototyper.run}

Saturday, June 9, 2007

Jetty Lift Scala Tutorial for Windows XP

First install Jetty as a web server.
Open a cmd session in that Jetty directory (for this I use Microsoft PowerToys "Open Command Window" tool.)
In that cmd session, execute
java -cp . -jar start.jar

Open an IE browser and enter the address http://localhost:8080
When the web page comes up, click the Jetty test link
Go to the cmd window and enter CTRL-c to stop jetty

Now install Lift if you have not already done so.
Copy the Lift JAR file to jetty\lib
Copy the Lift Examples WAR file to jetty\webapps
restart jetty
refresh the localhost web page with the F5 key
This time click the Lift Examples link

Welcome to Lift on Jetty

Thursday, June 7, 2007

Scala and the interpreter

I have been looking at Prolog-like facilities implemented in languages which could benefit from something like the partially determined clauses found in Mercury for which there is no backtracking: a matching clause is found among a set of clauses or we fail.
There are interesting implementations of prolog available as add-ons to many languages including Scala.

I began my foray into Scala with a PDF by Martin Odersky which presented the following code:
def sort(xs: Array[int]): Array[int] =
if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }

This implementation of a quicksort chokes Scala when it is fed line-by-line to the interpreter by my own shell tool.
Here is one variant that keeps the interpreter waiting for more:
def sort(xs: Array[int]):
Array[int] = if (xs.length <= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot >)),
xs filter (pivot ==),
sort(xs filter (pivot <))) }


It is the sort of thing that those who script Perl are used to but might seem odd to someone from the functional-side whose interpreters would be waiting for the closing embrace.

If you would like to contribute to a portal on declarative+imperative, there is a new SmalltalkProlog portal that I have opened at aboutus.org

Friday, June 1, 2007

redirecting Rebol stdin/stdout under Windows

Rebol has a console interpreter which I wished to wrap in a smarter Win32 console shell that would screen my typical typo's, maintain a history across sessions and a few other useful features to exploit the Rebol parser.

My console wrappers at the moment are both Smalltalk console applications written in Dolphin Smalltalk: ConsoleShell and ConsolePipe. ConsoleShell understands commands for several language configurations and writes to a named pipe opened and echoed by ConsolePipe1; ConsolePipe2 takes STDOUT and pipes it to a chosen NamedPipe to feedback to an IDE running the ConsoleShell.

The problem that I faced was to pipe out from rebol.exe as it is not enough just to use the -w option to prevent a window from opening.

The answer lay in a Rebol script not unlike what you might use to loop a Perl interpreter. In my test case, the following pipeline works under Windows XP:
ConsoleShell | ConsolePipe1 | rebol.exe -w -c --do "forever [attempt [print do ask %~]]" 2>&1 | ConsolePipe2

The input is to my shell and the output appears in a destination window fed by a named pipe.
Unless you ran taskmgr you would not know that rebol.exe was running.

The two key bits are the -c flag and the print block. You also have to ignore the obvious and set the prompt ( in my case '->' ) with the '%' as indicated and you must wrap the script in dbl-quotes.

Now my ConsoleShell pipes into Rebol and Rebol outputs into my chosen Windows NamedPipe. This should work with any 2 wrappers - you might want to try with Tcl and expect. The Rebolution continues ...

Sunday, May 27, 2007

Win32 NamedPipes and "All pipe instances are busy"

When I began using named piped with the excellent Win32 implementation of Smalltalk from http://www.object-arts.com/ called Dolphin Smalltalk. I was convinced that Windows XP named pipes had been abandoned for sockets.
I would open a pipe, receive
All pipe instances are busy
so I would try with Perl. No problem. Then the real evil: open a named pipe with Perl and Perl could write and read. Open a named pipe with Perl and then try to write or read with Tcl and
resource temporarily unavailable
yet again.

What was infuriating was that even with the disconnect issues noted in my last blog, Perl would reconnect clients to my pipe in a single shot. Tcl could not even read that pipe.

Had I been using the screen utility under Cygwin, the answer might have come earlier. It required 4 CMD sessions to be open on my left monitor. The top 2 opened the same pipe with Perl. Perl began writing to an instance of the pipe in screen 3 and screen 1 dutifully echo'd the output. Now amazement: in screen 4 I simply redirected my bothersome buffered interpreter to dump pages of docs to that same pipe and PRESTO screen 2 was dumping that output from an instance of the named pipe.

Now more evil. I close everything. Open one instance of that same named pipe. Now anyone can read and write to the pipe. Including Tcl.

No, I do not have any anti-virus software running: I suspect that this is a gift from Microsoft security upgrades.
Now when I want a pipe for the console of my choosing, I create it, close it, create it again. No problem. The 'one instance' accepts the first client.
There is a commercial ACL utility which could no doubt pin down the access issue.
Now just wait until I upgrade to Vista ...

Now to get a utility pkg written for Dolphin Smalltalk to allow read and write streams to interact correctly with a Win32 named pipe as if it were a file.

Friday, May 25, 2007

Perl Win32 NamedPipes

Inaccurate documentation of an API is always vexing - more so if it propagates across the web.
Take the win32::Pipe module for Perl, available from at least 3 sources: ActiveState, CPAN and its author.
I can vouch that the module does permit creating a Win32 named pipe at a server end and writing to the pipe from the client end. Then the time comes to disconnect.
The docs claim that $Pipe001->Disconnect() will return 1 or 0 depending on if it succeeds or fails.
But a tell-tale sign: in the docs 'working' example, no value is assigned and tested upon Disconnect(). Nor is this done in the 'test' app available from the module's author. And in the docs, the result of a data read (!) is used to close the pipe, i.e.,
$Data = $Pipe->Read();
$Data->Close()
which is a long-standing error in the 'working' example.

This is what a current ActiveState Perl in fact reports as the result of $Pipe->Disconnect() with a pipe created, connected, written and read using the Win32::Pipe module
Disconnection result: usage: Disconnect($PipeHandle [, $iPurge]);

Having tried several variants with no success, this remains: you close the pipe ( it will report 0 for that op ) and then you recreate the pipe de novo and wait for another client with Pipe->Connect()
The worry might be what security holes may be opened by the use of this faulty module.
Caveat emptor, err, there is no such thing as free money - except in spam.
Oh, the docs are ambiguous on the key op: destroy. Is it only the 'instance' of the pipe that Disconnect() was to destroy and the pipe 'itself' which Close() was to destroy? And just what is the issue when the client drops off either with or without closing? ( the docs warn that if the client drops before the server, then the server will have a long wait. I found this issue trivial to address with a friendly client of my own devising ... unfriendlies are, well, unfriendly.)
The fact that ActiveState reproduces the author's docs with no clear caveat of their own is somewhat vexing.

Wednesday, May 23, 2007

AWAX, or AJAX without JavaScript

Suppose that the key to RIA is to have the server send something other than HTML to a smarter client. That might mean AJAX and JavaScript.
I love JavaScript. I call it LiveScript and pretend that I am running Self under Win32.
But suppose a small company wants to take over its web work rather than just replace their current web vendor. They cannot start hiring java developers and unix administrators and a Prototype javascript guru and a CSS person. Perhaps they can hire a parttime designer and an fulltime developer. Or give motivated employees an opportunity to fill the spots. Enter RIA without Javascript.
The key RIA technology today appears to be XMLHttpRequest as an alternative to HttpRequest for dynamic content in a web browser. But it is often assumed that this means AJAX and Javascript. It does not.

ZK is claims to be devoted to RIA without Javascript, err, XMLHttpRequest without JS?

And then there is Curl. Curl came out of MIT but appears largely absent on the North American scene. A bit like Roxxen and Pike.

But at curlr.org there is a clear prescription for XMLHttpRequest without JavaScript.

Why should JavaScript concern the small company? For every reason laid out by Google to justify the use of the GWT or Google Web Toolkit. Now, even with the Instantiations GWT Designer for Eclipse, the company will be looking for a senior developer, if not their own web guru.
But why would taking on your own company web projects mean competing to hire a Java developer?
Companies in the past have taken employees with business knowledge and evolved them into top Smalltalk developers. That is in the very nature of Smalltalk.
Unless you are building electronic devices, taking a person with business knowledge and training them as a C or Forth programmer would likely be folly.
Expert System shells were different: there you could evolve your own staff from a business area expert into an information system expert.
There are other options: Rebol is one. Rebol is a case where one language is all that is needed for the web project.
But for a gentle learning curve, it would be hard to beat Curl.
And while there are licensing fees, they are not prohibitive as are the fees for,say, the Eiffel Windows library. It is a differnent business model and it is popular in Japan and elsewhere in southeast Asia.
And it could mean competitive advantage for a small firm whose product is under price-point pressure from a larger firm with a bigger web presence.
Ordinarily, taking on your own web projects means sacrificing the dynamic web content that an outside vendor could enable.
For an example of Curl at work, just visit Flickr
Oh, about hiring that Flash developer who not only knows ActionScript but who also was in on the latest Adobe Apollo Beta ... the Basic Language used the $ sign. VBSCript for ASP pages still do. But Javascript for the small company may require more like $$$.

Reformed Curl

This is the post, or an effort to recreate the shattered post, on LcurlR.
Here is an LcurlR
{ some-curl-code }

which you could think of as
lCurl some-curl-code rCurl

Now that my wit has been relegated to the universal bit bucket, I will keep this short.
Here is a Curl snippet:

{curl 1.0 applet}

{let name:TextField = {TextField max-chars = 30, value = "My name"},
address:TextField = {TextField max-chars = 60, value = "12635 Somestreet"},
city:TextField = {TextField max-chars = 50, value = "Plymouth-or-Gardena"},
state:TextField = {TextField max-chars = 20, value = "MN-or-CA"},
zip:TextField = {TextField max-chars = 14, value = "55441-or-90245"}
}


Because RSI is a reality and not just a TLA, here is the same snippet in LcurlR
{LcurlR 3.0 applet}

{let name:= {TextField max-chars = 30, value = "My name"},
address:= {TextField max-chars = 60, value = "12635 Somestreet"},
city:= {TextField max-chars = 50, value = "Plymouth-or-Gardena"},
state:= {TextField max-chars = 20, value = "MN-or-CA"},
zip:= {TextField max-chars = 14, value = "55441-or-90245"}
}

If you are stilll not convinced of the virtues of LcurlR syntactic sugar over Curl try
{define-proc public
{sphere-vertices-normals hres:int, vres:int}:
({Array-of FloatDistance3d}, {Array-of FloatDirection3d})
let vertices:{Array-of FloatDistance3d} =
{{Array-of FloatDistance3d}.from-size
(hres + 1) * (vres + 1),
{FloatDistance3d 0f(m), 0f(m), 0f(m)}
}
let normals:{Array-of FloatDirection3d} =
{{Array-of FloatDirection3d}.from-size
(hres + 1) * (vres + 1),
{FloatDirection3d 0, 0, 0}
}

Programmers will tell you that their editor has a customizable code-completion feature. But what it may not have is a hi-lite option for all those type declarations which are otiose.
Lets start here:
let vertices:{Array-of FloatDistance3d} =
{{Array-of FloatDistance3d}.from-size

versus
let vertices:=
{{Array-of FloatDistance3d}.from-size

Without some such sanity I cannot see Curl regaining a foothold in small companies which might otherwise be tempted to use Curl for their own web needs. Small companies understand the cost of RSI.
Curl may continue in Japan. Making a language needlessly difficult to read and write is the very essence of Nihon-go and the barriers to the gai-jin.
China might change. Vietnam might embrace LcurlR. Or Sri Lanka with its plethora of alphabets.
Perhaps Curl can wait for the SemanticWeb and a new Google. Until then, try a google on 'curl' and tell me then that a name is just a name. Then try a Google on 'LcurlR'
I rest my case { embrace {reformed {curl LcurlR }}}

Sunday, May 20, 2007

Rebol

My Rebol notes are going to be at what is somewhat marred at the moment by rant about what the trial version of Microsoft Office OneNote 2007 did to my licensed instal of OneNote 2003 ...
Only this morning I enter my office to edit this post to find my computer stone-cold dead. When Microsoft Windows XP comes back to life, a little message tells me that a security update required a restart.
I do not have the time or energy for a rant this morning: on to Curl, curlr and rCurl

But I am back. About 30 minutes later. And with no Blog POST for LcurlR.
Microsoft Internet Explorer 7, IE7, perhaps just to remind me of last night's fiasco, simply froze. I knew that blog post was history. I had not hit Save-As-Draft. Daft. I do not have time or energy for a rant.

So why was I not in Firefox ? Firefox will recover. It will reopen my 12 or more sessions with their multiple tabs. My machine will start to crawl (some have the Adobe plugin running.) Said I, you just want to post a blog on LcurlR. Firefox can wait. Wrong.

Tcl, fork, CommandShell and Squeak Smalltalk

Something rather Tcl-ish is available to Squeak Smalltalk based on the OSProcess classes: CommandShell. And of course it is only fully implemented on a Linux installation of Squeak.

But in Win32 where you cannot fork, you can likely get by using a socket on the child process, and there Squeak shines. And sockets are a definite alternative to messing with NamedPipes on Windows.

CommandShell detects whether it is being passed code to interpret or commands to execute, rather like a Tcl shell or any other scriptable shell. But scripting with Smalltalk is almost always a pleasure.

tbc at http://www.eclectic-pencil.com/

RIA Plugins: Curl Surge versus Adobe LiveScript/Flash/Apollo

This is just an IOU

If LiveScript/Flash is thought to be the answer for a browser-based commercial software project, then surely Curl must have been considered and eliminated. Likely not.

If a captive audience of cubicle domiciled users is to use plugin-Y, then there is at least a plugin-Z that merits consideration: the Surge plugin.

The Curl case is two-fold for RIA: the 'gentle slope' and the 'one-language-mastery' versus journeymen of many languages and apprentices in more.

Friday, May 18, 2007

http://www.eclectic-pencil.com

technorati is having problems with the frames in http://www.eclectic-pencil/ so this blog may run from a new home ... and as this was the home of my logiquewerks blog ...