Random idea: Procedural CGI?

I’ve been musing about something today,
and I’ve decided that one thing making
CGI tedious is the fact that it’s rather
non-procedural (and not in an OO way).

By that I mean you’re sort of creating
a state machine by hand every time…
what if your CGI could "stay alive"
after being invoked and communicate
with the web server (by sockets or
something)?

That is, I’d like it if I could write
something like:

Display a form and get the data back

results = myform.display()
if results.name == ""
results = myform.display(“Name required”)
else
# Process…
end

Horribly crude example, but do you see
where I’m going?

I’d like CGI to be nearer the simplicity
of old-fashioned gets() and puts().

Thoughts??

Release the hounds!

Hal

Check out the Squeak version of Iowa, Seaside.

···

— “Hal E. Fulton” hal9000@hypermetrics.com wrote:

I’ve been musing about something today,
and I’ve decided that one thing making
CGI tedious is the fact that it’s rather
non-procedural (and not in an OO way).

By that I mean you’re sort of creating
a state machine by hand every time…
what if your CGI could “stay alive”
after being invoked and communicate
with the web server (by sockets or
something)?

That is, I’d like it if I could write
something like:

Display a form and get the data back

results = myform.display()
if results.name == “”
results = myform.display(“Name required”)
else
# Process…
end

Horribly crude example, but do you see
where I’m going?

I’d like CGI to be nearer the simplicity
of old-fashioned gets() and puts().

Thoughts??

Release the hounds!

Hal


Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

[snip]

By that I mean you’re sort of creating
a state machine by hand every time…
what if your CGI could “stay alive”
after being invoked and communicate
with the web server (by sockets or
something)?

doesn’t FastCGI make this possible (asking)?

in general, i think really good web libs would help Ruby grow.

two things i’ve worked on lately (these all work - no vapourware)

  • HTML::Widget

    eg
    table = HTML::Table.new

    table << [0,1,2] << [3,4,5

    table.attributes[‘width’] = ‘100%’
    table[0].attributes[‘bgcolor’] = ‘0x0f0f0f’

    puts table.to_html

    or better still

    table = db.query sql # assume this is a LARGE result set

    table.extend HTML::TableMethods # no extra constructors!

    puts table.to_html

  • CGI::Session::PStoreStore

    session = CGI::Session.new cgi

    session[‘table’] = table

i have working example of both ideas. my thoughts are that nifty
HTML::Widgets which could be stored between sessions could lead to swift
development of complex html guis. what i need is a wasy to automatically have
the query string update said widgets, eg state… or something. bascially a
layer over CGI::Session which would allow a ‘web event loop’

if any one is interested in the above… let me know.

-ara

···

On Sat, 9 Nov 2002, Hal E. Fulton wrote:

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

[… procedural CGI example elided …]

Hal, too bad you couldn’t make the Ruby Conference. Avi Bryant
presented a very similar example based on the Borges (spelling?)
library. His example was a console app using “ask” and “display”
methods to prompt and get data. By changing two lines in the file (the
require line and the call to “main”), he was able to convert the example
from a console app to a web app. Very cool.

The really interesting part is how he supports the back button in web
browsers. Essentially this requires backing up the procedural program
to an earlier state … which is a perfect use for continuations.

I see another response to your request mentioned the squeak verion of
Iowa (which is also by Avi). Is the squeak version similar to Borges?

···

On Fri, 2002-11-08 at 21:56, Hal E. Fulton wrote:

That is, I’d like it if I could write
something like:


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

I've been musing about something today,
and I've decided that one thing making
CGI tedious is the fact that it's rather
non-procedural (and not in an OO way).

...

That is, I'd like it if I could write
something like:

  # Display a form and get the data back
  results = myform.display()
  if results.name == ""
    results = myform.display("Name required")
  else
    # Process...
  end

See discussion "CGI sessions as threads?" from 6th October, in particular
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/52624

I am looking forward to seeing Avi's code :slight_smile:

Regards,

Brian.

···

On Sat, Nov 09, 2002 at 11:56:36AM +0900, Hal E. Fulton wrote:

I’d like to know more about these.

I know Borges the author, but not
Borges the library. :slight_smile:

Is Borges in Ruby? Or was Avi mimicking
its behavior in Ruby?

And yes, how does the Squeak version of
Iowa relate to this (and to the Ruby
Iowa)?

Time to do some surfing…

Hal

···

----- Original Message -----
From: “Jim Weirich” jweirich@one.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, November 09, 2002 12:24 AM
Subject: Re: Random idea: Procedural CGI??

On Fri, 2002-11-08 at 21:56, Hal E. Fulton wrote:

That is, I’d like it if I could write
something like:

[… procedural CGI example elided …]

Hal, too bad you couldn’t make the Ruby Conference. Avi Bryant
presented a very similar example based on the Borges (spelling?)
library. His example was a console app using “ask” and “display”
methods to prompt and get data. By changing two lines in the file (the
require line and the call to “main”), he was able to convert the example
from a console app to a web app. Very cool.

The really interesting part is how he supports the back button in web
browsers. Essentially this requires backing up the procedural program
to an earlier state … which is a perfect use for continuations.

I see another response to your request mentioned the squeak verion of
Iowa (which is also by Avi). Is the squeak version similar to Borges?

I’ve posted the code I used for RubyConf at

Unfortunately this is purely demo code - it’s not a framework people can
go out and use yet. I’d love to be able to flesh this out as fully in
Ruby as I have in Smalltalk, but I suspect that’ll require someone else
with either a) time to do it themselves or b) sufficient commercial
interest to hire Julian or me to do it for them.

