Monday, December 27, 2010

Logtalk 2.42.1

Logtalk 2.42.1 for most Prolog implementations was released on Dec 22, 2010.

To quote from logtalk.org
Logtalk is an object-oriented logic programming language that can use most Prolog implementations as a back-end compiler. As a multi-paradigm language, it includes support for both prototypes and classes, protocols (interfaces), component-based programming through category-based composition, event-driven programming, and high-level multi-threading programming.
The release notes report (among other things)
includes portability updates for B-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP

Tuesday, December 21, 2010

Metacello ConfigurationOfAida

  Gofer new
    squeaksource: 'MetacelloRepository';
    package: 'ConfigurationOfAida';
    load.

  ((Smalltalk at: #ConfigurationOfAida) project version: '6.0') load.

"the above is the code for a DoIt in a Pharo or Squeak Smalltalk workspace so as to load AIDA/Web by Janko Mivšek."

"This and the above are in quotes because Smalltalk comments in code are in dbl-quotes."

"The two semi-colons above permit three messages to be sent in series to the instance of the Gofer service. A period (full-stop) ends those two keyword messages and the final unary message."

"What is argably not clear is that the first two messages set values in slots but the last directs an action. I say this because 'load' is not unambiguously a verb in English.  It would have been lovely if set and do had been available as no op sugar useful to an Slint."

  Gofer new
    set squeaksource: 'MetacelloRepository';
    set package: 'ConfigurationOfAida';
    do load.

"An easy mod to most Smalltalk implementations would be "
  Gofer new
    set_squeaksource: 'MetacelloRepository';
    set_package: 'ConfigurationOfAida';
    do_load.

"One up-side might be reminding developers to not hide actions in methods which consume value arguments. But that ship sailed in 1980 or earlier.

Here is the added quibble: the first two values are names (the second is certainly not a package qua object) and so this code might better have been more revealing as: "

  Gofer new
    set_squeaksource_id: 'MetacelloRepository';
    set_package_name: 'ConfigurationOfAida';
    do_load_package.
   Transcript nextPutAll: 'I blasphemed against ST.'

"What cannot yet be done is to send a message to a class
  >>requestFreshObject
and have the class request the needed parameters of YOU either then or at the time of the proposed action.

I say this because >>new is not the sole means of acquiring a reference to an instance. "

  >>new
    ^self shouldNotImplement 
" a possible class method in Gofer "
 
   Gofer default   "would be no surprise"

   SmalltalkComms currentGofer   " may lie in the offing.

So "

   Smalltalk user: me requires: (package named: 'Aida') from: (Metacello squeakSource).

"Unlike Curl, in Smalltalk the order of those keywords matters because no semi-colon means that the last message send used only one selector named
    user:requires:from:
and only by looking at the actual code would you maybe know which objects to supply.

And yet "
  Gofer new
    squeaksource: 'MetacelloRepository';
    package: 'ConfigurationOfAida';
    load.
" is so easy - provided that you already know to use Gofer and also know to provide a version as in "

   (Smalltalk at: #ConfigurationOfAida) project version: '6.0') load


" That last direct call into the global Smalltalk dictionary is a sure sign that even this great improvement in loading packages into Smalltalk is an improvement itself awaiting another iteration.

For generations, introductions to Smalltalk have glossed over the pragmatics of Smalltalk - the actual use of Smalltalk in context for some end.  It may even be that calling Smalltalk a 'language' is itself misleading and so I should not use the 'pragmatics' metaphor.  Back to guilds and artisans?
"

Tcl EventLoop

TIP #379: Add a Command for Delivering Events Without Tk


Seen at http://www.tcl.tk/cgi-bin/tct/tip/ as a Tcl Improvement Proposal.

Compare: Smalltalk's new Announcements framework or Curl's Sonntag.

A blog note regarding Dolphin Smalltalk.

Tcl 8.6

The manual page is at http://www.tcl.tk/man/tcl8.6/ but TclOO may not be final yet for 8.6 ?

Preemptive Predatory Partnerships

Note the plural. One is never enough - not in the crawl and scramble and crawl to that first personal billion ... which for two partners means?

This is the tale of IT and the litle ISV that could and would.

I wonder if the MBA schools are neglecting this topic?

Here's the short course.

Preemptive Predatory Partnerships 901.

Company X competes with Y and Z in a niche IT market as an ISV.  X fears that Y or Z may partner with ABC or JKL.  Try to partner with both ABC and JKL and let both know they are being considered. Partner with whichever first.  Drag feet. Fiddle with your API.  Send them your most useless 'architect' (just promote a senior developer who was warming a seat.) Start work on your own ABC-like or JKL-like product.
Now let the non-partner know you are already not to happy with your choice of partner, you made a mistake yah-da-yah-da.  You can see where this is going.

If you are good at it - really good - which you do by focussing on this 'strategy' rather than your core product - you can end up with a package better than that of ABC or JKL and the tax break and then the company that acquired floundering Y or Z now wants to acquire you - but not for that lagging 'core' product- but rather for your own little skunkworks alternative to the product of baffled ABC and/or JKL.

If you are really lucky ABC and JKL were located in Ireland and by the time you are acquired, they are defunct and they never understood the game.

It's like playing 'spades' with someone who thinks they know how to play whist because they once learned bridge.  You told them the object of the game but heck, it just looks and feels so much like whist ... and you make 500 ... or that first 100 million that is the first step to that first big B. That's an American 'B', 'natch.

Real advantage accrues to the partners at X, Y or Z who can sell the idea that their company "True-T-U" is their 'baby', their 'life' and is ever so definitely not for sale - which is why the partnering is so critical to our mutual success.  The successful entrepreneur with 3+ startups under his or her belt or bonnet by age 50 was first a ruthless salesperson by age 30.  Scramble, yes.  But don't neglect the all important crawl.

Partnerships.  Don't head to the banquet to feast with someone who is yet to display a good appetite.  It's rather like marriage before sex.  So partner, beware.

Motto: Just because you arrive at a square-dance with a partner doesn't mean that you won't be going home alone dressed in a sack and with nothing but old bags from Ralph's or Lund's on your feet.

If it's not for sale, it might as well fail.

Monday, December 20, 2010

Seaside versus Aida

The Aida 6 web framework is rather different in objectives than Seaside 3 as a Smalltalk application server. My specific interest was to determine to what extent the services for web applications were orthogonal to any given web markup.  Both default to HTML but I am looking at frameworks suitable for emitting declarative Curl markup using the Curl web content language (originally MIT and now Sumisho.)

Both frameworks loaded fine into Pharo as Metacello configured packages and both had gotchas which required some experience in Smalltalk - unlike the Gofer and Metacello tools themselves.

What was distinctive in Aida was the need to make changes across many framework classes - and in Pharo Smalltalk, I can see no way to move new methods for base classes into my packages other than the *extensions mechanism.

The worst problem was an >>initialize method which started with super initialize and then failed to call a private method - the one mechanism that permits a subclass to override initialize properly ( I will submit my change as a fix.)

A serious problem was the lack of critical cleanup and reset methods ( I only needed to add one to Seaside for WAKom.)  I will submit these to the Aida team.

You will not want to try to prototype anything in Aida without using the process browser tool and without running a set of >>allInstances sanity-check mthods.

The proliferation of objects comes from inadequate cleanup - but in a Version 6 of Aida may reflect the reliance on loading packages into base images.  This is terrific for PITL but Smalltalk was always great for prototyping and that almost means maintaining a 'working' image - which is one way to spot objects that hang around.

In the early days of Seaside my rule was to discard any image in which Seaside had launched.  For anything other than prototyping, Aida would mean working from a close-to core base image.  That's just my take on what I saw after running two subclasses of SwazooSite in the same image, stopping, saving, quitting, launching ST.

And all bets are off until I have seen what a production image looks like - in the old days this was a matter of "stripping" images down - but we should now be in the age of building core images up.

I say that with a clear awareness of just how tiny servers can be in other alternative languages - such as Rebol - aside from any issues of code getting reused, code being understood and code being maintainable.

In the positive column: Aida has achieved a dialect for composing web pages which I think is on a par with Seaside.  But Rebol is also great at dialecting ... so dialecting is not enough.

In secure corporate environments where Curl shines, I remain concerned with the use of a pharo.st file at startup.  On the other side of that coin, the Aida tag method looks as if it should be reading from a resource file as adding a new tag should not always be a matter of changing framework level code.

At this time I have more of Curl running under Seaside but neither have the equivalent of 'halos' in Curl yet - so the jury is still out on a Smalltalk web framework for Curl markup.

Curl has great prospects in Asia, the subcontinent and Africa (most professional Curl developers are in India and Japan) wherever security is paramount.

My current work has moved from "eyes-only" document browsing* to "dark documents" on analogy with "dark matter": shedding light on a file directory or a DB table does not reveal them.  The key is to make "dark documents" run light in collaborative environments.  Both Smalltalk and Curl come with such excellent programmer facilities that they make a terrific match for prototyping a dark objects source and viewers.  And Curl has an exisiting inheritance mechanism near to Traits and no barrier to evolution away from classic OOP  (having been designed and implemented by MIT Lisp and Scheme experts at curl.com)

More to follow ...
* a early prototype for which there are links at logiquewerks.com and at aule-browser.com - both required the Curl runtime for the browser or the Curl REPL with scripted variants.
Enhanced by Zemanta

Sunday, December 19, 2010

poetry markup

The motivation for emitting Curl markup instead of HTML markup from a Smalltalk web server was to have the benefits of Curl as poetry markup.

Curl macros and text procedures mean that poetry layout can be simply

  {poem title="...",
     {stanza ...
     {stanza ...

or

   {canto
      {line 1, ...
      {line 2, ...

or whatever proves suitable: {verse{book, {couplet ...  The marked content remains eminently readable and automated layout is a breeze.

The real strength of Curl for poetry markup lies in presenting/suppressing/selecting annotations, variants and variant translations inline - which of course also can be done with CSS and classes using visibility and scripted with JavaScript - with both the ease and elegance of Curl.

マークアップを生成します。
  شعر نشانه گذاری.
 توصيف قصائد.

시를 마크업.

詩歌標記。
標記。
標記詩。
  
thơ đánh dấu.
bài thơ đánh dấu.
đánh dấu bài thơ.


شاعری مارکاپ.
شاعری مارکاپ.
مارک اپ نظمیں.
şiir biçimlendirme.
biçimlendirme şiirler.


मार्कअप कविता.
मार्कअप कविताएँ.


诗歌标记。
标记。
标记诗。


поэзия разметки.
Стихотворение разметки.
разметки стихи.


poezja znaczników.
wiersz znaczników.
wiersze znaczników.


a marcado la poesía española
para el marcado poemas Españoles


di markup poesia italiana
di markup poesie italiane


le marcáil filíocht agus amhráin.
le marcáil dánta agus véarsa.


для разметки поэзии и песни.
для разметки стихи и стихи.


Gedichte und Lieder Markup

techniques pour baliser la poésie et des chansons ...
... au balisage des poèmes et des vers.
         

Pharo Curl

It took some effort again to get Curl markup running as an alternative to HTML+JavaScript on Seaside 3.0 on Pharo 1.1.1 Smalltalk.

The worst nuisance was Seaside using a method named text: for the equivalent of stream nextPutAll: or document print

This is because text is a common declarative identifier in Curl markup.  But it is only an annoyance and without examing available selectors at runtime or usinf perform: I can't see a workaround while leaving Seaside intact.

What was vexing was to still have to modifiy the WAAdmin class to defeat HTML-bias built into the framework.  And one or two other known quirks.

If only Seaside would embrace Traits on Pharo Smalltalk!  Traits would make it so clear that the choice of markup can be separated from the choice to use continuations, to use halos ...

Traits might also reduce the reliance on the Decorator pattern.  In a language with late binding, this leads to odd code, such as assigning a stream to an object whose class name and instance identifier clearly mean that it is not a stream ( but of course it is a decorator of a stream.)

Traits might reduce the reliance on the visitor pattern whcih I think reduces the understandability of code far more than double-dispatch itself because of the proliferation of visitor classes.  It is no longer necessary to ake a virtue of that necessity ( dare we now say, 'limitation' ?)

Many things are improved in Seaside 3.0 so that overall flipping from HTML markup to Curl goes well in the details - especially in a reduced need to subclass where closed tags happen to be identical across HTML and Curl.

It was amusing to me this time to add crlf so as to get better formatted Curl markup to inspect using the Curl source inspector - and spc to put spaces into the markup layout itself (Curl ignores whitespace the same an HTML client.)

The one concession was to use txt: to dump plain text - but super was not enough to preserve a Curl text: tag - for that I had to look at the runtime class so blocks go to text: and strings go to the canvas encoder for printing.

Curl 'attributes' (properties and options) are laid out the same as Seaside HtmlAttributes so anyone who can layout HTML for Seaside can layout Curl while remaining on 'the gentle slope' of the Curl language when used for declarative web content markup.

It still may be that Aida will be a better home for Curl poetry markup on a Pharo Smalltalk web server.

gnote off Ubuntu Maverick

Finally gave up on gnote on Ubuntu as a linux alternative to Evernote ( I refuse to install Mono just to run Tomboy notes.)

How much to install just to get worrisome compiler warniings and then runtime errors?  Boost, for starters.

apt-get got me a gnote for maverick that was a non-starter.  Hours later I still could not get gnote to build free of fatal runtime errors.

In hindsight, I would have put the effort into spec'ing out my own linux client to Evernote - which I already use on other devices.

Thursday, December 16, 2010

Metacello Pharo

I am loading Seaside into a Pharo Smalltalk (1.2 beta) 'core image' running on top of the latest Cog VM using
Gofer new
   squeaksource: 'MetacelloRepository';
   package: 'ConfigurationOfSeaside';
   load.

(Smalltalk at: #ConfigurationOfSeaside) load
which is going fine except that I occasionally have to look to see what cycles the process is consuming as I get no 'busy'cursor and the 'top' progressbar stays empty - during some downloads the image returns my blank stare.
It is good to see that I do not need 'ConfigurationOfSeaside30' to get 3.0
And only one walkback so far ( a minor deprecated method to correct )
Enhanced by Zemanta
OOPs ... I saw Cfg of Seaside loading Cfg of S 3.0 but here comes a pile of 2.8   oh vey.
How will we escape 'ConfigurationOfSeaside3.1bOsX' etc etc ?

And POOFFF! Magritte compiles by kicking back multiple error streams ... and we are off to try
Gofer new
    squeaksource: 'MetacelloRepository';
    package: 'ConfigurationOfSeaside30';
    load.

(Smalltalk at: #ConfigurationOfSeaside30) load
On my first try I type '3' and not the full '30' and was rejected (not advised, but rejected.)

The issue is that Smalltalk is not yet organic software: it is component software.  But then I see that Pharo offers a configuration ST file.  Now I have to go check to see if this facility remains available in a 'stripped' Pharo image.

This is an old Smalltalk implementation issue often glossed over - but try to explain to some one tasked with Governance, Risk and Compliance (GRC) that your Pharo image starts up by evaluating a raw ST file.  I remember a mission-critical app at a Fortune 100 where one of the ST files being consumed (Why not read and interpret all ST files that you find in the image directory ? ) was quite a shocker (for me, at least.)  But so long as 'stripping' Smalltalk images is more mysterious than establishing a 'base' Smalltalk developer image this concern will remain.

All in all, Metacello configurations are a big improvement.

I think that David Kranz says something about this in his Dr Dobbs interview on the role of the architect.

Meanwhile a class load method just failed on a createClass  message due to a global name collision - and I do not see the equivalent of a tool dating back to Cooper Peters 1990 for resolving this ... so a Seaside 3.0 on Pharo 1.2 alpha on Cog will have to wait for another day ... so back to Pharo 1.1.1 to further explore what Traits can bring to Seaside for multiple markup strategies (read: Curl in addition to HTML + JS)

Silver Smalltalk

'Vista Smalltalk' is back as SilverSmalltalk !

There is a silversmalltalk blog and a test page at appspot.

I saw this good news at planet.squeak.org

In non-news, there seems to be a little delay in Squeak 4.2 with the Cog VM ... other coming releases that I have an eye on: UNICON, a Rebol3 beta, Converge 1.1.1 and seeing Tcl 8.6 get out of beta.  And I am waiting to see what is next in ObjectIcon ... and for any news on a Curl 8.0 aka curl9 from curl.com
Enhanced by Zemanta

Wednesday, December 15, 2010

Curl memoization and a PEG parsing pkg

A text search of the Curl 7.0 docs using the Curl Documentation Viewer finds two mentions of Memoizer-of but only one is an implementation note:
make-SocketInetAddress-from-address
Memoizer-of is documented as
{Memoizer-of domain:Type, range:Type} (class)
This memoization class or its near equivalent would be crucial to getting PEG parsing into Curl as a package for a regexp alternative.
The other mention in the docs is suggestive and occurs as one of the notes to the docs on BucketHashTable-of of the package CURL.LANGUAGE.CONTAINERS

public final serializable BucketHashTable-of {inherits {Association-of tk, te}}

With regard to regexp, the Curl GUI packages already come with a RegexpValidator class for controls relying on use of CURL.LANGUAGE.REGEXP

Btw, great demos of the power of the Curl Documentation Viewer are the Regular Expressions doc pages with their 'live-code' examples for learning PCRE.

Tuesday, December 14, 2010

Curl ValueControl

Here's a challenge for class hierarchies without Traits.

The Curl class ValueControl is noted as follows in the docs:

ValueControl (class)
public abstract ValueControl {inherits Control}
Import from: CURL.GUI.STANDARD. Defined in package CURL.GUI.CONTROL-BASE.
Direct Known Subclasses: ValueControl-of
A superclass for any Control that has a value.
Description
All the Controls with values inherit from this class. It provides abstract accessors for the value, as an any, and an accessor for the expected Type of the value.
Overriding
Don't subclass this class. Subclass ValueControl-of instead.
I added emphasis to the advice. My question is, how might such an intent be enforced in a class hierarchy?  What would you call such a modifier or a macro used to create such a class?

The class in question has the 2 abstract methods value-type and value-as-any but it also implements 2 methods: form-value and has-value?.  In addition, it has a class procedure form-string.  The default constructor for the class is noted as
... : Rest arguments are passed up to Control, which passes them to Visual.
The method form-value is documented as intended for use with controls embedded in HttpForm instances.
It is documented as a getter but not as being abstract yet as intended to be overridden by subclasses.

Here is a snippet from those docs;
The value returned by this getter must be one of the following:
 • String
 • array of String
 • null
Notes
Each control overrides this method to return the value that needs to be sent when the HttpForm that contains this control is submitted.

So why is the method not abstract? Well, because it returns a value of type any - but its subclass is parameterized for types of values.  And here is one more thing that makes Curl fascinating: the leaf classes of these hierarchy branches are not themselves declared as parameterized for a type - and in the case of DateField, the value keyword parameter to the default constructor may be of a possibly-null type - a #DateTime type.

What this may show is that multi-inheritance with partially-abstract classes as mixins or otherwise can be very flexible:
public abstract MultiUIValueControlFrame-of {inherits 
   MultiUIControlFrame, 
   {ValueControl-of tValue}}

value classes in Curl

The Curl language for the last two versions has allowed explicit declaration of value classes used to create objects which can be moved on the stack rather than referenced on the heap.

There is an important tip in the Curl docs that one should keep such an object smaller than 64 bits so that it can be referenced as a simple any variable with no further memory allocated, i.e., why keep an object off the heap and then have allocate for it just to use it ...

A usual class declaration in Curl begins as the macro
{define-class
and these non-reference classes begin as
{define-value-class
which is in keeping with an accepted pattern as easy to recall.  But there are some caveats and they are laid out clearly in the docs.
The docs list Keycode, Pixel, and Vector2d-of as long having been implemented as value classes.

The Curl Documentation Viewer allows you to choose an installed version when opening another viewer, so I hopped down from 7.0 to 5.0 to look at Pixel - it was reported as (class) and not (value class) but perhaps that kept things from getting murky.  More often Curl docs state that a given feature is for internal use only.

rlwrap for the Curl shell

It is really essential to get a wrapper around some REPL's - the Curl shell is an example.

I run
rlwrap /opt/curl/surge/8/bin/curl --shell
which gives sane keystrokes and a command history.  If you are a client web developer coming over to the server-side, it is as essential a tool as egrep.

Pharo Smalltalk linux config

This would seem to be essential to working with Pharo Smalltalk on a daily basis on linux: pharo.st

Property ECMAScript5

If you are looking to port JavaScript3 up to strict ECMAScript5 in whole, part, stages but you have some choice for mission-critical applications, here is a glimpse from the package CURL.LANGUAGE.REFLECTION
Property (class)
public abstract sealed Property {inherits ClassMember}
Package: CURL.LANGUAGE.REFLECTION
Direct Known Subclasses: Getter, Option, Field, Setter
The representation of a property: Field, Getter, Setter, or Option.
The Property class provides a singular point of contrast for a mature web language against a maturing web language.

What is facilitated are such primitives of the Curl language as private-set
field public-get private-set key-field:int
There is as yet no tool for PITL with CommonJS packages comparable to the ability of the Curl Documentation Viewer to display selectively only public, non-inherited properties of a class as part of a package.  And what is PITL without such tools for communicating what is in a API?  Now look for comparable 'live-code' example facilities for training developers new to a language (they may yet appear in JavaScript as part of Avocado with Lively-Kernel.)

When I hear advocates of reusing an existing JavaScript codebase for PITL on industrial-quality server-side applications I wonder whatever they can be thinking?  Would this have been an aerospace argument to stick with aluminum?  After all, there are more aero-mech's out there accustomed to repairing aluminum aircraft components ... and far more aluminum in the air - and it was aluminum that made the air travel age possible ...

Monday, December 13, 2010

Curl BaseFrame

The Curl class BaseFrame is declared as
public BaseFrame {inherits BasicBox}
and is not abstract. Frame inherits from it as
public Frame {inherits BaseFrame}
and is certainly not abstract. But a RootFrame to root a graphic hierarchy is declared as
public abstract sealed RootFrame {inherits Frame}
and is abstract -yet its immediate subclass View is declared as
public View {inherits GuiRangeSelectionContext, RootFrame}
and is a very common class for concrete instances.  GuiSelectionRange is also abstract and is declared as
public abstract GuiRangeSelectionContext {inherits TextSelectionContext, BaseGuiRangeSelectionContext, ContainerDragScroller, OptionListInterface}
RootFrame and GuiRangeSelectionContext are performing a special role that Traits or Mixins might perform in another language.

View has a need to have its visibility specified as a property, which can be a stumbling block in first experiments with Curl. Here is an example:

{curl 7.0 applet}
{import WindowVisibility from CURL.GRAPHICS.WINDOW}
{View visibility=WindowVisibility.normal,
   {text Some text that will appear in a freestanding window}
}

View has an interesting subclass which is rather like the first window one used to create for MS Windows back in the days of C using only a frame: OutlineOnlyView.

BaseFrame is a usable class, which is not what the name would suggest in some other languages: it is usable in the sense that a subclass can make immediate use of its constructor in a class declaration as shown in the Curl docs:
{constructor {default}
     {construct-super.BaseFrame
which the docs say can be used as a special frame destined to have only one child graphic or visual object.

Rebol Altme

As soon as IE hits this blogspot blogger site this PM (ADT) today, ProcessExplorer shows IE consuming almost all CPU cycles - and with no end in sight, I keep killing it.  But Opera just opened on the site fine.  So I won't try Chrome.  No point in acting paranoid ...

And then there's Rebol.  It seemed today from an announcement in the altme.com Rebol3 'world' that a testable combo of runtime+DLL+gui-code was available.  But it fails immediately on any test I tried. OK - it's based on code that is not even in the R3 alpha yet, so no big deal.  I'll tinker with it and someone may post something on the style issue involved (some essential path type is finding a none! value.)

But altme.  This is the public face of Rebol these days.  Oh vey.  Not that I am so crazy about the curl.com developer site at developers.curl.com not being written in Curl ... but at least that site is largely useable and searches well with things such as google site:curl.com

Imagine (as I hop in and back out of the HTML editor in the WYSIWYG editor) - oh hang it, I give up on editing this post.

Of course what is far worse is this Google-owned blog editor in which I find myself at the moment.  It repeatedly traps a user in a blockquote element or in an em element - and it is not just a problem with some one browser.  It is all but impossible to post a simply formatted text without spending time in the HTML edit page. Okay. HTML is markup ...

And facebook - suddenly putting a url in a status makes it impossible to get rid of a web snippet that it shovels into the status update.  Give me twitter's fewer characters any day ...

And this blog's edit interface just screwed up two "carriage returns" in a row ...

Then there is the Rebol showcase web site which is not smart enough to set the background in CSS ... such very smart and capable and inventive people but a result that looks so dumb it doesn't matter how smart it is.

But there is always Microsoft OneNote:  a software pkg that by-and-large works and it mostly adequate to the task.

Question: how many x100 megabytes must an editor be so that it can format a short latin-encoded text [non-technical English] in simple paragraphs and emit it in a DOC format?  It must be a Monday. And I'm north of 45 deg LAT and its both warm and raining on Dec 13. Something's not right ...

There is hope for Rebol3 GUI: I see what style code did for Curl GUI's and such chrome will do the same for Rebol GUI''s.  What would be worthwhile would be for an historian of technology to document just how difficult it has been to move from Rebol2 to Rebol3 - difficult for such very bright and dedicated people.

But what explains why an altme/safeworld is so dismal: no simple reply metaphor (topics, not threads), no tagging (which is now all but universal) and no one able to step up to the plate and make a signature app outa that thing.  What vexes me most is the notion that there was some advantage to be had in writing the darn thing in Rebol at the very point when it had been acknowledged that Rebol had to be significantly re-thought in order to be used for PITL.

On the positive side is the web bug tracking - but that has also become near universal.

In a sad parallel, Smalltalk is only now arriving at Metacello for a sane approach to loading Metacello packages.  For years loading open-source Smalltalk packages has been a near total crap-shoot.  And that from the folks who gave us class browsers, refactoring browsers, unittest frameworks, the wiki, eXtreme programming ... but Metacello configurations appears to be a strategy that is working - both for Squeak Smalltalk and for Pharo Smalltalk.  Is there hope for Cincom VisualWorks Smalltalk ?  Their public code repository is those nightmare in which those use it to commit code are used to it and continue to use it ("Isn't it great?") but they also wonder that Smalltalk does not catch on.  Just compare Ruby gems any day.  Python virtualenv may be an embarrassment that is less than a kludge, but at least it works as intended.

Curl ain't JavaScript/ECMAScript

A question was posted over at developers.curl.com about creating a an off-screen 2D Drawable that exceeds a Curl sanity check on screen resolution.

A Curl developer should be able to bypass the current 'reasonable guess-timate' limit with the expression
{Drawable.set-bypass-size-restriction? true}
prior to using a
{Renderer2d.create-offscreen ... }
The docs offer this practical test:
let display-context:DisplayContext =
{get-default-display-context}
let resolution:Resolution = 1 / display-context.pixel-size

There was a time when this was worrisome: we offered opportunities for staff with domain expertise to work in Smalltalk - but in the day of math coprocessor-on-the-board or not it was important to watch out for division.  In other languages we tried not to offer examples using division when multiplication was mandated - but Smalltalk was an exception because it offered rationals.

In code such as the example which would execute once, this really is a non-issue.  but all the same - this should have been
1 div display-context.pixel-size
to return an integer value.  Now for inverse or reciprocals.

In Curl, the exponent approach to obtaining a multiplicative inverse is
{pow n, -1}
The Curl compiler package contains the trig functions but no inverse function ( the Quaternion package has an invert and there are other inverse functions.)

The example becomes
{let display-context:DisplayContext =
    {get-default-display-context}}
{let resolution:Resolution = {pow display-context.pixel-size, -1 }}
But is this needed on current hardware?  Or is the compiler addressing this?

In JavaScript, the developer has the Math object and any available packages (  Python recently replaced numpy.)  But in Curl, the trig functions are addressed by the compiler.

Screen resolution itself poses a JavaScript and server issue because now the programmer is dependent on the browser supporting screen.width as a feature and likely a cookie.  It is much less an issue in Curl.  and that is before looking at CSS versus Curl styles.

Curl also offers this declaration in the docs:
{Display.set-resolution-mode
      mode:ResolutionMode,
      override-value:Resolution = 0dpi
}:void
as well as
public   {Display.get-displays}:{Iterator-of Display}
Moving on to Curl and 3D graphics - I see this for HTML5

Extensive work on Curl 2D dates back to a PhD done in 2001?
Curl 3D
[ to be continued ]

Sunday, December 12, 2010

Curl primitive never-returns

The docs for the Curl package CURL.LANGUAGE.CORE-TYPES cover a distinctive primitive: never-returns

There is an example by Chris Barber here.

The IDE docs example is in a Curl live-docs {example } macro for running/editing/saving doc code snippets and goes like this
{define-proc {not-odd-error i:int}:never-returns
    {error {format "%s is not odd", i}}
}
{define-proc {assert-odd val:int}:int
    {return
        {if {bit-and val, 1} == 1 then
            val
         else
            {not-odd-error val}
        }
    }
}
 It is not at all the same as the language primitive named void.

Which somehow brings me round to JavaScript and new.

In Curl, the programmer is not required to use the {new } macro - and using it requires another comma in a declaration.

So why ever use {new MyObject, my_args} ?

It might be this: what MyObject is specifying for the macro is a type - and that type may be determined at runtime.  This is not what you usually expect in a language that is "typed" - but this is a language which also has an any type.

So one step further: in Smalltalk the issue is to know who should implement new and basicNew and new:

But in Curl, new is also a method: it is a method of 3 classes in the package  CURL.LANGUAGE.REFLECTION
Constructor
Factory
InstanceMaker
Here is what the docs say about InstanceMaker:
public abstract sealed InstanceMaker {inherits ClassMember}
Package: CURL.LANGUAGE.REFLECTION
Direct Known Subclasses: Factory, Constructor
The representation of a Constructor or Factory for objects of some class.
Notes
See ClassType.
Note that the {new } macro is from the package: CURL.LANGUAGE.COMPILER
Which somehow brings me to {let  ...} {set  ...} and {def  ...} ... and {value  ...}

I recently posted a Rebol tyro puzzler
   p: 42 lst: [p ] what: first lst ; What is the value of :what ?

There is a great little bit in Icon about assignments which do not occur and assignments which reverse when an expression does not succeed. Like Rebol and Curl, Icon is expression-based.  But what huge differences in the paradigms of these three unusual languages. Icon has the prefix dot for de-referencing and Rebol has the word reduce.

let and def are primitives of the Curl language; set, however, is a macro - as are {value ...} and {do ...}.

In some ways, the Curl docs articles on let and value are a great introduction to the language ( def came to Curl only recently.)

What I have found is that it is not all so very clear to neophytes just what is meant by "top-level" code.

Let's take the case of a Curl applet intended for a web browser.  The content of the Curl applet is found in a document which will be one of 3 possible types.  the default type need not be declared and is DefaultDocument.

Someone new to Curl places a {VBox } as declarative Curl in a pristine applet, runs it and nothing appears in the browser.  Or is that so?  This is why I always have my windowing environment on an OS flip my default window backgrounds to some pleasant shade of green: when a browser pane shows me that green background - even if just in some text entry field - I know that something is missing.  The default Curl document background is white.  My demo strategy is this: make things explicitly and declare things explicitly.
{curl 7.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{applet
   name="top level demo",
   notes="like rebol, add most any metadata tag - this one is called       notes"}

{document-style DefaultDocument}
{set-document-properties background =
    {Background.from-string "blue"}}

{title heading? = false, Demo}

{VBox
   {text {value 65535 + 42}},
   {paragraph btw, 6782865577 is prime},
   {text So, what was the question?},
   {new HBox, {paragraph this is just some text ...}}
}
|| end of applet comment =====================
|tagged-comment#
                                 [ to be continued ... ]
#tagged-comment|

notes for an open letter to Crockford on Curl

I am working on a response To Douglas Crockford's comment concerning the case for server-side JavaScript (beyond Yahoo and YUI3) for my blog at developers.curl.com

This is just a first pass: open letter to Crockford
  0) mea culpa.  Sorry about that.  I do apologize. Crockford on Rebol. That was simple ignorance on my part: I thought "I knew my Crockford."  I was wrong to think that I have paid close enough attention to your work. I was wrong not to research that.  I have known for a few years that there was a Rebol link on the JSON page.

  1) But. We should try not to misrepresent/understate/elide the salient facts in history of science - even an applied science. SUN and the fate of Self and Strongtalk is almost as wicked a tale as RCA and FM (see the story of super-heterodyne and the 9/11 broadcast mast.) The history is about the team that Sun provided Netscape, is it not?  Or is it me who has substituted myth for history (the human bent) ?

     a) from Self to Javascript
     b) Google V8 inlining [ no puns: see inline-8 engines ]

 Setting the facts straight: (i.e., setting me straight)

    Dates: (timelines)
      JavaScript and Java are 1995 releases
      Strongtalk dates from 1993 and ideas put to work in 1994 but completed only in 1996 and for a company acquired by Sun in 1997.  So that team did not work on getting LiveScript up to JavaScript as I was told one evening in L.A.
So much for hearsay; history is most often based on the available documents but tempered by documents unavailable or suspected to exist (when there are documents;  see below: transparency vs dark-documents; recent case: Katyn)

BRB: Blog Readers Beware of 'web' documents: Frank and Stein Java's history interview at javaperformancetuning.com on April 1st 2003 by Jack Shirazi
See: Frank Yellin and James Gosling.
See: the Ralph Griswold papers at UMN (Icon and SNOBOL)
NTMR NoteToMyReaders: not be confused are Ralph, Bill and Dave Griswold as identity matters for more than just objects.

      Self -
         GC paper 1984
         Self starts at Xerox PARC in 1986
         the critical paper dates from 1987
         first release in 1990
         acquired by Sun in 1991 [inlining paper is Sun 1991 ?]
      Java - work began in 1991

      Q: who worked on second gen-JS and second-gen Java ?
      Q: who from Sun worked on JS at Netscape with Brendan Eich ?
              - prior to and in 1995
              - 1995 and later
          what were their roles and what were their contribution
      Curl
         - work began in 19__
        SIGPLAN 1986
David Kranz. ORBIT: An Optimizing Compiler for Scheme. Ph.D. dissertation, Yale University, February 1988. Research Report 632, Department of Computer Science.
                 DARPA grant details:
        whitepaper 'the gentle slope' or 'The Curl Project' authors:
              M. Hostetter, D. Kranz, C. Seed, C. Terman, S. Ward
              Organization:  MIT Laboratory for Computer Science
                                      545 Technology Square, Cambr. MA
The Curl project is supported by the Information Technology Office of the Defense Advanced Research Projects Agency as part of its Intelligent Collaboration and Visualization program. 

         - free software movement at MIT
         Q: is 1998 a correct release year ?
         - Michael Dertouzos dies unexpectedly in Aug., 2001
               a note and the Dertouzos Lecture Series at MIT
         - PDF  Morgan McGuire "The Curl Graphics2d Immediate Mode Rendering API" supervised by Steve Ward [thesis date May 17, 2000]
         - decision to 'spin-off' from MIT in
         - low point of dot.com crash: 2002
         - the major Curl programmer's book: 2002
         - decision to participate in open-source in
     Scheme
         Guy Steele and Oak/Java (James Gosling, Bill Joy, Guy Steele) [see Java and closures]
         Steve Ward et al and Curl ?
         Brendan Eich and Mocha/LiveScript/JavaScript
     Python
        Python and Java in the MIT CS curriculum

    LISP & Curl
       On T at paulgraham

 
  2) Curl is swell - not so very swell as it has a big unknown and a few gotchas, too.
 
       Let's take Pharo Smalltalk as a really 'swell' language (and yes, Pharo is both server-side and in the browser.)
      
         Classic Smalltalk 80 got many things right, but tended for years to reject composition in favor of inheritance. Smalltalk implementor's pride was the Collection hierarchy with its list comprehensions exploiting blocks.  Smalltalk's weakness was a lack of interfaces (implemented using inheritance as abstract classes relying on
             >> subclassResponsibility
          In hindsight, given the work of Ducasse (the 'Crockford' of Smalltalk) we can see that both the perceived strength and weakness were neither. This is what Traits bring to Smalltalk: insight and results.
          The strength of Smalltalk can be seen in the ease with which both Traits and Seaside continuations could be introduced into a 'transparent' boot-strapped language [and SOUL and Backtalk and ...]

   Truly Swell: Pharo moves onto Eliot Miranda's Cog VM from Teleplace.com
         
       Now Curl
          Curl uses Regex.  In an expression-based language this is something of a travesty [not to use it or to offer it but to offer it only and solely.]  I call it  'the manager says use Perl' fallacy.  That fallacy applies to JavaScript: in my experience the manager says to use JavaScript in our custom site-specific intranet collaboration browser because we can tell the  CIO or CTO that HR can always find us JavaScript programmers cheap. [ I heard for years how expensive Smalltalk  developers were even after we had proven the value of offering Smalltalk training to non-CS employees with domain expertise in telecom].  Until Crockford (or without Flanagan) HR were hiring JS programmers who often had not learned their language.  Python programmers argue for python in the browser and python on the server so that they will be able to think in only one language. This is folly.  But python out-performs ruby so appears unstoppable. virtualenv is lauded although virtualenv offers something of a reductio ad absurdum for python-in-the-large.

          The libraries: arguing for JavaScript without looking at the Curl package documentation in the live-Curl IDE help applications is less than responsible.  Nothing in Prototype or Dojo comes close.  [ so, in faireness, I must segue here to YUI3 ].  In comparison, Smalltalk packaging of libraries is a nightmare. And ObjectIcon has a long ways to go and Rebol3 is only getting there now [only now do we have a UNICODE Icon and Rebol - there Curl shone and JS now shines.]

    Curl has not fostered the use of explicit constraint resolution or constraint handling  Curl for open-source still sees key, essential-to-grok code libraries unavailable even though they are not compiler or runtime engine specific.
         
    But.  A Curl developer who learns Curl syntax has a much better chance of understanding the strength of the language if she also learns and uses the macro facilities with which her daily coding expressions are built.
         
    So what is the history of Curl?  There is no need to compare JavaScript for serious server-side  to 'wild cowboy python' and its dynamic objects.  Every flaw in the JavaScript of 1999 was not a flaw in the Curl of 1999.  Curl is the foil.
         
    It is true but trivial that Curl is not on the server-side (in public).
         
   Rebol.  It is just not relevant that Rebol is not in wide use.  Monitoring the rebol-based  altme.com 'rebol world' reveals where rebol is in use.  Rebol2 has issues, but in practice, JS proves to tbe the problem child, not Rebol.
         
   The truly great language that is only used on one important funded project: ICON.  Ditto for Oz.
         
   Ditto for Caml (almost)
   Programmer says: we had to learn Prolog in a 300 class.
   Programmer says: we didn't learn Smalltalk ... is that still used anywhere?  It's kinda-like Prolog, but with objects, right?
          Where Curl was wrong in 1999.  The Curl pay-for-use came about 10 years ahead of GoogleAppEngine  and came at a bad economic juncture.  Curl faled to protect its name ( cURL horror: if I type curl  on my linux box I run cURL and not /opt/curl/surge/8/bin/curl
          Curl failed in not separating content from presentation. This has been addressed.
         
          If Curl had been free the way in which ICON was free ... (see the history of SNOBOL.)

          Economies of scale:        
         
         [ The MIT-trained Chief Technology Officer and Python: the case of the summer intern and the folly of dynamic objects in mission-critical code. A sad but true story.]
         
Why is there no lint ( Crlint ? ) for Curl ?

   It could be just a grep for pragmas and directives.
   It could be a grep for [ my const story ]
  
The missed 'killer app' was a Microsoft OneNote written in Curl or in ICON.

Rebol
  p: 42 q: 65535 lst: [p q] what: first lst
 
  GoogleTechTalk question: "What is the value of  :what  ??"
 
  But ICON and Curl are also expression-based languages - is this an issue in both of them? See: Rebol and denotational logic.
 
  And this is the issue of get words and set words being types in rebol.
 
  But wait a minute: look at {define-syntax} in Curl - such as
 
  {define-syntax public {first  ?item:identifer in
     ?list:expression where ?cond:expression}


  This is a conditional {first} macro declaration head suggested by Chris Barber at http://developers.curl.com
   
Another useful comparison of Curl as a web content language in 2010 and JavaScript 5: the Arguments object

And then there is the Curl documentation and the Curl IDE with the interactive debugger.  Now those are swell.

At the Michael Miller et al JS5 talk just before the release of the spec, a Google manager cautions that the talk is public when a minify issue is raised.  Why is minify not a Curl issue?  Answer: the pcurl file format.

To experiment with Curl:

  /opt/curl/surge/8/bin/curl --shell
 
NOTE: Scripting with Curl on the server:
  running an xcurl script does not launch the Curl 'applet manager'.

A current Curl weakness: the web docs remain 6.0 when Curl is 7.0

The Curl strength:  live code in the {example} macro and the documentation macros and 'text-procs'

Where to see good Curl code?  http://code.google.com/p/zuzu-curl and various at sourceforge.net

A great strength of Curl: the packaging and the packaging macros.
BUT commonjs.org

Great strengths of JavaScript: JSLint, JSON, traits.js, node.js  jQuery "use strict";

A weakness of JavaScript: the actual JSlint code.  Compare how this would be packaged in Curl. This remains a weakness of ICON and even ObjectIcon and is only addressed in Rebol3.
    
And I like the Crockford .create for new and the Crockford 'in closure find your privacy'

The manager for Perl also said not to use JSON because HR can always find XML programmers.

Here is my private constant story.  I cannot tell you the many,many global 200 organizations using this Curl codebase or a customized variant.

Suppose you ran grep on a src directory of source files for a modern language which provided encapsulation and a const declaration.  Suppose that in that large codebase maintained by a large off-shore coding firm you could not find a file with either
  private
  const
 
So it is true that people will not learn their language; so it is true that a prototype can get shoveled-and-shoe-horned out into production.

Python has the author of straits.py and JavaScript has Crockford.  Curl has Chris Barber, who really should be giving a Yahoo talk and a GoogleTechTalk.

Curl's release began with an unforeseeable tragedy for the CS dept at MIT - and an unforeseen economic crisis.  But evolution teaches us about a small furry niche-only mouse-like creature which we call a mammal and of which the larger dinosaurs took no notice.

Evolution's good ideas can start with few numbers.  Applied science should not be a popularity contest: not for bridges, not for Bose-Eintein condensates, not for creating, marking-up and transforming web content.

And like Pharo Smalltalk, Rebol, ICON, UNICON, ObjectIcon and Converge, Curl is evolving: a recent example is the access modifier named 'library' and 'library' as a languge primitive.

Q: has Steve Dekorte given a talk at Yahoo on his Io ? Would Ducasse come from Lille to show what his work in Berne has meant for Smalltalk ?  Or Robert Parlett for ObjectIcon ?

What Curl has rejected: continuations, coroutines, SNOBOL/ICON text strategies ...

A useful antidote: the paper on the Oz resizeable clock.  Also of note: the use of logic and constraints in Smalltalk: SOUL (Roel Wuyts), Backtalk and lisp.

Of note in Smalltalk beyond Traits: Cog VM and multi-core Squeak.

Question: should Curl be rejected over being based on an Object class?
   Note: Object has 3 public methods

Question: should Curl be rejected for using multiple inheritance?
   Note: some classes are declared as shared and implement secondary constructors
  Note: MI is used in Curl for abstract classes which serve as Mixins due to the simple rule that a single abstract method renders a class abstract.
  But: mixins ain't Traits.

Question: is Curl too-strongly typed for the server-side?

Question: should a server-side language be both distributed and offer co-routines?
Compare distributed Oz and ICON 9.5 as UNICON presses forward for concurrency changes.

Question: by the time JavaScript is as robust as Curl, will Curl still exist?  Will it have been forced merely to take a new name?

CSail refs: Curl at MIT
  with other items (PDF)
other refs: PDF at curl.com  · the first book at Amazon
On Michael Dertouzos at wikipedia.org and his book.
Other perspectives: see David Kranz, Steve Ward (2010), Ternan
The old MIT page.
Curl today (Japan) and USA.
What the Strongtalk site has as a history page.
Strongtalk at code.google.com/p/strongtalk
Eliot Miranda post.
Optimizing dynamically-typed object-oriented languages with polymorphic inline caches [1991]
David Ungar Sun patents.

What I think I 'know' about this history was told to me by a German PhD Xerox PARC researcher but I did not take notes or check facts later - so I have only hear-say from a non-participant.

Out-of-date DMOZ page for Self [ see Avocado and Lively-Kernel ] and blog.
c2.com Self page. Io page.  Pythonic Iconesque language: Converge.

See: inlining and Google V8: the history of a strategy cf: PDF and a Scientific Commons page. Many materials are Wiley, Springer or other for-pay resources.
Type Inference in Self (pdf).

Urs Hoelzle in papers at Gilad Bracha site.

Squeak Smalltalk bibliography.

Missing: a history of CSail Curl in terms of concepts, strategies, trade-offs, optimizations, performance, evolution, understandability, maintainability, limitations, regrets, bias, mistakes, economics [spin-off, acquisition, marketing]
   Web Document David Kranz and Bert Halstead
      note the history warning at its close
Kranz' diss is a Yale Computer Science Dept. tech report. I would say it is required reading for anyone interested in serious compiler technology for functional programming languages.
   see: Bert Halstead's parallel lisp

   2001 Slashdot.com 

   Kranz is named as an inventor on many issued and pending patents on the Curl technology.

See: Deirdre Blake, Dr. Dobb's Journal Jul 01, 2008 'The Architect's Role'
David Kranz is Vice President of Engineering and CTO at Curl (www.curl.com). Previously, David was a principal research scientist at MIT where he was a leader in parallel computing technology. David holds a B.A. in Mathematics and Physics from Swarthmore College, and an M.S. and Ph.D. in Computer Science from Yale University

Curl and security: http://www.dcs.bbk.ac.uk/~geoff/ForresterSecuringRIA.pdf
see also: http://www.curl.com/riasecurity/

Question: Yahoo in corporate Asia, the subcontinent and Africa: why not Curl?

Curl in public-sphere computing: the challenge of transparency while respecting genuine needs for security and privacy.

Curl and the anti-document/dark-documents in eyes-only SSB browsing.

Constraints: Alan Borning, Prologia IV, Oz clock, Backtalk

Saturday, December 11, 2010

dumping globals in node.js REPL

This seems handy in the node REPL.  It exploits a JS3 flaw in the failure to send new to a function 'creating' an instance.  The this in the dump function gets the context above and not ourself.
> function Fexp() { for (var v in this) { console.log(v) }; return this}
> var ex = Fexp();
global
process
GLOBAL
root
setTimeout
setInterval
clearTimeout
clearInterval
console
Buffer
module
require
_
from my running console. Was there an easier way?
See http://nodejs.org/docs/v0.3.1/api/repl.html

Zuzu Curl

One of the things that I like best in Chris Barber's open-source Zuzu code for Curl is the Dictionary-of class. My hope is that it will become part of curl9 (aka Curl 8.0)

Friday, December 10, 2010

The Joy Of Smalltalk Debugging

Here is a link to Eliot Miranda on debugging in Smalltalk: Sometimes Smalltalk Is Truly Awesome.
He has authored a new VM which should appear any day now in Squeak 4.2 and which is also suited to Croquet and Pharo. The VM is being released as open-source by Teleplace who are in the collaborative software space.

Curl pragma

Chris Barber's Zuzu Curl testing package is a sort of Curl goldmine.

Here is one snippet:

{getter public inline {size}:int

  {pragma suppress SyntaxRequiresInteger}
  {return {bit-count self.mask}}
  {pragma unsuppress SyntaxRequiresInteger}
}
There is very little documentation on pragmas in Curl other than the documentation page for pragma in the package CURL.LANGUAGE.PRAGMA

Here is a short exerpt:
This syntax allows the developer to specify directives in the source code to affect the behavior of advanced versions of the Curl IDE that support real-time error checking. Pragmas are ignored by the Curl RTE and have no effect on the runtime behavior of Curl programs.
That snippet is followed by the caveat that pragmas are only processed by the Curl plugin for Eclipse
One use that I think terrific is {pragma info|warning|error message}An example would be
{pragma info FIX_THIS really klunky and hard to test}

But how to keep these out of code commits (let there be no TODO in thy code escrow....) ?

hidden Curl

There are a few places where Curl code is documented as for internal use only*.  This will surely not be the case in open source Curl projects.

There are also some examples of the use of hidden as an access modifier such as this docs entry:
GenericIterator (class)

  hidden abstract GenericIterator
  Package: CURL.IO.STREAM
Another curious example is the parent of HVBox.

LengthBreadthBox (class)

  hidden abstract sealed LengthBreadthBox {inherits SequenceBox}
  Package: CURL.GUI.BASE

The documented 'hidden' is that for the hidden-package accessors in PackageNamespace and the field hiidden? in AliasedNameRef (which is itself internal-use only.)What makes this interesting is that SequenceBox is itself visible.
*example from Curl docs:
 seqnum-generator (field)
protected seqnum-generator:{proc-type {}:int}
Class: TableOptionItem
Package: CURL.GUI.BASE
... This item is unsupported and reserved for internal use.

Beautiful Curl

The Curl language can have a strange beauty: consider that when mixing positional and keyword arguments to a method or procedure that the positions of the former need only be in relative order and that duplicate keyword arguments are permitted.

With access to the Curl AST and the power of Curl macros - and the fact that the  Arguments object is still part of Curl - a fascinating avenue opens for unusual programming paradigms.

Just consider the bug-bear of any Prolog which is the fact that the serial order of clauses and facts is critical and drives the need for cut.  But just imagine the kind of quasi-forward-chaining that can be done by parsing Arguments based on relative positions: remember that the keyword arguments can be in any order and can be duplicated.  Not only that, rest arguments can be given a type at compile time such as anonymous func {proc-type} (but in that case ... may not contain keyword arguments.)

My first experiments are simply

  {clausal goal, 1, clause: procC, clause: procB, 2, clause: procA , asserted-working-mem}

where {clausal} is just
{define-proc {goal:{proc-type}, branch:int, leaf:int, ...}(result:bool, depth:int, breadth:int)
Notice that in my example the rest keyword arg clause: is preceding the positional leaf arg!  There is order relied upon - but it is our order in our code-as-data.

But {define-proc} is itself a Curl macro ... which makes implementing logic in Smalltalk look like really hard work in comparison ...

My convention above is (Goal, [guard-clauses],branch,[clauses],leaf,[clauses],WM)

Anonymous Curl functions close-over their context and are first-class, so I do not explicitly return a solution set.  And of course I can pass in a logic procedure.

What is remarkable is to inspect rest arguments and lo-and-behold there are the multiple keyword arguments.  The convention is that a Curl function cascades to take the last of the duplicate keyword arguments - but now we place our own macro in the body of our clausal proc and proceed to evaluate, parse, ...

Immediately someone says 'But look at the performance hit!'  But if your problem is hard and your solution is elegant, performance will not be the issue - better an answer in 90 seconds or 42 minutes than in 90 centuries or more.

The next nay-sayer: 'But we have a C library that does this!'  And the answer is that we needed a dynamic solution responsive to the user's hunches and advice.  And we wanted a useful, debuggable trace, not a trace that now needs to be parsed and even then may not be useful.  And we want it to be more readable than LISP.

My point is only this: I can get this richness out of the macro {define-proc} itself.  And thankfully Curl 7.0 retained its Arguments class - unlike the fate proposed for Arguments in a harmonized ECMAScript5+ as it moves to its rest arguments convention.  To quote as AS3 author
The catch is to remember that the ...(rest) keyword can be defined only after explicit parameters because required parameters must come before optional ones
Now where had we seen that before ...

Inspecting Global Variables in Pharo Smalltalk 1.1.1

I cannot resist posting this: it creates an interable collection of associations of all current global identifiers and their current types:

"A recipe from Squeak wiki at http://wiki.squeak.org/squeak/1824

Smalltalk keys select:
   [:k | ((Smalltalk at: k) isKindOf: Class) not]
     thenCollect:
        [:k | k -> (Smalltalk at: k) class]


"The code is in SystemDictionary's class comment."

Smalltalk implementations and VM's are evolving - but just compare what has to be done today in other dynamic languages to achieve the same ...

One notable exception is the Io Lobby object.  With a little care, the same result can be very succinct in Rebol 2.7.6. and even simpler in Rebol3.

Here is a node.js shell result on startup:
for (var s in process) { s}
'listeners'
In a Pharo One-Click I get an Array of 127 assocs.

Python does have dir(obj) which is hardly a Smalltalk inspection widget ...

in JavaScript there had been access to the Arguments object for a top-level function callee/caller to get into the activation/call object - But what will that kludge's fate be now that ECMAScript5 is here and Mozilla JavaScript 2.0 is coming?

In all fairness, in Smalltalk and Rebol the unwary traditionally can clobber anything.  But in Smalltalk you can inspect almost anything non-primitive - even during startup. And a bootstrapping JavaScript interpreter written in JavaScript achieves almost the same transparency.  See also: The avocado variant of Lively-Kernel.

see: JavaScript Function.call and Function.apply and ECMAScrip5 Function.prototype.bind

node.js REPL

I do like the node.js REPL.
The classic test is to enter 3 > 2 > 1

But consider this
/opt/curl/surge/8/bin/curl --shell
Entering 3 > 2 >1 gives a much better response.

Curl is an expression-based language - can you name another in which 42 > x > 0 evaluates to a success?

But let's stick to curl for now:  enter the string exit
Now that is a respectable result.  Douglas Crockford, applied science is not a popularity contest.

Simulate loosing your bearings for a moment and enter exit()

Are you convinced that JavaScript variables should always use var?  If so, enter
let answ:int = 42
Note the echo behavior is not annoyig.  To see answ enter answ or {value answ}
To change the value of answ, try
{set answ=65565}
So I such an
ln -s /opt/curl/surge/8/bin/curl xcurl
since the folks as curl.com failed to protect Curl from cURL.

And an icurl.sh gets you your rlwrap xcurl --shell

And to exit the REPL
{exit}
When Crockford talks about the origin of JavaScript and the involvement of SUN, he leaves out a few details.  His audience may not need to know about Self or Strongtalk.
But when Crockford lays out the weaknesses of JavaScript prior to ECMAScript5 he neglects to mention Curl.  Just as he neglects to mention Rebol or Io.  But at a GoogleTechTalk?  Were those talks intended to be misleading? Biased?

I do like JavaScript just as I do like Python (for my own needs.)  But Python is wrong for applications which must be tamper-proofed on the server-side.  Python dynamic objects in that regard are scary.  JavaScript is worse.  And Curl is (for now) absent on the server-side.

As for node.js, Curl has offered event loops in closures since forever.  and for generators, see RolledRandom at curl.com

Tuesday, December 7, 2010

The path to BFG: virtualenv bfgenv and _socket PYTHONHOME PYTHONPATH activate

The BFG python web framework folks pride themselves on their testing - but I can't say the same for virtualenv when installed under Windows.  And in this regard, the BFG web documentation is lacking (compared, say, to WebCore.)

First, the point of virtualenv is to be able to maintain a BFG server on a machine with python26 and python27 and python31  as we transition to python32 and beyond.  So they move a copy of some version of python.exe and pythonw.exe into a Scripts folder.  But they neglect to supply the respective python DLL. So copy that from your PYTHONHOME into that new bfgenv/Scripts directory.

The scripts will not work correctly if you do not first clean up your cmd environment by executing the following at that DOS shell prompt:
set PYTHONPATH=
but even then I have found that for my sanity I need to go into the new /bfgenv/Scripts and edit the activate.bat and deactivate.bat files to preserve and restore my %PYTHONPATH% as well %PYTHONHOME%

One symptom that there is a problem is having an install script complain about not finding a module which imports without problem in your 'normal' python environment.  In my case it was _socket

Sadly, I read advice on mail lists to reinstall Python.  "There must be something wrong with your Python install" as you will see by a web search on virtualenv _socket

Here is a set of steps which will work on Windows XP for Python 2.7 if \python27\Scripts is on your PATH
cd \python27
python ez_setup.py            (note: get this python script off the web for SetupTools)
easy_install virtualenv
set PYTHONPATH=
cd \
virtualenv --no-site-packages bfgenv
cd \bfgenv
Scripts\activate
Scripts\easy_install -i http://dist.repoze.org/bfg/current/simple repoze.bfg
cd Scripts
python test_bfg_port_28686.py   (note: this last is your test file - remember to choose a port)

Suppose PYTHONHOME had been conceived as a string such as
"27*c:\python27;31*i:\python312"
then this would not be an issue - so long as PYTHONPATH was not built by subst of %PYTHONHOME% or $PYTHONHOME

But that ship has sailed.

And take care when in \bfgenv to issue the command as
Scripts\activate.bat
because, like me, you may have more than one activate.bat in your path ... I mean, %PATH%.

Here is a 2009 blog post on using virtualenv: Chris Scott

The WebCore pages suggest using pip. And what could be simpler than
pip install CherryPy
PS
Of course, BFG on linux installed and ran like a charm ...
PPS
Check that %PYTHONHOME%\Scripts is on your PATH

Thursday, December 2, 2010

Curl web content on a CherryPy web server

Here are two snippets from a Python CherryPy web server test run:

    def index(self):
        cherrypy.response.headers['Content-Type'] = 'text/vnd.curl'
        return """{curl 7.0 applet}{br}{paragraph Test CherryPy}{br}"""
                   
    index.exposed = True
  
    def home(self):
        cherrypy.response.headers['Content-Type'] = 'text/vnd.curl'
        return """{curl 7.0 applet}{br}{paragraph Curl Test for CherryPy}{br}"""
  
    home.exposed = True

 It is also possible to specify a path to static Curl files and an index to that directory - in which cases files could appear with .CURL extensions.

In the two cases above, the working URL's are
http://localhost:18787/
http://localhost:18787/index
http://localhost:18787/home
and the Curl content displays as intended in linux (Ubuntu maverick) FireFox.

This test run was done using CherryPy 3.1.2 but it would only run on Python 2.6.6 as of today

The test daemon was launched from a local code folder using
sudo python /usr/local/lib/python2.6/dist-packages/cherrypy/cherryd -c ./curl/site.conf
That ./curl web app folder was modelled on the CherryPy3 scaffold folder in their python module distribution (which also includes a working ./tutorial for HTML content.)

Although I was setting a content-type globally for cherrypy.server I found that I still had to flip the MIME type in the individual 'page' methods as you see above in order to send a response with "text/vnd.curl".
Solution: tool decorator

@cherrypy.tools.response_headers([('Content-Type', 'text/vnd.curl')])
def curlHome(self): { // etcetc
//or
class Root:
  @mimetype("text/vnd.curl")
  def someView(self):
// using
def mimetype(type):
    def decorate(func):
        def wrapper(*args, **kwargs):
            cherrypy.response.headers['Content-Type'] = type
            return func(*args, **kwargs)
        return wrapper
    return decorate
// thanks to 
http://stackoverflow.com/users/11549/ddaa