Friday, October 23, 2009

ObjectIcon 2.0 UNICODE ICON programming language

The latest release of ObjectIcon is now at code.google which brings oit and oix up to 2.0

This release built without incident on my Ubuntu box and is running behind some scripts on my shared host site.

I have posted a request to Robert Parlett to comment on what features distinguish 2.0 from 1.4

The ICON language itself remains at 9.4.3

Other ICON variants include OOP UNICON and the more-pythonic Converge with its meta-programming features (Converge implements a complete Compile-Time Meta-Programming facility.)

Ralph Griswold and other ICON originators brought us iterators, generators, associative arrays and an alterntive logic-programming facility (Erlang is another language with a restricted or limited logic programming feature set.)  ICON language features are now common in Python and Ruby but its style of logic as success-or-failure rather than true and false goes far beyond non-zero evaluating to a Boolean value as found in many other programming languages.  ICON is an expression-based language (other such languages include Curl and REBOL) which leads to idioms unlike those typical of procedural languages working with a command/statement paradigm in which expression evaluation is secondary.  ICON is nonetheless procedural: each program begins with
   procedure main()

ICON and its follow-on variants are arguably the most neglected languages which were ever aimed to interest non-programmers.  

Saturday, October 17, 2009

4 Windows Browsers

I use Opera 10, Safari or Chrome or IE8 or Prism when I am not in a browser from those I am working on at aule-browsers.com

Opera has the smallest footprint at startup on my XP box ( I use Epiphany on linux) and I stopped using Firefox when it began to choke and bloat on my large set of bookmarks.  Opera behaves well on a few sites where IE8 misbehaves and vice-versa.  When all else fails I turn to Chrome or Safari (Opera is also the only one that passes w3c Acid3 on this box - but Safari does warm the room with its updates.)

Here are 4 other Windows browsers that you might want to consider:

Avant at http://www.avantbrowser.com/

TheWorld at http://www.ioage.com/en/index.htm

Wyzo 3 at http://www.wyzo.com/

SlimBrowser at http://www.flashpeak.com/sbrowser/

The latter offers to build your site-specific browser, so I will be happy to submit a competitive bid if that is your need!

Concept Application Server

While looking at alternatives to Jetty and Geronimo with Jetty, I chanced upon the Concept Application Server.  I will make an effort not to take the wrong tone.

A few tips: they offer the server and the client.  Take the server. It comes with the client and you want them co-installed or no end of test scripts break (expect paths to be hard-coded and they will be the physical paths.)

The web site is in English but is in need of work.  If you find the help CHM file, you will find that it even more in need of help.

The server and client are said to be RC (release candidates) but their own simplest examples crash the client on my XP desktop.  Those examples were a mix of broken English and garish odd dialogs with senseless layout or radiobuttons which are not etc. etc.  They say their current focus of effort is on their IDE, which I have not seen (it will not run.)

The choice of the name 'Concept' is so regrettable.  It is the name of their alternative programming language. The architecture is something like client server for the web: applications reside on the server but execute in a client.  So how to see this in action?

The server bin has options to install as an NT service.  Once that is done, you can try
     concept://localhost/Samples/test.con
in your browser.

You may do better than I did in Opera and IE 8 on XP if you are running Vista or Seven.

What was sad to see was the immense install: the server arrives with an immense pile of DLL's.  The download was very slow in my case (they may be serving the file themselves) and I had already waited for the Client (my mistake, I guess.)

It remains unclear why anyone would adopt the Concept programming language unless they believe that programmers are what is needed: this looks like life without the web designers.  But they also appear to be without UI designers.  Perhaps they have an alternative to HTTP, but I cannot see it after a few hours.

Their blog has seen no addition in the past year (last entry Oct 2008) but it is tell-tale, quote
The Linux distribution is now up-to-date (or almost up-to-date).

The worst is the commendation from a Romanian academic: the author of Concept is working to write the demo chat program in less that 1 minute - indeed, he will soon be able to write those few lines of code in less than 30 sec's.  This feat may impress some CIO somewhere.  And the team is brilliant and the team is dedicated.  But a former president's wife was an all-but illiterate peasant who was awarded a PhD and headed chemical research.  This is Romania.  Not Montenegro, but still, caveat emptor.  I follow a promising project in Sofia, Bulgaria.  But things are not always what they seem in countries where for years saying made it so.  Even in academic life.

If this server and client are 'release candidates' then I might also be the pope.

And if the documentation were not a big enough concern, I cannot find a test framework.  A search in the CHM reveals an assert but no hint of Test, UnitTest, Builder, Factory.