Anyone who is interested in doing something with this code - please
consult with me first. I’ve spent the last year working out
the gotchas and tradeoffs inherent in this approach, and I’d hate to see
wheels reinvented.

From the README:

···

On Sun, 10 Nov 2002 05:39:49 -0800, Brian Candler wrote:

See discussion “CGI sessions as threads?” from 6th October, in
particular
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/52624

I am looking forward to seeing Avi’s code :slight_smile:


This directory contains source code and slides from my RubyConf
presentation “The Garden of Forking Paths”.

It requires WEBrick to run.

The code in borges/ is a simple demo port of some of the functionality of
the Seaside 2.0 framework in Squeak Smalltalk. For more information, see
beta4.com .

The garden/ directory contains some slides, notes, and sample code from
the talk. To try out the sample code:

cd garden
ruby train.rb
netscape http://localhost:7000/borges/book

This code is presented as is - it is far from complete, and is not yet
useful for deployment or even real development. It is my hope, however,
that this will encourage work on a full port of the Seaside framework to
Ruby.

Those who are interested will likely be greatly helped by the Seaside 2.0
documentation. Currently implemented features in Ruby include:

  • the respond() primitive
  • the HTMLRenderer
  • a basic Page class with call/answer

Notably missing features include:

  • proper embedding of pages
  • automatic state rollback
  • auto-redirection
  • transactions

Cheers,
Avi

[…]

I see another response to your request mentioned the squeak
verion of Iowa (which is also by Avi). Is the squeak version
similar to Borges?

I’d like to know more about these.

I know Borges the author, but not Borges the library. :slight_smile:

Is Borges in Ruby? Or was Avi mimicking its behavior in Ruby?

And yes, how does the Squeak version of Iowa relate to this (and
to the Ruby Iowa)?

Time to do some surfing…

Borges is Seaside v2; Seaside is the Squeak version of Iowa.

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.11.09 at 09.27.46

···

On Sat, 9 Nov 2002 16:39:24 +0900, Hal E. Fulton wrote:

“Hal E. Fulton” hal9000@hypermetrics.com writes:

I’d like to know more about these.

I know Borges the author, but not
Borges the library. :slight_smile:

Is Borges in Ruby? Or was Avi mimicking
its behavior in Ruby?

And yes, how does the Squeak version of
Iowa relate to this (and to the Ruby
Iowa)?

Time to do some surfing…

See Seaside (beta4.com). That’s Avi’s Squeak project.

Jim

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“Any sufficiently advanced technology is indistinguishable from a Perl
script.” – Programming Perl, 2nd edition

The functionality that Avi was demonstrating at the Ruby conference
(partially) depended upon continuations. Does Squeak have
continuations, or is it done in a different manner in the Squeak
version?

···

On Sat, 2002-11-09 at 09:29, Austin Ziegler wrote:

Borges is Seaside v2; Seaside is the Squeak version of Iowa.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

Jim Menard wrote:

“Hal E. Fulton” writes:

I’d like to know more about these.

I know Borges the author, but not
Borges the library. :slight_smile:

Is Borges in Ruby? Or was Avi mimicking
its behavior in Ruby?

And yes, how does the Squeak version of
Iowa relate to this (and to the Ruby
Iowa)?

Time to do some surfing…

See Seaside (beta4.com). That’s Avi’s Squeak project.

Jim

