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 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();
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 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

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


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

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

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 ...