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().
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().
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)
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
====================================
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:
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
I know Borges the author, but not
Borges the library.
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?
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:
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:
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:
I know Borges the author, but not
Borges the library.
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.
I know Borges the author, but not
Borges the library.
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? 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.
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?
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?
It appears I and a few other developers accidentially implemented
continuations without knowing it
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.