<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Documents vs. Objects</title>
	<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/</link>
	<description></description>
	<pubDate>Tue, 07 Oct 2008 01:42:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>

	<item>
		<title>By: Kevin Teague</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8863</link>
		<dc:creator>Kevin Teague</dc:creator>
		<pubDate>Fri, 18 Jan 2008 12:08:17 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8863</guid>
		<description>"An object has behavior but no visible state"

In REST you want to represent the state so that you can transfer it over the network (yeah, duh). In many forms of programming we often work almost exclusively with objects. Since the state of an object is encapsulated by behaviour it can feel like trying to thread a needle with oven mitts on, "dear object, tell me what you are so that I may better represent you!"

"In an object-based system you can only poke around with a process of 20 questions, hoping that there isn't some hidden truth that you are unaware of. For instance, talking to a proxy that is almost exactly like the original object, but with some small replacement. Of course internally a server can be peculiarly coupled as well, with relationships between the resources that aren't explicit or obvious. But at least the faces it projects are fully formed."

Ha! Twenty questions is a good analogy. Objects can act according to Heisenberg's uncertainty principle, whereby the act of observing an object changes the object itself. This can be mitigated if you do not treat all objects as conceptually equal. If you have a category of objects whose only purpose is to describe the outward face of another object - including a description of state of the object it describes, then you don't need to play 20 questions with an object to get a sense of an objects outward face. COM and zope.interface/zope.schema provide such things, but then these are only loose promises of what they *think* the state of an object is. If your object is a proxy object or has other comlexities then when it comes time to extract state it may not be what you expect.

In these ways of thinking we say interface and implementation. A description of behaviour (interface) and the many possibilities of that behaviour (implementation). There are interesting parallels between this and resources and documents. A state (document) and the many possibilities of that state over time (resource).

