[plt-scheme] Implementing web services

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Aug 9 11:28:21 EDT 2007

Isaac Raway wrote:
> Hey guys. First post for me.

Welcome.

> I am looking at creating a complex system which uses four main components:
> 
> - Client side GUI
> - Limited web based interface
> - Web service
> - Database
> 
> I would like to implement all of this in pure PLT Scheme.
> 
> The main thing I really need is some idea of how to implement web 
> services with PLT Scheme.
> 
> To clarify, this is different from the recent request for how to go 
> about generating a website. What I'm looking for is a way to implement, 
> say, a module, export some procedures from it, and have those accessible 
> through a stub object on the client side or directly called by the view 
> of the dynamic web interface.

I'd define a model module in which all data is stored. Then I'd
have separate control and view for the web and GUI parts. Both the
control-web and control-gui module require the same model module.

How the model component is implemented depends on whether the
data is shared between the clients.

In principle the approach described in:

<http://www.scheme.dk/blog/2007/01/introduction-to-web-development-with.html>

could be extended to support a GUI.

Question: Would make sense to have a general control module and then
have control-gui and control-web to proxy operations to the general
control module?

> I'd also like suggestions on how to handle data storage in a "Scheme way".

I don't there is Scheme way per se. Consider instead the data and
see what requirements you have for storing and processing data.

Popular solutions:
   1) Simple read and write to files
   2) Relational databases
   3) A layer on top of relational databases, such that
      the data looks like normal structures.

> I am, to put it bluntly, a novice Scheme programmer. I have been doing 
> software development for several years in lesser languages (any basic, 
> C++, Javascript, some Java, lots of PHP), but I consider myself a *fan* 
> of Scheme if there can be such a thing.
> 
> Any tips to get me going? 

Look at SXML and/or X-expressions. Then write a few simple module
based servlets. Also read Noel and David's experince report.

<http://blog.plt-scheme.org/2007/08/experience-report-scheme-in-commercial.html>

> Assume I can run the web server included with 
> PLT Scheme. My development platform is Mac OS X but everything has to 
> run on Mac, Win XP+, and Linux, which I don't think will be a problem, 
> just to note that's important for me.

I normally develop on WinXP (don't ask) and deploy on Linux. That
very seldom leads to problems.

> Eventually I'll probably get into other requests when it comes to the 
> interesting parts of the application, but for now I just want to get 
> some basic web service stuff going.

A last tip: If one takes the time to think of the right question, this
mailing list provides surprisingly insightful answers. (But you seem
to have figured this out already)

-- 
Jens Axel Søgaard



Posted on the users mailing list.