Web Page Programming
(With Sybase And JavaScript)

Although graphical web-page design tools are growing ever more capable, they can't approach the power and flexibility of real programs that spit out HTML. Simple though it may be, one of the most powerful combinations is a database, CGI, and Perl on the server, and HTML and JavaScript on the client.

Traditional CGI is slow because it must start up Perl anew for each access of a page. One solution is an enhanced server that contains Perl within it, so that it needn't be restarted for each access. Sybase's Web.Sql is one such tool: .hts files on the server contain Perl in <syb> sections, which contain server-side code to be executed to produce the final output to be passed to the client.

For those tasks best performed on the client (graphical widgets and so forth), JavaScript is the best current solution, as it runs on both Netscape and Internet Explorer (at least, it does if you program very carefully).

This combination of Perl on the server and JavaScript on the client is very powerful, but it makes for complicated web page code, because both are somewhat C like, and the differences from each other cause bugs. I've found the troublesome differences to be:

Specified in HTML by <syb>code</syb> <script>code</script>,
or Perl that writes same
For loopsfor (;;), or foreach (@array) for (;;), or for (x in object)
String concatentationdot (.)+
Array length@arrayarray.length
String equalityeq==
Null reference''null
Variable namesstart with $, @, or % start with letter or _

The problem is that the Perl and JavaScript in a .hts file look similar enough that one can easily confuse their syntax. And Perl is very permissive, so that the wrong syntax often causes buggy code rather than a more easily found and therefore less severe syntax error. For instance, using + instead of . for string concatenation will do an arithmetic addition, which typically results in "0". And using myArray.length by accident instead of the correct @myArray will return 0. An error in the other direction is when one mistakenly uses the JavaScript "for (in)" syntax, thinking that it ought to work like Perl's "foreach (array)" syntax. The JavaScript version enumerates the object properties, rather than its contents, and so does not do what one expects.

I haven't worked with a RDBMS for 15 years, so it was a shock to run up against the many limitations of today's supposedly robust Sybase. Only 16 tables per query, only 256 searchable bytes per record? C'mon! We went from the 2^16 to the 2^32 era a decade ago, now they want me to accept 2^4 and 2^8? Of course, a reasonably designed database can fit in those limits, but it's the principal of the thing. To one accustomed to the lofty excesses of modern software, a table of fixed-length text fields feels like a medieval torture rack.


Flanagan, David; JavaScript: The Definitive Guide, Second Edition, ISBN 1-56592-234-4, O'Reilly & Associates, Inc., 1997. Explicit coverage of the NS and IE variations is commendable, although there are errors. Not in the same class as Programming Perl (below), but it is serviceable, and it may well be the best available for JavaScript.

Gruber, Martin; Understanding SQL, ISBN 0-89588-644-8, Sybex, 1990. For beginners only: verbose, but understandable. Poor as a reference, with spotty coverage of the basics, little explanation of extension differences between competitive products, and nothing on advanced issues. If you have to own just one SQL book, this shouldn't be it, but it's ok as the intro in a set of three or four.

Musciano, Chuck, and Kennedy, Bill; HTML: The Definitive Guide 2nd Edition, ISBN 1-56592-235-2, O'Reilly & Associates, Inc., 1997. Clear and complete. Gonna hafta buy stock in O'Reilly.

Tittel, Ed, et.al.; World Wide Web Programming with HTML & CGI ISBN 1-56884-703-3, IDG books, Programmers Press, 1995. Spotty presentation of SGML just confuses the issue of learning HTML; this is not O'Reilly quality. I should have gotten the O'Reilly CGI book instead.

Wall, Larry, Christiansen, Tom, and Schwartz, Randal L.; Programming Perl, Second Edition, ISBN 1-56592-149-6, O'Reilly & Associates, Inc., 1996. Definitive, lucid, and funny.

Substantive changes:
    1997-12-05: created.
Copyright © 1997, Steve Colwell, All Rights Reserved
Home page