Infinite behviour mutliplied by infinite state and the mind is pleasantly boggled ... :)</description>
		<content:encoded><![CDATA[<p>&#8220;An object has behavior but no visible state&#8221;</p>

<p>In REST you want to represent the state so that you can transfer it over the network (yeah, duh). In many forms of programming we often work almost exclusively with objects. Since the state of an object is encapsulated by behaviour it can feel like trying to thread a needle with oven mitts on, &#8220;dear object, tell me what you are so that I may better represent you!&#8221;</p>

<p>&#8220;In an object-based system you can only poke around with a process of 20 questions, hoping that there isn&#8217;t some hidden truth that you are unaware of. For instance, talking to a proxy that is almost exactly like the original object, but with some small replacement. Of course internally a server can be peculiarly coupled as well, with relationships between the resources that aren&#8217;t explicit or obvious. But at least the faces it projects are fully formed.&#8221;</p>

<p>Ha! Twenty questions is a good analogy. Objects can act according to Heisenberg&#8217;s uncertainty principle, whereby the act of observing an object changes the object itself. This can be mitigated if you do not treat all objects as conceptually equal. If you have a category of objects whose only purpose is to describe the outward face of another object - including a description of state of the object it describes, then you don&#8217;t need to play 20 questions with an object to get a sense of an objects outward face. COM and zope.interface/zope.schema provide such things, but then these are only loose promises of what they <em>think</em> the state of an object is. If your object is a proxy object or has other comlexities then when it comes time to extract state it may not be what you expect.</p>

<p>In these ways of thinking we say interface and implementation. A description of behaviour (interface) and the many possibilities of that behaviour (implementation). There are interesting parallels between this and resources and documents. A state (document) and the many possibilities of that state over time (resource).</p>

<p>Infinite behviour mutliplied by infinite state and the mind is pleasantly boggled &#8230; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Dai</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8819</link>
		<dc:creator>David Dai</dc:creator>
		<pubDate>Fri, 18 Jan 2008 08:03:06 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8819</guid>
		<description>Like many have pointed out, if you think of document/resource based system as a version/difference system, then we can easily see the differences between the resource and the object model.  In its purest form a REST/resource based model can be seen as an explicit state representation.  You "do" something to the state by adding or moving things (documents) around (think of destruction of the state as a relocation of resource, maybe to /dev/null?).  You have a full history of what is going on and things are always additive.  Mixing in the time dimension, (current) state of the system is basically a snapshot of what you have added to the system so far.  If you stop in time, and check out (punt intended) the "current" state of the system and how it's functioning, there is no difference between object-based and resource-based systems. However, with a resource-based system, you have (or at least in theory) the whole history of what you've have done.  You can look at states other than the "current" one to compare and contrast what your have done.  Where as an object-based system tend to confine you to only the current state, and you have to infer what has happened.  Maybe this is why you can "feel a certain confidence" towards a resource-based system, or you "can get a real sense of what the truth is".  But do keep in mind that too much information can overwhelm a system and its users.  There is always a balance/trade-off in an imperfect world.  Maybe we should start thinking about what all these mean in quantum computing...  hm... the possibilities... :)</description>
		<content:encoded><![CDATA[<p>Like many have pointed out, if you think of document/resource based system as a version/difference system, then we can easily see the differences between the resource and the object model.  In its purest form a REST/resource based model can be seen as an explicit state representation.  You &#8220;do&#8221; something to the state by adding or moving things (documents) around (think of destruction of the state as a relocation of resource, maybe to /dev/null?).  You have a full history of what is going on and things are always additive.  Mixing in the time dimension, (current) state of the system is basically a snapshot of what you have added to the system so far.  If you stop in time, and check out (punt intended) the &#8220;current&#8221; state of the system and how it&#8217;s functioning, there is no difference between object-based and resource-based systems. However, with a resource-based system, you have (or at least in theory) the whole history of what you&#8217;ve have done.  You can look at states other than the &#8220;current&#8221; one to compare and contrast what your have done.  Where as an object-based system tend to confine you to only the current state, and you have to infer what has happened.  Maybe this is why you can &#8220;feel a certain confidence&#8221; towards a resource-based system, or you &#8220;can get a real sense of what the truth is&#8221;.  But do keep in mind that too much information can overwhelm a system and its users.  There is always a balance/trade-off in an imperfect world.  Maybe we should start thinking about what all these mean in quantum computing&#8230;  hm&#8230; the possibilities&#8230; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil jones</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8813</link>
		<dc:creator>phil jones</dc:creator>
		<pubDate>Fri, 18 Jan 2008 02:53:51 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8813</guid>
		<description>Great post.

I liked the way you started with late binding.

The fact is, the resource model (eg. web) gives up on late-binding, gives up on polymorphism (there's no ambiguity about what's at the end of the URL), and doesn't really encapsulate *behaviour* much at all.

That turns out to be OK. 

But does it, in fact, turn out to be OK because the web as we understand it simply doesn't have much behaviour? And so ReST is sufficient to keep it under-control? 

Or does it turn out to be OK because, in fact, the extra complexity of managing the indirection needed to give you later-binding makes it impossible to scale? And so programming in the largest large  means giving up on hopes of polymorphism altogether ... and so living with the redundancy?</description>
		<content:encoded><![CDATA[<p>Great post.</p>

<p>I liked the way you started with late binding.</p>

<p>The fact is, the resource model (eg. web) gives up on late-binding, gives up on polymorphism (there&#8217;s no ambiguity about what&#8217;s at the end of the URL), and doesn&#8217;t really encapsulate <em>behaviour</em> much at all.</p>

<p>That turns out to be OK. </p>

<p>But does it, in fact, turn out to be OK because the web as we understand it simply doesn&#8217;t have much behaviour? And so ReST is sufficient to keep it under-control? </p>

<p>Or does it turn out to be OK because, in fact, the extra complexity of managing the indirection needed to give you later-binding makes it impossible to scale? And so programming in the largest large  means giving up on hopes of polymorphism altogether &#8230; and so living with the redundancy?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Fuecks</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8434</link>
		<dc:creator>Harry Fuecks</dc:creator>
		<pubDate>Wed, 16 Jan 2008 21:23:50 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8434</guid>
		<description>Starting from a more mundane origin, the web.py framework gives you controllers with methods corresponding to HTTP methods, which is a good starting point for designing a web app. around the notion of resources. But what when you want to compose a web page out of multiple resources; it would be nice to be able to call the corresponding web.py controllers via their externally facing methods.

Unfortunately you don't know what the side effects will be - a controller you call might start sending undesirable HTTP headers such as content-length. Also it would be nice, if the call would be rather more than just a method-call; acting like an HTTP client, calling a server so, for example, caching headers can be employed. So perhaps it would be nice to unify fetching a remote resource with fetching one "internally" from memory.

Meanwhile, given a URI for a resource and it's value (the document), HTTP provides mechanisms for comparing the value you currently have the source you got it from, from modification time to direct comparison via something checksum-like (E-Tags). In most programming languages, when you receive a copy of some variable, you first don't really have a way to know it's source and comparisons of values may be [difficult and expensive](http://cpan.uwinnipeg.ca/dist/Data-Compare).

Perhaps those are problems that would be interesting to solve at a language level?</description>
		<content:encoded><![CDATA[<p>Starting from a more mundane origin, the web.py framework gives you controllers with methods corresponding to HTTP methods, which is a good starting point for designing a web app. around the notion of resources. But what when you want to compose a web page out of multiple resources; it would be nice to be able to call the corresponding web.py controllers via their externally facing methods.</p>

<p>Unfortunately you don&#8217;t know what the side effects will be - a controller you call might start sending undesirable HTTP headers such as content-length. Also it would be nice, if the call would be rather more than just a method-call; acting like an HTTP client, calling a server so, for example, caching headers can be employed. So perhaps it would be nice to unify fetching a remote resource with fetching one &#8220;internally&#8221; from memory.</p>

<p>Meanwhile, given a URI for a resource and it&#8217;s value (the document), HTTP provides mechanisms for comparing the value you currently have the source you got it from, from modification time to direct comparison via something checksum-like (E-Tags). In most programming languages, when you receive a copy of some variable, you first don&#8217;t really have a way to know it&#8217;s source and comparisons of values may be <a href="http://cpan.uwinnipeg.ca/dist/Data-Compare">difficult and expensive</a>.</p>

<p>Perhaps those are problems that would be interesting to solve at a language level?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philippe Marschall</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8430</link>
		<dc:creator>Philippe Marschall</dc:creator>
		<pubDate>Wed, 16 Jan 2008 21:16:13 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8430</guid>
		<description>Your Smalltalk code is wrong, it should be:

    buddies do: [ :buddy &#124; buddy sendMessage: myMessage]

note the colon on the first buddy, the period is actually optional</description>
		<content:encoded><![CDATA[<p>Your Smalltalk code is wrong, it should be:</p>

<pre><code>buddies do: [ :buddy | buddy sendMessage: myMessage]
</code></pre>

<p>note the colon on the first buddy, the period is actually optional</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mueller</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8406</link>
		<dc:creator>Patrick Mueller</dc:creator>
		<pubDate>Wed, 16 Jan 2008 20:30:37 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8406</guid>
		<description>*"signalling a reference’s immutability isn’t something I’ve seen REST try to handle"*

Probably more correct to say that HTTP doesn't have a way of signalling immutability; REST doesn't add anything like that to the equation anyway.

This has come up before, on some other blog thread, because there are some fairly clear use-cases for it.  The most obvious one I've run into is pre-packaged versions of huge JS libraries (dojo, yui), which, at least in production, you could certainly treat as immutable by using a version number in the URL itself (presumably a directory name).</description>
		<content:encoded><![CDATA[<p><em>&#8220;signalling a reference’s immutability isn’t something I’ve seen REST try to handle&#8221;</em></p>

<p>Probably more correct to say that HTTP doesn&#8217;t have a way of signalling immutability; REST doesn&#8217;t add anything like that to the equation anyway.</p>

<p>This has come up before, on some other blog thread, because there are some fairly clear use-cases for it.  The most obvious one I&#8217;ve run into is pre-packaged versions of huge JS libraries (dojo, yui), which, at least in production, you could certainly treat as immutable by using a version number in the URL itself (presumably a directory name).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8383</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Wed, 16 Jan 2008 19:46:20 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8383</guid>
		<description>Dave:

The mapping between what you describe and Ian's description of REST would seem to be "view -&#62; uri, (view,state) -&#62; (uri,tick)".

Ian:

Really good stuff.

The pair (uri,tick) can also be represented as object/document, at a uri. Immutable and reference-able resource.

"You can pass around a reference value (a URI), but this is like calling a function with a pointer argument."

URIs are unlike pointers in that they don't refer to the same "memory address" (call-by-value, your point), modifications are not necessarily symmetric. For immutable resources, you can ignore the distinction, but signalling a reference's immutability isn't something I've seen REST try to handle. (Caching with etag/if-not-modified does allow you to grossly detect when immutability becomes non-operative.)

URIs are like pointers in that we can perform some key operations without dereferencing a given uri. Relational join, index/hash lookup; metadata. Microformats, RDF, LinkedData are all focused around expanding the pool of data you know about things you may only have heard of, not yet seen or touched. In immutable/by-value, this property is perhaps associated with lazy evaluation.

On the distinction between document and object models, inheritance is something to consider (or say, polymorphism, to stick with your intro's avoidance of classes). Date and Darwen in Third Manifesto make a solid argument that an (object model with object-ids) cannot support an (inheritance model with generalization/specialization-by-constraint). It would be interesting to see if the differences between URIs and objectIDs/pointers remove that limitation.</description>
		<content:encoded><![CDATA[<p>Dave:</p>

<p>The mapping between what you describe and Ian&#8217;s description of REST would seem to be &#8220;view -&gt; uri, (view,state) -&gt; (uri,tick)&#8221;.</p>

<p>Ian:</p>

<p>Really good stuff.</p>

<p>The pair (uri,tick) can also be represented as object/document, at a uri. Immutable and reference-able resource.</p>

<p>&#8220;You can pass around a reference value (a URI), but this is like calling a function with a pointer argument.&#8221;</p>

<p>URIs are unlike pointers in that they don&#8217;t refer to the same &#8220;memory address&#8221; (call-by-value, your point), modifications are not necessarily symmetric. For immutable resources, you can ignore the distinction, but signalling a reference&#8217;s immutability isn&#8217;t something I&#8217;ve seen REST try to handle. (Caching with etag/if-not-modified does allow you to grossly detect when immutability becomes non-operative.)</p>

<p>URIs are like pointers in that we can perform some key operations without dereferencing a given uri. Relational join, index/hash lookup; metadata. Microformats, RDF, LinkedData are all focused around expanding the pool of data you know about things you may only have heard of, not yet seen or touched. In immutable/by-value, this property is perhaps associated with lazy evaluation.</p>

<p>On the distinction between document and object models, inheritance is something to consider (or say, polymorphism, to stick with your intro&#8217;s avoidance of classes). Date and Darwen in Third Manifesto make a solid argument that an (object model with object-ids) cannot support an (inheritance model with generalization/specialization-by-constraint). It would be interesting to see if the differences between URIs and objectIDs/pointers remove that limitation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wynand Winterbach</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8298</link>
		<dc:creator>Wynand Winterbach</dc:creator>
		<pubDate>Wed, 16 Jan 2008 16:46:58 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8298</guid>
		<description>Interesting post.

Speaking of document-oriented systems, I think that monads could make for some very interesting applications.

In a document-oriented system (say an interactive web-app) written in a language like Haskell (where state is explicitly isolated), state (which would be contained in a set of monads) could be sent to the client with each response. The state could be something like a continuation.

In this sense, one would have a continuation-based system (like &lt;a href="http://seaside.st" rel="nofollow"&gt;Seaside&lt;/a&gt;), but instead of the state residing on the server, it resides with the client. So all documents (in the web-app) can remain immutable.

Researchers at Cornell have developed a stateless network stack based on this idea. It's called "Trickles" (&lt;a href="http://www.cs.cornell.edu/~ashieh/trickles/protocol.php" rel="nofollow"&gt;http://www.cs.cornell.edu/~ashieh/trickles/protocol.php&lt;/a&gt;).

This system will probably be impractical if the client state requires a lot of storage space. Perhaps a way around this problem is a hybrid approach where some state is sent to the client and where new documents are created on the server (using something like PUT) to represent the rest of the client state. 

But this is pretty much back to the Seaside model (although given my lack of knowledge of the inner workings of Seaside, I don't know whether client state can be reified as a set of documents).</description>
		<content:encoded><![CDATA[<p>Interesting post.</p>

<p>Speaking of document-oriented systems, I think that monads could make for some very interesting applications.</p>

<p>In a document-oriented system (say an interactive web-app) written in a language like Haskell (where state is explicitly isolated), state (which would be contained in a set of monads) could be sent to the client with each response. The state could be something like a continuation.</p>

<p>In this sense, one would have a continuation-based system (like <a href="http://seaside.st" rel="nofollow">Seaside</a>), but instead of the state residing on the server, it resides with the client. So all documents (in the web-app) can remain immutable.</p>

<p>Researchers at Cornell have developed a stateless network stack based on this idea. It&#8217;s called &#8220;Trickles&#8221; (<a href="http://www.cs.cornell.edu/~ashieh/trickles/protocol.php" rel="nofollow">http://www.cs.cornell.edu/~ashieh/trickles/protocol.php</a>).</p>

<p>This system will probably be impractical if the client state requires a lot of storage space. Perhaps a way around this problem is a hybrid approach where some state is sent to the client and where new documents are created on the server (using something like PUT) to represent the rest of the client state. </p>

<p>But this is pretty much back to the Seaside model (although given my lack of knowledge of the inner workings of Seaside, I don&#8217;t know whether client state can be reified as a set of documents).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8294</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Wed, 16 Jan 2008 16:35:48 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8294</guid>
		<description>Interesting thoughts there.

Consider MFC document-view architecture also, the lines are blurred somewhat between objects and documents as you describe: there is the undo/redo history (state changes) and the view provides a complete snapshot of state at any one time. However, the document is undeniably an MFC object. I suppose the paradigm is dependent on whether you're a user or a developer, whereas in REST architectures it's the same...</description>
		<content:encoded><![CDATA[<p>Interesting thoughts there.</p>

<p>Consider MFC document-view architecture also, the lines are blurred somewhat between objects and documents as you describe: there is the undo/redo history (state changes) and the view provides a complete snapshot of state at any one time. However, the document is undeniably an MFC object. I suppose the paradigm is dependent on whether you&#8217;re a user or a developer, whereas in REST architectures it&#8217;s the same&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: troels</title>
		<link>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8248</link>
		<dc:creator>troels</dc:creator>
		<pubDate>Wed, 16 Jan 2008 12:00:04 +0000</pubDate>
		<guid>http://blog.ianbicking.org/2008/01/15/documents-vs-objects/#comment-8248</guid>
		<description>"""
A resource should really be a document (content type, some bytes, perhaps a cache
of parsed representations) plus the name (URI) and the time. Resources aren’t
eternal, but given a time and URI there is (in a REST world) a single canonical
representation.
"""

My immediate though in response to this, is that svn (or any other version control system), addresses this issue exactly. You can get a resource, as it is currently (HEAD), or you can retrieve a particular revision (URI+time).

(Btw. you comment system doesn't format as markdown, even though it says so)</description>
		<content:encoded><![CDATA[<p>&#8220;&#8221;"
A resource should really be a document (content type, some bytes, perhaps a cache
of parsed representations) plus the name (URI) and the time. Resources aren’t
eternal, but given a time and URI there is (in a REST world) a single canonical
representation.
&#8220;&#8221;"</p>

<p>My immediate though in response to this, is that svn (or any other version control system), addresses this issue exactly. You can get a resource, as it is currently (HEAD), or you can retrieve a particular revision (URI+time).</p>

<p>(Btw. you comment system doesn&#8217;t format as markdown, even though it says so)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