The one large coding effort, GyroGears, is included in compiled form as is the PDFViewer.  And this is open-source of some sort.  The SOAP code that I looked at had no header for copyright or copy-left.  A submarine patent nightmare, I assume.

The author's one PDF tells us that Concept is faster than Python.  Which Python?  Faster than PHP.  Bare-bones open-source PHP?  And why with Scala available, would we choose this form of DLL-hell on a Windows platform?  And if so much like PHP in practice, why not opt for haXe?

Concept most often means "abstraction", an important CS notion.  But today that means such things as the use of interfaces in the implementation of inversion of control.  Patterns.  Web containers.  Geronimo.  But what I find here is very unclear:  the two documents offered are unencumbered by references.

At first I thought that Concept was like client-side Curl (http://www.curl.com/ and not haxx.se cURL) but shifted to the server-side with a focus on the delegate pattern.  There is talk of an interface builder, but I see no sign of it yet in the code.  I may dig a bit more, but the game appears not to be worth the candle.

For developers most at home with GTk, this may be of interest for a project in Romania with funding for 'made in Romania' systems.  Perhaps someone at LtU would take a look at the merits of Concept as a programming language and the use of delegates in the CAS framework.  Maybe someone can see more clearly which architectural challenges are being addressed and how to judge how effectively.  Maybe this is a place for a cyclic dependency metric to be applied.  Perhaps there is some research published in Romania or some tangible data on the one HR system which has been implemented (gone into production?) in CAS or using their GyroGears.

Someone may be unkind enough to notice the file extension; perhaps another unfortuate choice.  What I suspect, is that CAS is a project solving a non-problem or another problem: the focus is on keeping the software on the server to prevent piracy and preclude updates while being performant to reduce server load.  But the trips to the database are the usual issue, and I see nothing to address that in what I can tease out of the code and the limited docs.

Thursday, October 15, 2009

curlgen with Groovy BuilderSupport: CurlBuilder for Curl web content markup

Because the Groovy MarkupBuilder has a private method which hardcodes the markup delimiters, a CurlBuilder must extend BuilderSupport just as does MarkupBuilder itself.

What follows looks to be roughly a builder candidate for Curl web content markup using "{" and "}" as the delimiters.  As with XHTML, the Curl content may require a 'prolog' and a few non-hierarchical items comparable to the !DOCTYPE of XML.  Web markup is often more than simply a hierarchy of nested nodes.
/**
* A helper class for creating Curl markup
* borrowed from http://docs.codehaus.org/display/GROOVY/Make+a+builder
* original MarkupBuilder by James Strathan
* mods by RS
*/
public class CurlBuilder extends BuilderSupport {

private IndentPrinter out;
private boolean nospace;
private int state;
private boolean nodeIsEmpty = true;

public CurlBuilder() {
  this(new IndentPrinter());
}

public CurlBuilder(PrintWriter writer) {
  this(new IndentPrinter(writer));
}

public CurlBuilder(Writer writer) {
  this(new IndentPrinter(new PrintWriter(writer)));
}

public CurlBuilder(IndentPrinter out) {
  this.out = out;
}

protected void setParent(Object parent, Object child) {
}

protected Object createNode(Object name) {
  toState(1, name);
  return name;
}

protected Object createNode(Object name, Object value) {
  toState(2, name);
// out.print(">");
  out.print(value.toString());
  return name;
}

protected Object createNode(Object name, Map attributes, Object value) {
  toState(1, name);
  for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
    Map.Entry entry = (Map.Entry) iter.next();
    out.print(" ");
    print(transformName(entry.getKey().toString()));
    out.print("='");
    print(transformValue(entry.getValue().toString()));
    out.print("'");
  }
  if (value != null)
  {
    nodeIsEmpty = false;
    out.print(" " + value + "}");
  }
  return name;
}

protected Object createNode(Object name, Map attributes) {
  return createNode(name, attributes, null);
}

protected void nodeCompleted(Object parent, Object node) {
  toState(3, node);
  out.flush();
}

protected void print(Object node) {
  out.print(node == null ? "null" : node.toString());
}

protected Object getName(String methodName) {
  return super.getName(transformName(methodName));
}

protected String transformName(String name) {
  if (name.startsWith("_")) name = name.substring(1);
    return name.replace('_', '-');
}

protected String transformValue(String value) {
  return value.replaceAll("\\'", """); }

protected void toState(int next, Object name) {
  switch (state) {
    case 0:
      switch (next) {
        case 1:
        case 2:
          out.print("{");
          print(name);
          break;
        case 3:
         throw new Error();
      }
      break;
    case 1:
      switch (next) {
        case 1:
        case 2:
          out.print(" ");
          if (nospace) {
            nospace = false;
          } else {
            out.println();
            out.incrementIndent();
            out.printIndent();
          }
          out.print("{");
          print(name);
          break;
        case 3:
          if (nodeIsEmpty) {
            out.print(" }");
          }
          break;
        }
        break;
      case 2:
        switch (next) {
          case 1:
          case 2:
            throw new Error();
          case 3:
            out.print(" }");
            break;
        }
        break;
      case 3:
        switch (next) {
          case 1:
          case 2:
            if (nospace) {
              nospace = false;
            } else {
              out.println();
              out.printIndent();
            }
            out.print("{");
            print(name);
            break;
          case 3:
            if (nospace) {
              nospace = false;
            } else {
              out.println();
              out.decrementIndent();
              out.printIndent();
            }
            out.print(" }");
            break;
        }
        break;
     }
     state = next;
   }
}
That could have been so elegant if the MarkupBuilder class had understood markup itself as a pattern rather than hard-coding the SGML-style tag delimiters and assuming the tagging style (close before content, reopen after content.)

The ability to inject a markup builder for non-SGML markup for an entire site is lost: we still have to look into such things as 404 and 500 errors because we have only covered where we explicitly instantiate a builder.  DI should have solved that web container-wide.

As I never tire of saying, when we get beyond HTML5 and the mere browser, this SGML-bias will look like an unquestioned assumption as curious as any other in the history of data format oddities and over-sights.

To get from   <br/>  to {br} should not be a coding intervention task of this magnitude or this nature.

Wednesday, October 14, 2009

curlgen with Ruby Rails: Mime::Type.register and response.rb

I took some time today to try to see what is happening with default MIME content_type over at lighthouseapp.com

But I am still at sea ...

In the meantime, the Rails code states that we must not use the Response class itself. So what to do if you want to change a default MIME type across a site. For example, the default in the Mailer is 'text/plain'. And in the Response class there is a method

   def assign_default_content_type_and_charset!
      self.content_type ||= Mime::HTML

which is immediately called by

  def prepare!
    assign_default_content_type_and_charset!
    handle_conditional_get!
    set_content_length!

The first thing was to track down the Mime module in action_controller where you can see that your type may be missing (mine was.)

So now I might start the effort to convert to non-HTML web content as site output with

    Mime::Type.register "text/vnd.curl", :curl

The Mime module has a class Type (yes, I know, but so it is) and that has a static
   @@html_types = Set.new [:html, :all]
Note that it is not
  @@markup_types

Of course, it might be easier just to go into the Response class and have it set its default to the Mime::Type class static default.

But should it really be necessary to repair and modify these classes to achieve something so obvious as the default MIME Content-Type for an HTTP web framework?

That's where the hope lies with Rails 3.  But Rails 3 will be a marriage with merb and there will have to be compromises. But we should be able to hope that hard-coding the MIME defaults will be a thing of the past.

Of course for individual controllers you can go piecemeal with

  class MyApplicationController < ActionController::Base



    before_filter :set_content_type
    def set_content_type
     @headers["Content-Type"] = "text/vnd.curl; charset=utf-8"
    end
  end
 
but then you are faced with tracking down just how much of ApplicationController you must override. For example,
 
  def record_not_found
    render :text => "404 Not Found", :status => 404
  end
 
must become something like
 
  def record_not_found
    render :text => myApp.msg_404, :content_type => 'text/vnd.curl' :status => 404
  end

If you are aware of how Rails on ruby 1.8.6 can globally alter the Response content_type, please add a comment.  I don't see the answer over in the Rack module where you will find hard-coded

      @header = Utils::HeaderHash.new({"Content-Type" => "text/html"}.merge(header))

Oops.

Tuesday, October 13, 2009

curlgen using Scala Lift. Not. Or: XML considered harmful

The other day I was looking at a modest web framework's HtmlTag class and saw that it had a parent class: ComponentTag.  Fine; I'll subclass CurlTag from that parent. Not. The parent of ComponentTag was none other than XmlTag.  What made this almost funny is that this framework claims to spare you XML configuration pain.

Imagine if the authors of the first unix shell had required that scripts be written in COBOL.  COBOL was ubiquitous in business systems at that time.  And then just imagine some key, patented component, say, suid, somehow required that a hidden .conf  file parse correctly as COBOL ...

So here I find myself today re-visiting Lift, the web framework stalwartly bearing the Scala standard onto the field of software slaughter.

The author of the Scala 2.7.6 compatible Lift 1.0.1 web framework has admitted that to set a non-XML MIME Content-Type for a Lift app that you must manually re-code Boot.scala in your app.

Imagine.  Here is a framework where convention has triumphed over configuration.  Run a few maven tasks and all is installed and one more maven task and you are up and running.  So long as anything you output as web content has an HTTP response payload starting with

    ?xml version=
and then
   !DOCTYPE html

Even with the content type manually flipped in Boot.scala ( and that is not as obvious as the web posts and sanguine responses might lead you to believe) the XmlParser is invoked.  Oh vey. LiftRules.determineContentType must be called after this and before that ...

Perhaps when Martin Odersky wisely included Traits (from the Swiss Smalltalk team up the road from Laussane in Berne) it became debatable whether IoC containers would require implementaion using Dependency Injection.  But here I am, reaching into the bowels of Scala Lift, just to flip a MIME type and free myself of an enforced XML parse.  All this just to output a page of non-XML, non-HTML, non-XHTML and yet not mere text/plain web content.  When did all internet markup become trapped in angle brackets?

The GOF warned that the Hollywood Principle can make for software which is dificult to understand.  Imagine the starving actor.  Even in Kafka's world the anti-hero could petition to change, if not improve, his lot.  But we who might serve must now sit and wait in the hope that we might be called.  It has been said that IoC prevents spaghetti code at the price of macaroni code.  We were promised a platter with a few of these and a little of those.  All at the openly shared feast freely offered in the marketplace.  But not without risk of something indigestible in the stuffing.

There must be room for some measure of configuration in this mad rush to impress the CIO's with the trivial app that hints at a killer app.  RAILS is not a killer app.  Emulating RAILS is folly.  Software - and with no effort at all. Imagine.  Less effort than learning to unicycle.  But you won't touch that page without a Ruby programmer at your elbow.  Call it "peer-web-dev".  The Rubyist will be peering over your shoulder.

There are supposedly highly-principled reasons to prefer Lift to RAILS (though perhaps not to GRAILS) and, in fairness, perhaps Lift version 1.1.x will break this fond coupling with XML and XHTML.  But if Lift was to be an indication of the advantages of the Scala IT shop over the Java-only shop and C#-only shop then Scala has surely not found its "killer framework" in Lift.

My Kafka-esque nightmare: a revival of Hermes, from IBM, in the Aufhebung above and beyond the split of OS from application process - the messenge has almost arrived! - only we find that PlanK only installs in our wristwatch ant-gravity gadget if Maven was first installed ... POM-da-da-POM.

Monday, October 12, 2009

curlgen using Rebol QuarterMaster

Over at aule-browser.com I have the 3.11 version of Rebol QuarterMaster generating some Curl web content.

Two minor changes were required to tweak the qm.r source for the Content-Type to be "text/vnd.curl" and to share Apache with other web frameworks.  As with Django, you will need the final forward slash on the URL paths such as /qm/ or /macros/.

The QuarterMaster file structure is quite plain by the time you are 2 levels deep and it lies outside my web container. The lower level is the expected ./controllers and ./models and ./views that you would expect with a web-style MVC framework.  Compared to Django on the same host, there was minimal configuration required.

The Curl code that you see at aule-browser.com/qm/ resides in an RSP file within the views/pages folder which reflects this QM install being configured to use a pages controller.  That code resides in ./controllers/pages.r and is simply:
REBOL [   title: "Pages Controller"
  type: 'controller
  default: "index"
]
action "index" does [
    render %welcome.rsp]
If you are not familiar with Rebol, it is (among other uses) the scripting language of the Syllable operating system and is currently in alpha-88 and moving towards a beta for version 3.0 at http://www.rebol.net/

Like ICON and Curl, Rebol is a reflective expression-based object language but without ICON's keywords.
While recently ObjectIcon has brought a ICON dialect up to UNICODE, Rebol will be UNICODE with version 3.0 and will have modular facilities suited to PITL.  Curl, of course, has had both since its inception almost a decade ago.

Rebol3 will see various extensions to parse which is how Rebol scans a string or series datatype.  And like ICON, Rebol has many data types: I count 58 at this point of the Rebol3 alpha.  In Rebol, the values have the data types and an effort has been made to provide useful types for web development, such as tag! and url!

When Rebol3 goes to beta, the author of QuarterMaster can be expected to release a new version.

When all was said and done, less effort was required to get QuarterMaster generating Curl than was required to get the same result from Django at www.aule-browser/macros/ (which is intended eventually to showcase Curl macros).

If you would like to try QuarterMaster on a localhost, I would sugggest either Jetty or the Cheyenne Rebol server. I should note that Syllable Server's documentation states that it includes the "QuarterMaster web application framework, configured to run on Cheyenne." and, at a glance, I would guess that http://www.syllable.org/ is itself running on QuarterMaster.