« Java vs. C++ | Main | Microsoft Needs a Theory »

Amazon Web Services in Scheme

Initial screen for Amazon Web Services (AWS) in Scheme
Earlier, I showed my Programming Languages class how XML and s-expressions were related and how to use the SSAX parser to parse XML into s-expressions. I wanted to do something more real, however, so yesterday, I wrote a package to call Amazon Web Services from Scheme, parse the results using SSAX, and query the output using SXPATH. The result was a s-expression version of the results formatted as HTML.

That’s not nearly enough, however since after you’ve run the query from inside the Scheme interpreter a couple of times and see the results come back, you want a Web page. So, I used the Web server that comes with DrScheme to write a Scheme servlet that uses the AWS query code to build a Web application that lets a user query Amazon and see the formatted results. I’ve put together a page to describe how I did it.

Results of querying AWS for “eagles” in books.

The pictures at the right show the Web application in action and the code is available for downloading in the pages linked above.

I’ve written programs that use XML in Java, Perl, Python, XSLT, and now Scheme. Scheme has been the easiest. I think the reason is that with s-expressions, XML is essentially a native data type in Scheme. That’s an incredibly powerful idea. Your milage, of course, may vary. If Lisp isn’t your thing, you’ll have to wait for something else.

My primary purpose in doing all of this is to show my students why understanding programming language concepts and how to build language interpreters is relevant. Using XML is all about defining data languages, including BNF (schema) and then parsing and manipulating the results. The point isn’t that this is in Scheme, but that once they know how to do it in Scheme, doing it in another language will be just adapting what they already know.

Posted by windley on February 4, 2005 4:26 PM

See related posts:

1 Comments

Comment from Brian Kramer at February 7, 2005 12:57 PM

I am finding XML to be a good choice for representing data in my research, even when all other tools don't. It's refreshing to be able to use a standardized and extensible syntax instead of inventing my own or borrowing syntax from related work.

Anyway, to contribute more directly to this thread: bringing XML to the language level does sounds like a great idea. Incidentally, Monad (Microsoft's "next" command line shell) also has a native XML type. I dove into using Monad for a while, but it is quite a conceptual leap for those normally used to the NT command line environment.

PS I am a former student of Dr. Whidbey, "way back when," and I learned Scheme from him (but like a foreign language, I lost the "tongue" for it.)