<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>overwatering &#187; shrew</title>
	<atom:link href="http://www.overwatering.org/blog/category/shrew/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.overwatering.org/blog</link>
	<description>Random musings on fish, books and occasionally programming.</description>
	<lastBuildDate>Mon, 07 Nov 2011 07:06:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Ultimate Development Environment</title>
		<link>http://www.overwatering.org/blog/2008/03/the-ultimate-development-environment/</link>
		<comments>http://www.overwatering.org/blog/2008/03/the-ultimate-development-environment/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 10:52:00 +0000</pubDate>
		<dc:creator>giles</dc:creator>
				<category><![CDATA[comp. sci.]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[shrew]]></category>

		<guid isPermaLink="false">http://www.overwatering.org/blog/2008/03/the-ultimate-development-environment/</guid>
		<description><![CDATA[An enormous claim, I know. But this is not about processes, tools or
working conditions. This is about something quite different.

Shrew is
progressing, it now sports an s-expr to XML evaluator; I&#8217;m reading
RESTful Web Services to gain a better idea of how it should expose
resources. And I&#8217;m also working through The Seasoned Schemer. And
therein lies the most [...]]]></description>
			<content:encoded><![CDATA[<p>An enormous claim, I know. But this is not about processes, tools or
working conditions. This is about something quite different.</p>

<p><a href="http://overwatering.blogspot.com/search/label/shrew">Shrew</a> is
progressing, it now sports an s-expr to XML evaluator; I&#8217;m reading
<em>RESTful Web Services</em> to gain a better idea of how it should expose
resources. And I&#8217;m also working through <em>The Seasoned Schemer</em>. And
therein lies the most interesting aspect to Shrew. I am a reasonably
experienced, quite competent polyglot software engineer, but learning
Scheme has forever changed how I think about programming. And through
example crystallised the ultimate development environment that I have
been drifting towards.</p>

<p>When I&#8217;m working on Shrew, my editor looks something like this:</p>

<div style="text-align:center;"><a href="http://www.flickr.com/photos/21818828@N00/2312302048" title="View 'i-scheme-emacs' on Flickr.com"><img src="http://farm4.static.flickr.com/3214/2312302048_65651591d0.jpg" alt="i-scheme-emacs" border="0" width="400" height="300" /></a></div>

<p>In the top-left is the module I am currently working on: writing,
expanding or fixing &#8211; as I&#8217;ll try to show there isn&#8217;t really any
difference between those three. In the top-right is a scratch file
that contains a bunch of ad-hoc tests for the module I&#8217;m working on:
nothing structured, just calls of the functions that I&#8217;m
writing. Across the bottom is the output from a Scheme process running
in the background.</p>

<p>Before I go on there&#8217;s one detail of Scheme I should explain. To write
a new function you call a built-in function called <code>define</code>, passing
the name of the new function and its body. <code>define</code> is smart enough to
simply replace the body if a function of that name already exists.</p>

<p>It sounds like a pretty simple development environment: a plain text
editor with three windows on screen. Why so special?</p>

<p>I write a function &#8211; not a test, sample or prototype, but the real
code I&#8217;m planning to commit &#8211; I jump to the end of the <code>define</code> and
run a command in my editor to evaluate it. That function is then
inserted into the running Scheme process and available to be used by
anything else that is run in that Scheme process. Or, I&#8217;m immediately
informed of a syntax error in my code.</p>

<p>I switch over to the scratch file and write some code to call the
function I just implemented: typically just one expression, but it can
be as many as I need. I evaluate that new code. And immediately see
the output in the window at the bottom; the window reflecting the
running state of the background Scheme process.</p>

<p>And of course, there&#8217;s a bug in my function. I switch back to the
window containing the module, fix the bug and re-evaluate. I switch
back to the test code, re-evaluate that, and see that my change has
fixed the bug.</p>

<p>Elapsed time from writing the function through debugging and verifying
the fix: 45 seconds.</p>

<p>Instead of having to write a complete library, compile it, write a
test harness, compile that and link it to the library and only then
run the code to see if it works, I have a Scheme process running in
the background that I can just keep adding code to. New code, or code
to replace existing code. And at any point I can execute any sub-part
of that process and immediately see the output. No delays, no pauses,
no backtracking to find which line of code is wrong.</p>

<p>Scheme could be regarded as a fairly direct implementation of a
theoretical model of computation: the lambda calculus. Most texts that
teach Scheme emphasise this; they encourage you to think of your
programs in terms of this theory, in quite some detail. That may sound
fairly esoteric, but once you&#8217;ve spent sometime working in this
environment you reach this unique state. You are inside your program,
reaching around moving code as fast as you can think. There is
essentially nothing between your thought and code: no defining
boilerplate, no compiling, no creating test harnesses, no waiting for
test runs to complete. Your solution simply unfolds before you.</p>

<p>But that&#8217;s not to say your code is of lower quality. In fact, because
you&#8217;re concentrating more fully, with no distractions and the
flexibility to easily push your code in any way you want, the code is
of much higher quality. There&#8217;s no idle thought &#8216;I should test that&#8217;
which is forgotten in the edit-compile-run-debug cycle: think it, try
it. This is flow as
<em><a href="http://overwatering.blogspot.com/2007/04/peopleware.html">Peopleware</a></em>
could only dream.</p>

<p>And once you break out of this magical flow, you&#8217;re left with complete
code; code you lived and breathed for a few hours, code you understand
deeply and will have a hard time forgetting. Plus, a comprehensive set
of tests to commit alongside.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overwatering.org/blog/2008/03/the-ultimate-development-environment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thoughts on Scheme</title>
		<link>http://www.overwatering.org/blog/2007/08/thoughts-on-scheme/</link>
		<comments>http://www.overwatering.org/blog/2007/08/thoughts-on-scheme/#comments</comments>
		<pubDate>Sat, 18 Aug 2007 09:50:00 +0000</pubDate>
		<dc:creator>giles</dc:creator>
				<category><![CDATA[comp. sci.]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[shrew]]></category>

		<guid isPermaLink="false">http://www.overwatering.org/blog/2007/08/thoughts-on-scheme/</guid>
		<description><![CDATA[There&#8217;s nothing like writing a complex application in a language for
really learning it. I&#8217;ve been able to read and write small pieces of
Scheme for years. And I&#8217;ve known enough of the underpinnings of the
language to write a (very) small Scheme interpreter in the past. But,
part of the point of writing Shrew in Scheme as opposed [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s nothing like writing a complex application in a language for
really learning it. I&#8217;ve been able to read and write small pieces of
Scheme for years. And I&#8217;ve known enough of the underpinnings of the
language to write a (very) small Scheme interpreter in the past. But,
part of the point of writing Shrew in Scheme as opposed to, say, Ruby
is to really learn the language.</p>

<p>I haven&#8217;t been at it for long, but here are some random thoughts and
comments so far. Much of this will change as I figure out how to use
Scheme properly. These comments are also mainly a comparison of the
only other functional language I know
well: <a href="http://haskell.org">Haskell</a>.</p>

<ul>

<li>The syntax is not very clear: everything looks the same. This
prevents you from scanning the code to get a feel for what is
happening. The indentation helps, but fundamentally every operation is
just a parenthesized expression. I am certain that this is just
cultural, with more exposure I&#8217;ll get better at reading; don&#8217;t count
this as a negative.</li>

<li>I really miss pattern matching. How can you program without it?
I&#8217;m going to have to look into <code>destructuring-bind</code>.</li>

<li>Dynamic typing is sweet. As well as all the other benefits,
dynamic typing + modules = as much encapsulation as classes give you
in C++.</li>

<li>The standard libraries are pretty paltry. The SRFIs add a lot, but
it&#8217;s still nowhere near as rich as pretty much any other
language. Maybe I&#8217;ll explore Common Lisp at some point.</li>

<li>Currying is not just an implementation technicality, it&#8217;s useful
for designing data structures. I miss currying as well.</li>

</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.overwatering.org/blog/2007/08/thoughts-on-scheme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Shrew?</title>
		<link>http://www.overwatering.org/blog/2007/08/what-is-shrew/</link>
		<comments>http://www.overwatering.org/blog/2007/08/what-is-shrew/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 11:45:00 +0000</pubDate>
		<dc:creator>giles</dc:creator>
				<category><![CDATA[comp. sci.]]></category>
		<category><![CDATA[shrew]]></category>

		<guid isPermaLink="false">http://www.overwatering.org/blog/2007/08/what-is-shrew/</guid>
		<description><![CDATA[Shrew: a small
insectivorous, mammal; one of the descendents of the first mammals to
evolve. Related
to voles
and hedgehogs. They
are not rodents, and are not in related to mice and rats.

It&#8217;s also an animal name containing the letters S, R and W: I use
animal names for my project code names, and I needed this one to
contain those three [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Shrew">Shrew</a>: a small
insectivorous, mammal; one of the descendents of the first mammals to
evolve. Related
to <a href="http://en.wikipedia.org/wiki/Vole">voles</a>
and <a href="http://en.wikipedia.org/wiki/Hedgehog">hedgehogs</a>. They
are not rodents, and are not in related to mice and rats.</p>

<p>It&#8217;s also an animal name containing the letters S, R and W: I use
animal names for my project code names, and I needed this one to
contain those three letters. The R and W are for REST and Web Server
respectively, the S is for Scheme. I&#8217;ll get to that later.</p>

<p>The idea of Shrew is to build a web server that makes the creation of
RESTful web services easy. Popular web servers are still designed as
file servers: a web server exposes a directory tree, and then allows
certain files within that tree to be executed on the server, to
generate the content to send to the client. This encourages (even
forces) web applications and services to be built around
files. RESTful services are supposed to built around resources. These
resources are meant to be the logical &#8216;things&#8217; that exist in your
service: not files. You don&#8217;t want to have &#8220;.aspx&#8221; or &#8220;.jsp&#8221; or &#8220;.php&#8221;
appearing in your resource URI. It should look something
like <code>/person/visit/730</code>. And one of the rewriting modules
should not be how you have to get there.</p>

<p>Shrew will make resources the centre of an application or service. The
resources exposed will be listed and mapped onto a URI form, and also
a piece of code to handle that resource. Shrew will also make no
attempt to pretend that an application is not running over HTTP. All
request headers will be available to the application; the application
will be able to override the generation of response headers on a
response-by-response basis; the application will be able to specify
particular response codes.</p>

<p>Most importantly, dispatch of incoming requests will be performed not
just on the request URI, but also the request method: GET, POST, PUT
or DELETE.</p>

<p>The point of providing this level of control is to allow applications
to be properly RESTful. For example, look at the Etags header. When a
request for a URI is first served to a client a web server can
generate and attach an Etag header. If the client requests that
resource again, it can include the Etag header in the request. The
server can then use the received Etag to determine if the resource has
changed and needs to be re-sent. Sounds fantastic, right? No need to
re-generate a complex page on the server, or send down a large amount
of HTML. The server reduces its load, and the client can redisplay
faster. A popular web framework even automatically implements Etags
for you. Everyones&#8217; happy.</p>

<p>Not so fast. That popular web framework generates its Etags by taking
an MD5 hash of the page before sending it to the client. This requires
generating the full page, everytime. Even when it hasn&#8217;t changed. It
saves the bandwidth, but not the server processing time. To do Etags
properly the application needs control of headers, it needs to be able
to match the response to a particular resource.</p>

<p>The web changes rapidly, there could be other valuable headers coming
soon, there could be interesting and unique ways of using existing
headers. Instead of trying to forsee all those cases, Shrew will
simply provide default implementations for headers, but allow an
application to override those.</p>

<p>Of course, there&#8217;s more to web applications than requests and
responses. Part of the reason those rewriting solutions are
distasteful is that the generated pages needs to use URIs in the
rewritten space, not the developers directory space. Shrew will allow
resources to link to other resources, by name and id, generating the
correct URI at runtime.</p>

<p>Shrew will also include a library for writing markup. This will not be
template based. The markup will be written in a Shrew DSL and then
executed to produce the HTML. Inspired
by <a href="http://code.whytheluckystiff.net/markaby/">Markaby</a>. This
markup will be renderable as HTML for serving to a browser, and also
as XML for serving to a web service client. This will probably require
some hinting, as large parts of the HTML will not be required in a XML
view. It&#8217;s going to be interesting to get that to work&#8230;</p>

<p>Finally, in
my <a href="http://overwatering.blogspot.com/2007/08/new-project-shrew.html">introduction
to Shrew</a> I mentioned some unusual technology choices: the whole
thing will be written in Scheme. This is the other half of Shrew as
learning project. As well as really getting a handle on REST, I want
to learn Scheme. I can read Scheme and write small projects in Scheme,
but there&#8217;s nothing like writing something large for really getting a
feel for a language.</p>

<p>In particular, Scheme&#8217;s killer feature to me is &#8216;data is code.&#8217; Not
that code is data, nor the macro system, nor that it&#8217;s a functional
language. I&#8217;m really interested in exploring the data is code concept,
and a web application/service framework seems like a good place to try
that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overwatering.org/blog/2007/08/what-is-shrew/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The New Project: Shrew</title>
		<link>http://www.overwatering.org/blog/2007/08/the-new-project-shrew/</link>
		<comments>http://www.overwatering.org/blog/2007/08/the-new-project-shrew/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 08:50:00 +0000</pubDate>
		<dc:creator>giles</dc:creator>
				<category><![CDATA[comp. sci.]]></category>
		<category><![CDATA[shrew]]></category>

		<guid isPermaLink="false">http://www.overwatering.org/blog/2007/08/the-new-project-shrew/</guid>
		<description><![CDATA[I&#8217;ve been reading and thinking about RESTful web applications and
services quite a bit recently. The last large web application I wrote
evolved into a RESTful web application: readable, bookmarkable URLs;
resources with unique addresses; and alternative renderings of a
resource depending on the request.

It would have been a short step to complete this evolution and then
expose the programmable [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading and thinking about RESTful web applications and
services quite a bit recently. The last large web application I wrote
evolved into a RESTful web application: readable, bookmarkable URLs;
resources with unique addresses; and alternative renderings of a
resource depending on the request.</p>

<p>It would have been a short step to complete this evolution and then
expose the programmable interface as RESTful as well. This all
happened without being aware of REST: it just seemed like the logical
way to design a web application.</p>

<p>REST is starting to make a big splash now. Web services have been
around for a few years, and many systems have been built upon
them. Beyond the architectural considerations, it seems that the main
differences between the two approaches is that it is easier to write
clients for a RESTful service, and it is easier to write the service
using SOAP.</p>

<p>Up until recently most of the development of web services has been for
systems that do not cross organisation boundaries. Therefore, the
consumer of the web service has usually been the programmer who wrote
it. Or, if not actually the same programmer, then a programmer in the
same organisation. SOAP works well in this environment as one
development tool can be mandated and this tool can generate all the
painful code required to consume a SOAP service, and when the SOAP
service changes every single consumer can be informed.</p>

<p>However, now there are many services being exposed on the Internet
that provide useful data. Services such as Google Maps. It is becoming
more common to write applications that consume a handful of services
from different organisations. Suddenly, it is more important for the
client to be robust and easy to write.</p>

<p>Unfortunately though, it is still much easier to write the service
using SOAP than REST. Most web servers don&#8217;t deal well with the
concept of the URI not referring to an actual file on disk, and there
aren&#8217;t many frameworks that put resources rather pages at the
centre. There seems to a hole in the eco-system here.</p>

<p>I&#8217;m going to take a shot at filling it. For this project, as I&#8217;ll be
doing this for interest and to learn, I&#8217;m going to talk about what I
do as I do it. Ruby On Rails will ultimately provide the full RESTful
service framework that the world needs; I&#8217;m not expecting to make
money off this project. No need to hide anything.</p>

<p>I&#8217;ve started writing some code, and planning a simple design. I&#8217;m
going to make some apparently unusual technology choices, but this is
for my learning. I&#8217;ll talk about the technology and design in some
upcoming posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overwatering.org/blog/2007/08/the-new-project-shrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

