Scheme as the Language of the Internet
One thing that has always bugged me about the web is that it is composed of so many discordant technologies, all cobbled together as best as the original architects could manage. We write our web pages in Java and PHP and Perl and sometimes even in C++ to generate a particular dialect of SGML, style it all up with a special one-off syntax that has nothing in common with anything else, and script the client in JavaScript. It works, and experience has taught me that the state of the art will always follow this pattern, however much one might wish for a unified, ivory tower solution to wrap it all up.
Despite this, I’ve always been interested in the possibilities of replacing all of the above technologies with a single language: Scheme.
Scheme has basically all the features you could ever want, plus the one feature that lets you build all the rest. Further, its super-regular syntax makes it an outstanding data description language. In other words, it’s the omni-purpose DSL.
Basically, the way it would work is that your scripts would generate a document tree. Consuming this script, and transforming it into HTML, CSS, and JavaScript would be relatively straightforward. It might even be feasible to do enough static analysis to generate AJAX services for server logic that is initiated by client events.
So, to randomly djinn up an example, we’d be able to do something like this*:
(link (label "Send")
(style
(image-src "button.png")
(mouseover
(image-src "button-mouseover.png")))
(onclick
(lambda ()
(do
(mysql-query
(concat "INSERT INTO messages (text) VALUES ("
(get-element-value 'text-box)
")"))
(show-dialog "Your message has been sent")))))
There are a few things that make this not quite the Greatest Idea Ever. The first one is that I don’t think Scheme is the most pleasurable language in the world to write.
The second one only came to me recently while revisiting the idea, and it’s the really important one: why bother? Such a system would mean abandoning all of the tools and expertise out there, and all for what? Sure, it’s theoretically cool, but, even if you could mix your client and server logic with your layout and presentation, would you really want to?
* I don’t remember how to do things in Scheme at all anymore. I am probably butchering the syntax. Sorry!