Hehe… just got back from OOPSLA to find this thread. Just to clear
all this up… Avi wrote Iowa in Ruby (as well as other experiments in
Java and Scheme) a couple of years ago. After that he and I ported it
to Squeak and it became known as Seaside (part of our Squeak Enterprise
Aubergines -get the pun anyone? :slight_smile: We were pretty happy with that but
have been working on a new, completely rewritten version that we
released several weeks ago.

The rewritten version has a much more layered architecture and the core
layer of Seaside 2 was code-named Borges (see the quote on the seaside 2
home page and hopefully you’ll understand why).

A small amount of Borges has been back-ported to Ruby at the moment and
I think that’s what Avi used in his demo at RubyConf. There’s plenty
more to be ported and a few people have expressed interest in working on
that but as for time frame, I have no idea.

Seaside/Borges absolutely need continuations and we do use them in
Squeak (though we had to implement call/cc semantics). It should also
be portable to VisualWorks (in progress) and Dolphin. VisualAge and
SmalltalkX are problematic at the moment because of the way their VMs
are implemented.

Seaside is designed to provide exactly what Hal was asking for. You
write your code completely linearly. You can even use call/return
semantics to display a “dialog” that requests info from the user for
example. And yes, the back button does work… if you go back and then
go forward on a different path it will continue working just fine (thus
the quote again). You also implement “components” and “views” which are
self contained, reusable, widgets that can be displayed and embedded in
other pages.

If you want more info, check out the webpage at
beta4.com or email either myself or Avi. The
webpage also has a link to the seaside mailing list which is an
excellent place to ask questions. If you want to play with the old
version of IOWA you can grab it at beta4.com.

Julian

···


julian@beta4.com
Beta4 Productions (http://www.beta4.com)

Nevermind … I answered my own questions. From the design
documentation at http://beta4.com/seaside2/borges.html,

Seaside handles this transparently by leveraging first class
continuations, a powerful language construct most commonly
associated with the Scheme language […]

I hadn’t realized Squeak supported continuations. Cool!

···

On Sat, 2002-11-09 at 17:20, Jim Weirich wrote:

On Sat, 2002-11-09 at 09:29, Austin Ziegler wrote:

Borges is Seaside v2; Seaside is the Squeak version of Iowa.

The functionality that Avi was demonstrating at the Ruby conference
(partially) depended upon continuations. Does Squeak have
continuations, or is it done in a different manner in the Squeak
version?


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

I don’t know; I’m not really sure what a continuation is (before
this past year, I didn’t know what a ‘closure’ was – I’m still not
100% sure, but apparently I’ve been using them if I understand
them), but I suspect that it does – Squeak is a Smalltalk
implementation.

-austin, not a Smalltalker, will learn Squeak, but will probably
remain “not a Smalltalker”
– Austin Ziegler, austin@halostatue.ca on 2002.11.10 at 00.11.55

···

On Sun, 10 Nov 2002 07:20:22 +0900, Jim Weirich wrote:

On Sat, 2002-11-09 at 09:29, Austin Ziegler wrote:

Borges is Seaside v2; Seaside is the Squeak version of Iowa.
The functionality that Avi was demonstrating at the Ruby
conference (partially) depended upon continuations. Does Squeak
have continuations, or is it done in a different manner in the
Squeak version?

Hi,

···

In message “Re: Random idea: Procedural CGI??” on 02/11/10, Jim Weirich jweirich@one.net writes:

I hadn’t realized Squeak supported continuations. Cool!

Actually they invented continuation.

						matz.

Huh? Really? I thought continuations came out of Scheme.

A little google searching seems to indicate that Avi implemented
continuations in Squeak himself in about 8 or 9 lines of code. See

http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/msg01373.html
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos

Interesting.

···

In message “Re: Random idea: Procedural CGI??” > on 02/11/10, Jim Weirich jweirich@one.net writes:

I hadn’t realized Squeak supported continuations. Cool!

On Sat, 2002-11-09 at 22:44, Yukihiro Matsumoto wrote:

Actually they invented continuation.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

“Jim Weirich” jweirich@one.net wrote in message
news:1036916775.825.49.camel@traken…

In message “Re: Random idea: Procedural CGI??”

A little google searching seems to indicate that Avi implemented
continuations in Squeak himself in about 8 or 9 lines of code. See

http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/msg01373.html
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos

Interesting.

It appears I and a few other developers accidentially implemented
continuations without knowing it :slight_smile:
We had this problem with a scripting language used to execute interviews
(surveys). But sometimes you need to go back in order to a change a previous
answer. The logic was implemented by copying the interpreter stack. We also
worked with more refined ways where you do not copy unless values change and
more crude versions of rerunning the entire logic from start.

Mikkel

Hi,

···

In message “Re: Random idea: Procedural CGI??” on 02/11/10, Jim Weirich jweirich@one.net writes:

I hadn’t realized Squeak supported continuations. Cool!

On Sat, 2002-11-09 at 22:44, Yukihiro Matsumoto wrote:

Actually they invented continuation.

Huh? Really? I thought continuations came out of Scheme.

Oops, I was wrong. Sorry. I somehow screwed up Squeak and Scheme.

						matz.