BYTE.com > Tangled in the Threads > 2002 > February
What Is General-Purpose Scripting?
By Jon Udell
February 18, 2002
(What Is General-Purpose Scripting?
: Page 1 of 1 )
Language and environment are the two axes of debate. Someday we may be able
to separate these issues, but probably not anytime soon.
A friend wrote recently to ask my thoughts on [ECMA|Java|J]Script (which
I will now, out of habit, refer to as JavaScript) as a general-purpose scripting
language. He teaches software engineering courses and would like
to use Python but, he says, there's pushback because people seem to long
for a syntax like that of C or Java. Coincidentally, I'd just been doing some
work that prompted me to rethink my own assumptions about JavaScript's
effective domain. Although I usually reach for JavaScript when I need to
activate a web page in some way, and generally rely on its special relationship
to the browser and its document object model, I've also increasingly
found myself running JavaScript from the command line using the cscript
utility that's part of the Windows Scripting Host (WSH).
Here's an example. I work on a project that needs some ad-hoc reporting.
The database is accessible at an authenticated URL, allows a subset of SQL
to be passed on the URL-line, and returns results as HTML or XML. Queries
have two general flavors: Some count or sum matching records for a set
of dateranges, others display them. The queries further subdivide into families;
within each family a query has the same general shape, which varies
along one or several dimensions. Typically, in this situation, I've used
templates to express the query shapes, and Perl to interpolate values
into variable slots and run the queries. But this time, I wanted to make
the mechanism available to others without requiring them to have or use
Perl, or deal with any CGI machinery. Why not use JavaScript to manage the
query templating and query execution?
There was one obstacle. The queries that return counts of records are used
interactively, as a kind of status dashboard. But there's also a need to
record these numbers at regular intervals and save them for longitudinal
analysis.
Page 1 of 1
BYTE.com > Tangled in the Threads > 2002 > February
|