Subscribe, It's Free
Link To Us!
We continue to push the Web, script big projects, and keep an eye on professional conferences. This installment of Regular Expressions elaborates themes that Cameron Laird and Kathryn Soraiz have ben discussing over the past few months. (1,100 words)
|By Cameron Laird and Kathryn Soraiz|
Scheme is indeed a very pleasant and intellectually sound programming environment that has made several previous appearances in Regular Expressions. Kleberg buttresses his case with a reference to Matthew Flatt's dissertation (for a reference, see the Resources section, below).
Other languages combining object orientation and a lightweight approach include Squeak, SmallEiffel (which are scripting implementations of Smalltalk and Eiffel, respectively), and Dylan. All three combine considerable aesthetic appeal and good-to-great performance.
However, those languages don't include libraries that support current technologies of broad interest (e.g., the Web, graphical toolkits, email protocols, and XML) the way some other languages do. We're always pleased when readers help us balance the attention we give to both specialized and more mass-market topics.
Three ways to push Web data
The previous installment of Regular Expressions launched a series on coding push for the Web. We generally avoid writing about HTML source, but because (to our knowledge) no one has introduced push in a unified way, we decided to offer it from our usual scripting vantage point.
The three significant mechanisms for achieving push-style communications are:
We showed how to code the first two in the earlier column, although we neglected to mention browser fragility. If you're relying on REFRESH, for example, it's important to test your configuration early in the development process to make sure that memory leaks in your browsers won't prevent you from reaching project goals.
The three display styles for Web push data are whole screen, framed updates, and hidden variables. This column explains the first two of these styles.
Pushing a whole screen isn't good enough
The easiest way to update a screen is to build the display you want on the server and show it as a single URL. This is often unsatisfying with push. Monitors such as stock tickers, medical readouts, and aviation displays combine invariant elements (a list of securities of interest, say, or a layout of flight characteristics) with time-dependent ones (the price of AT&T; right now or a current altitude). Rebuilding an entire display that differs from a previous one is both an inelegant waste of bandwidth and highly unsatisfying to viewers. Having the entire browser blank out while it receives a new image is terminally distracting for most applications.
In some applications, discontinuous visuals don't matter, and it's valuable to practice with whole-screen displays to validate other components in a particular design. However, essentially all browsers that properly support any style of push communication also support HTML frames. Most push applications you deliver will be framed.
Framing your work
All three display styles can be used with the three communications methods. A simple example of a framed
REFRESH can be made
<URL:http://DEMONSTRATION/frame.html>, implemented as
these three source files:
frame.html: <HTML> <HEAD> <TITLE>simple framed push</TITLE>
<FRAMESET ROWS="*,*"> <FRAME SRC = "frame1.html"> <FRAME SRC = "cgi-bin/refresh"> </FRAMESET>
frame1.html: Notice that the lower frame is keeping time.
echo "Content-Type: text/html "
echo "<HTML> <HEAD> <meta http-equiv='refresh' content='1;url=/cgi-bin/refresh'> </HEAD> <BODY> `date` </BODY> </HTML>"
While most browsers exhibit a little jerkiness with that display, it's much easier to accommodate than an unframed refresh. One variant that models many common circumstances is a display of a log file (that is, a text with periodic append operations). A simple demonstration can be built at
<URL:http://DEMONSTRATION/frame_log.html> from these sources:
frame_log.html: <HTML> <HEAD> <TITLE>file-display push</TITLE>
<FRAMESET ROWS="*,*"> <FRAME SRC = "log_caption.html"> < </HTML>
log_caption.html: Notice what happens as the file fills up.
echo "Content-Type: text/plain "
echo "<HTML> <HEAD> <meta http-equiv='refresh' content='1;url=/cgi-bin/show_log'> </HEAD> <BODY> `sed -e 's/$/
/' /tmp/log` </BODY> </HTML>"
fill: while true do uptime >> /tmp/log sleep 3 done
Create a zero-length
/tmp/log and launch your browser.
Then, on the Web server, launch the
fill process. That
sort of idea can be quite useful if you want a quick way to show
someone the contents of a file without giving a login.
The problem with the example becomes apparent as soon as the lower
frame fills: scrolling isn't smooth. Someone with a Unix mentality would quickly
fix this by changing the display line in
`tail -10 /tmp/log | sed -e 's/$/<BR>/'`
That won't satisfy end users for long, though, so the question becomes: is smooth scrolling possible?
rough_scroll.html: <HTML> <HEAD> <TITLE>push with primitive scrolling</TITLE>
<FRAMESET ROWS="*,*"> <FRAME SRC = "log_caption.html"> <FRAME SRC = "cgi-bin/show_scrolled_log"> </FRAMESET>
echo "Content-Type: text/html "
echo "<HTML> <HEAD> <TITLE>title</TITLE>
<meta http-equiv='refresh' content='5;url=/cgi-bin/show_log'> </HEAD> <BODY onLoad = 'scroll(0,10000)'> `sed -e 's/$/
/' /tmp/log` </BODY> </HTML>"
Notice the primitive scrolling visual effect as
Still to come
We can do even better. We're still sending too much redundant information through constrained bandwidth and an uninformed rendering engine. Next month we'll extend our examples with hidden push variables and Java networking. Also, look forward to reports from the winter Tcl, PHP, and Python conferences. To warm up to the latter, we've provided a page in the Resources section below that points to notes from the Eighth International Python Conference.
About the author
Cameron Laird and Kathryn Soraiz manage Phaseit, their own software consultancy, near Houston.
Advertisement: Support SunWorld, click here!
|Resources and Related Links|
|Tell Us What You Thought of This Story|
If you have technical problems with this magazine, contact firstname.lastname@example.org
Last modified: Monday, October 02, 2000