<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-33378235</atom:id><lastBuildDate>Wed, 05 May 2010 09:51:52 +0000</lastBuildDate><title>Dynamic Aspects</title><description>experiments in interactive programming</description><link>http://dynamicaspects.org/blog/</link><managingEditor>noreply@blogger.com (Roly Perera)</managingEditor><generator>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-8400770602704439014</guid><pubDate>Mon, 16 Nov 2009 00:18:00 +0000</pubDate><atom:updated>2009-11-16T01:19:39.014Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>interactive programming</category><category domain='http://www.blogger.com/atom/ns#'>functional reactive programming</category><category domain='http://www.blogger.com/atom/ns#'>software visualisation</category><title>Interactive terms and evaluation stores</title><description>Here's the &lt;a href="http://dynamicaspects.org/papers/PADL2010Final.pdf"&gt;final version&lt;/a&gt; of my &lt;a href="http://clip.dia.fi.upm.es/Conferences/PADL-2010/"&gt;PADL&lt;/a&gt; paper.  I've hived off all the technical spec to a separate &lt;a href="ftp://ftp.cs.bham.ac.uk/pub/tech-reports/2009/CSR-09-09.pdf"&gt;technical report&lt;/a&gt;, and devoted the space thereby liberated to a clearer explanation of how it works: interactive terms, lifting and unlifting, value stores, evaluation traces and evaluation stores, reification, memo-reification and synchronisation.  The mutually recursive relationship between reification and synchronisation is one of the things I've tried to clarify.&lt;br /&gt;&lt;br /&gt;I went to &lt;a href="http://sneezy.cs.nott.ac.uk/fplunch/"&gt;FP lunch&lt;/a&gt; at Nottingham on Friday.  The main reason for the trip was to hook up with &lt;a href="http://www.cs.nott.ac.uk/~nhn/"&gt;Henrik&lt;/a&gt;, but I also gave a talk.  For the talk I knocked up some slides that animate the evaluation store for the example programming scenario in the paper, using output generated by my &lt;a href="http://code.google.com/p/interactive-programming/"&gt;F# implementation&lt;/a&gt;.  It's much easier to visualise how the system works this way, so I've included them below.  I've also include a rather crude hand-crafted animation of the mock-up UI from the paper.  As mentioned in the paper, I only allow edits to program constants, which in this setting, means terms built purely out of constructors.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Motivating example&lt;/h3&gt;&lt;a href="http://dynamicaspects.org/papers/MotivatingExample.pdf"&gt;These slides&lt;/a&gt; animate the motivating example from the paper.  The programmer interactively discovers and fixes two bugs in a simple program which compare two lists.  The UI shown is only a mock-up, intended to be representative of what one could build on top of my current system.  &lt;br /&gt;&lt;br /&gt;In the scenario, the programmer takes her program through 5 editing states.  For some states, the slides also show some alternative &lt;ital&gt;view&lt;/ital&gt; configurations.  For example, at state 4, the programmer collapses the recursive call to &lt;code&gt;equal&lt;/code&gt;, once she realises the problem actually lies with the definition of &lt;code&gt;equal_nat&lt;/code&gt;.  This isn't an edit to the program, but just to the view.  Browsing features like this will be essential to a practical implementation of interactive programming, but are orthogonal to the work presented in the paper.&lt;br /&gt;&lt;br /&gt;The following diagram illustrates some of the features of this hypothetical UI; they're not essential to understanding the paper, but are useful for making sense of the mock-ups:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://dynamicaspects.org/papers/explain-UI.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 545px; height: 549px;" src="http://dynamicaspects.org/papers/explain-UI.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Interactive terms&lt;/h3&gt; The &lt;a href="http://dynamicaspects.org/papers/InteractiveTerms.pdf"&gt;second set&lt;/a&gt; of slides show how edits are enabled.  A transformation called &lt;definition&gt;lifting&lt;/definition&gt; replaces constants in the original program by references to store locations initialised to those constants.  (I call this a &lt;definition&gt;value store&lt;/definition&gt;, to distinguish it from an &lt;definition&gt;evaluation store&lt;/definition&gt;, below.)  The result of lifting is called an &lt;definition&gt;interactive term&lt;/definition&gt; (shown on the right), whence we can recover a non-interactive term (on the left) by &lt;definition&gt;unlifting&lt;/definition&gt; at a particular store state.   Edits are modelled by mutations to the value store, and so an interactive term is associated with a family of unliftings, one for each possible state of the value store.  Lifting thus converts a term into a mutable representation, and unlifting does the reverse.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Evaluation stores&lt;/h3&gt; Because the unlifting of an interactive term changes as the value store changes, how it executes may also change.  It can compute a different value; or it can compute the same value, but "for a different reason".  In other words the &lt;ital&gt;intensional&lt;/ital&gt; behaviour of the program can change, even if extensionally it is unchanged.   This behaviour is reified into a mutable representation called an &lt;definition&gt;evaluation store&lt;/definition&gt;.  &lt;a href="http://dynamicaspects.org/papers/EvalStoreAnimation.pdf"&gt;These slides&lt;/a&gt; show the evaluation store evolving through the 5 states of our scenario.  There are two further states which show how fragments of reified evaluation persist and are reused if they arise in subsequent states.  The notation used in the slides is explained in the paper.&lt;br /&gt;&lt;br /&gt;So what next? The main limitation of the current system is that only data values can be changed.  This in turn effectively requires a restriction to a first-order language.  The reason is this.  In an interactive programming system, functions are not purely extensional beasts.  Their intensional behaviour is observable too.  We can't therefore allow modification of functional values without permitting arbitary code modification, since the intensional behaviour of a function is given by its definition.  This doesn't arise in standard FRP systems, which are higher-order, but where functions behave purely extensionally.&lt;br /&gt;&lt;br /&gt;Interestingly, and as &lt;a href="http://www.cs.nott.ac.uk/~txa/"&gt;Thorsten&lt;/a&gt; mentioned, once you permit code changes, you obtain something of a higher-order feel, even in a first-order setting.  So code modification is the key thing I want to enable, from which higher-order functions should naturally follow.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-8400770602704439014?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2009/11/interactive-terms-and-evaluation-stores.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-3865155567536868072</guid><pubDate>Sat, 05 Sep 2009 06:56:00 +0000</pubDate><atom:updated>2009-09-06T22:18:01.449Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>functional debugging</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming</category><category domain='http://www.blogger.com/atom/ns#'>incremental computation</category><category domain='http://www.blogger.com/atom/ns#'>persistence</category><category domain='http://www.blogger.com/atom/ns#'>reactive programming</category><title>The whys and what ifs of programming</title><description>I'm submitting &lt;a href="http://dynamicaspects.org/papers/PADL2010.pdf"&gt;this paper&lt;/a&gt; to &lt;a href="http://clip.dia.fi.upm.es/Conferences/PADL-2010/"&gt;PADL&lt;/a&gt; this coming Friday.  Conveniently, the organisers extended the deadline by a week, so I have a few days to solicit some comments.  It's not as coherent as I would like, but for the first time I've got something approaching an end-to-end story: a problem, a motivating example, a solution (with formal spec), and an implementation.  It's still restricted to a first-order, call-by-value setting, allowing me to side-step the issue of code modification.  (If values can have function type, and values can change, then there's no side-stepping the issue.  Ditto call-by-name, which allows values to have code in them.)  I'm planning to tackle code modification next, and with that in place it should be easy enough to accommodate higher-order functions too.&lt;br /&gt;&lt;br /&gt;I've narrowed my motivation down to focus on an "interactive" style of programming, where the programmer is engaged in an ongoing dialogue with the development environment, and all programming activities, including writing new code, are framed in terms of the programmer &lt;ital&gt;asking questions&lt;/ital&gt; and the development environment &lt;ital&gt;responding&lt;/ital&gt;.  It took me a while to realise that having a narrow motivation is really the only sane methodology.  If there are other applications or benefits (as I think there are) they're best treated separately, else the whole thing gets too unwieldy.  For now it's nice to have a narrow problem to solve and a reasonably simple story to tell.&lt;br /&gt;&lt;br /&gt;There's not much yet in the way of theorems about formal properties of the system.  So far, the formalism is really just serving as a dependently-typed programming language, only one I don't happen to have a compiler for.  Guess I should probably start using &lt;a href="http://wiki.portal.chalmers.se/agda/"&gt;Agda&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;There is some &lt;a href="http://code.google.com/p/interactive-programming/"&gt;source code&lt;/a&gt; though.  I was planning to host it on GitHub, but unfortunately I'm still running on Windows, and Git on Windows looks a bit sketchy.  So I'm using Google Code.  (Annoyingly its source browser doesn't like the apostrophes I've used in my identifiers, so I may think again.)  The code is now in F# instead of Haskell, which will hopefully make experimenting with UI ideas a bit easier.  For now there's no UI, though.&lt;br /&gt;&lt;br /&gt;So: what are the biggest problems with this paper?  I'm glossing lots of important issues, time and space performance being obvious ones, and how to recover something like normal effectful programming.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-3865155567536868072?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2009/09/whys-and-what-ifs-of-programming.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-615101278279688436</guid><pubDate>Thu, 09 Jul 2009 13:05:00 +0000</pubDate><atom:updated>2009-09-06T17:39:16.546Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>self-adjusting computation</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming</category><category domain='http://www.blogger.com/atom/ns#'>incremental computation</category><category domain='http://www.blogger.com/atom/ns#'>related work</category><category domain='http://www.blogger.com/atom/ns#'>persistent computation</category><title>Full vs. partial reification</title><description>&lt;style type="text/css"&gt;.nobr br { display: none }&lt;/style&gt;My research project is called &lt;a href="http://www.cs.bham.ac.uk/~rnp/"&gt;&lt;definition&gt;interactive programming&lt;/definition&gt;&lt;/a&gt;.  The central concepts are (1) &lt;ital&gt;reification&lt;/ital&gt;, where a big-step semantics is taken to characterise a data type, and evaluation to produce instances of this data type; (2) &lt;ital&gt;reactivity&lt;/ital&gt;, the interpretation of a program as a transition system whose states are such instances; and (3) &lt;ital&gt;persistence&lt;/ital&gt;, a means for sharing state across transitions so that common substructure is not duplicated.  Since none of these ideas is particularly novel, I need to be careful in my treatment of related work.&lt;br /&gt;&lt;br /&gt;Reified evaluation arises, in a restricted form, in &lt;a href="http://ttic.uchicago.edu/~umut/papers/"&gt;Umut Acar&lt;/a&gt;'s &lt;definition&gt;self-adjusting computation&lt;/definition&gt;, as well as in debuggers that record execution traces or similar structures.  Reactivity is central to visual programming, spreadsheet languages, functional reactive programming (FRP), and again, self-adjusting computation.  Persistence also arises in self-adjusting computation, as a form of &lt;ital&gt;memoisation&lt;/ital&gt;.  Self-adjusting computation is therefore of special importance: it is the only prior work which combines all three concepts.  What I want to do here is compare Acar's (mature, well-worked out) system with what I'm hoping to do.&lt;br /&gt;&lt;br /&gt;Before I start, I should point the reader to this interim &lt;a href="ftp://ftp.cs.bham.ac.uk/pub/tech-reports/2009/CSR-09-05.pdf"&gt;technical report&lt;/a&gt;.  My report has a number of problems, which I won't attempt to enumerate, and unfortunately it doesn't use the term "reification".  (That was &lt;a href="http://web.cecs.pdx.edu/~harke/"&gt;Tom Harke's&lt;/a&gt; idea.)  It should shed some light on what I mean by a persistent evaluation graph, which is essentially Acar's notion of a "trace".  My notation is intentionally similar to Acar's.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Self-adjusting computation&lt;/h3&gt;&lt;br /&gt;&lt;a href="http://ttic.uchicago.edu/~umut/papers/thesis.html"&gt;&lt;definition&gt;Self-adjusting computation&lt;/definition&gt;&lt;/a&gt; is a language and runtime system for incremental computation.  After an initial evaluation, the inputs of a program can be repeatedly modified, and the resulting changes to the output observed.  During the initial evaluation, the runtime records a &lt;ital&gt;trace&lt;/ital&gt; identifying how parts of the computation depend on other parts.  When an input is modified, the output is re-calculated by a &lt;ital&gt;change propagation&lt;/ital&gt; algorithm, which exploits the information in the trace to perform the update efficiently.  &lt;br /&gt;&lt;br /&gt;Early formulations required the programmer to deal explicitly with much of the technical machinery involved in making a computation self-adjusting.  Although the resulting programs were still much easier to write than hand-coded dynamic algorithms, the approach was difficult and error-prone.&lt;br /&gt;&lt;br /&gt;The most recent version, a self-adjusting extension of Standard ML called &lt;a href="http://ttic.uchicago.edu/~umut/papers/afp08.html"&gt;&amp;Delta;ML&lt;/a&gt;, provides more direct language support.  This brings it closer in concept to interactive programming.  Nevertheless it differs in several important respects, thanks to its focus on incremental performance.  The following discussion is organised around the common features of reification, reactivity and persistence.  The figure show some typical &amp;Delta;ML code.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;structure ModList =&lt;br /&gt;struct&lt;br /&gt;  datatype 'a cell = NIL | CONS of 'a * 'a modlist&lt;br /&gt;  withtype 'a modlist = 'a cell box&lt;br /&gt;  type 'a t = 'a modlist&lt;br /&gt;&lt;br /&gt;  afun lengthLessThan (l: 'a modlist) : bool box =&lt;br /&gt;  let putM = mkPut $ ()&lt;br /&gt;      afun len (i,l) =&lt;br /&gt;        if i &gt;= n then false&lt;br /&gt;        else case get $ l of&lt;br /&gt;               NIL =&gt; true&lt;br /&gt;             | CONS(h,t) =&gt; len $ (i+1,t)&lt;br /&gt;  in putM $ (NONE, len $ (0,l)) end&lt;br /&gt;&lt;br /&gt;  afun map (f: 'a -&gt; 'b) (l: 'a modlist) : 'b modlist =&lt;br /&gt;  let val putM = mkPut $ ()&lt;br /&gt;      mfun m l =&lt;br /&gt;        case get $ l of&lt;br /&gt;          NIL =&gt; NIL&lt;br /&gt;        | CONS(h,t) =&gt; CONS (f h, putM $ (SOME h, m t))&lt;br /&gt;  in putM $ (NONE, m l) end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Reification&lt;/h3&gt;&lt;br /&gt;In both systems, the initial evaluation is reified into a data structure capturing the dependencies between parts of the computation.  &lt;br /&gt;&lt;br /&gt;The key difference seems to be in whether the reification is "full", or only "partial".  In self-adjusting computing, the trace only captures the aspects of evaluation relevant to efficient incremental update.  In interactive programming, the entire evaluation is reified.&lt;br /&gt;&lt;br /&gt;&lt;div class="nobr"&gt;&lt;table border=1 bordercolor=lightgray&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Self-adjusting computation&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Interactive programming&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;The programmer must explicitly identify the &lt;definition&gt;adaptive&lt;/definition&gt; aspects of the computation.  The type constructor &lt;code&gt;box&lt;/code&gt; distinguishes &lt;ital&gt;changable data&lt;/ital&gt;, which may change after the initial evaluation, from &lt;ital&gt;stable&lt;/ital&gt; data, which cannot.  Keywords &lt;code&gt;afun&lt;/code&gt; and &lt;code&gt;mfun&lt;/code&gt; identify &lt;definition&gt;adaptive functions&lt;/definition&gt;, which produce and consume changeable data.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;All data is 'changeable'; all functions are 'adaptive'.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Computations are partly reified into &lt;ital&gt;traces&lt;/ital&gt;.  Traces are data structures which record the dependencies between adaptive parts of the computation, and the code fragments associated with them. &lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Computations are fully reified into &lt;ital&gt;evaluations&lt;/ital&gt;.  Evaluations are data structures "all the way down", recording individual steps of the big-step semantics.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;No direct requirement that traces reflect in any way the derivation tree given by the original semantics, but only that the final computed values are consistent.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Evaluation graph can at any state be unravelled into the derivation tree given by the original semantics.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Runtime interface exports operations for querying and updating changeable data, but not for observing traces.  But trace information could in principle be exported.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Runtime interface exports evaluation graphs as well.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;Reactivity&lt;/h3&gt; In both systems, data can be modified after the initial evaluation, causing the output to be updated.  Synchronisation updates the trace as well as the output, producing a result consistent with an initial evaluation, and leaving the system ready to respond to another input change.  Both implementations are imperative, to allow state to be reused across transitions.  &lt;br /&gt;&lt;br /&gt;The differences seem to follow from the different treatment of traces: partial reification means that self-adjusting computation has an (efficient, but potentially problematic) hybrid execution model.&lt;br /&gt;&lt;br /&gt;&lt;div class="nobr"&gt;&lt;table border=1 bordercolor=lightgray&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Self-adjusting computation&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Interactive programming&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Partial reification means that change propagation must &lt;ital&gt;re-execute&lt;/ital&gt;, rather than merely synchronise, adaptive computations when the modifiables they read have changed.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Full reification of evaluation means no notion of "re-execution".  Synchronisation is the reactive mutation of structure, "all the way down".&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Re-execution interacts poorly with imperative features such as I/O (effects may be duplicated) and memory allocation (effects may differ).  The occurrences of the &lt;code&gt;mkPut&lt;/code&gt; primitive in the figure above are a symptom of the latter problem.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Full reification implies a purely functional treatment of effects: the evaluation can include &lt;i&gt;descriptions of effects&lt;/i&gt;, and these descriptions can be updated by synchronisation.  Invites the question of how interactive programming accommodates "traditional" I/O, such as launching missiles or writing snapshots of execution to a file.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Modification to data values only.  Since &amp;Delta;ML is higher-order, these values may be of function type.  However, functional values are opaque, rather than represented as changable data structures.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Intention is to permit modification to code as well as data, as a separate consideration from higher-order vs. first-order.  Requires programs to have a similar representation to user-defined data types: in Acar's terms, &lt;ital&gt;modifiable code&lt;/ital&gt;, as well as modifiable data.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Functional specification; mutable traces not part of observable behaviour.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Imperative specification; mutable evaluation nodes essential part of observable behaviour.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Imperative, bottom-up implementation, based on priority queue.  No proof that algorithm conforms to functional specification.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Top-down implementation, corresponding closely to imperative specification.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Implementation shown to be optimally efficient for programs which are &lt;definition&gt;monotone&lt;/definition&gt; with respect to a particular class of input changes.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Inefficient.  No performance guarantees.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;Persistence&lt;/h3&gt; In both systems, sub-computations are shared across states by a generalised memoisation facility which stores not just computed values but associated traces.  &lt;br /&gt;&lt;br /&gt;Here, the differences arise because interactive programming makes the identities of evaluation nodes part of the observable structure.  This shifts memoisation from a performance trick, to playing an essential role in the treatment of evaluation graphs as purely functional data structures.&lt;br /&gt;&lt;br /&gt;&lt;div class="nobr"&gt;&lt;table border=1 bordercolor=lightgray&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Self-adjusting computation&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;&lt;i&gt;Interactive programming&lt;/i&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Traces are not exported by runtime interface, so memoisation can only be observed indirectly, as incremental performance.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Evaluations are exported by runtime interface, so memoisation can be observed as an evaluation subgraph shared by adjacent states.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Only adaptive functions can be memoised, not arbitrary terms.  Programmer specifies when adaptive functions are memoised, via keyword &lt;code&gt;mfun&lt;/code&gt;.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Evaluation of every term is memoised, effectively by memoising the &lt;code&gt;eval&lt;/code&gt; function of the interpreter.  Common substructure is therefore always shared by adjacent states; evaluation graph is a &lt;a href="http://en.wikipedia.org/wiki/Purely_functional_data_structure"&gt;purely functional data structure&lt;/a&gt;.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Memoisation only occurs across evaluations, not within a single evaluation.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Memoisation occurs within evaluations too, meaning that common sub-computations are shared.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Essential role of memoisation in performance restricts language to CBV.  Unclear what kind of incremental performance is possible under CBN.&lt;/td&gt;&lt;br /&gt;&lt;td align=left width=200 valign=top bgcolor=lightgray&gt;Not limited to CBV, because performance is disregarded.  Intention is to support CBN.&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The $64,000 question is: can full reification ever be done efficiently?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-615101278279688436?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2009/07/full-vspartial-reification.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-6318079984054494007</guid><pubDate>Sun, 12 Apr 2009 20:26:00 +0000</pubDate><atom:updated>2009-04-14T00:17:53.828Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>interactive programming</category><category domain='http://www.blogger.com/atom/ns#'>fluid AOP</category><title>Sleepless near Seattle</title><description>&lt;iframe width="425" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?daddr=Vancouver,+BC,+Canada&amp;amp;geocode=&amp;amp;dirflg=&amp;amp;saddr=seattle&amp;amp;f=d&amp;amp;sll=49.263588,-123.138565&amp;amp;sspn=0.180805,0.30899&amp;amp;ie=UTF8&amp;amp;ll=48.44228,-122.656505&amp;amp;spn=1.64262,0.96517&amp;amp;output=embed"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;small&gt;&lt;a href="http://maps.google.co.uk/maps?daddr=Vancouver,+BC,+Canada&amp;amp;geocode=&amp;amp;dirflg=&amp;amp;saddr=seattle&amp;amp;f=d&amp;amp;sll=49.263588,-123.138565&amp;amp;sspn=0.180805,0.30899&amp;amp;ie=UTF8&amp;amp;ll=48.44228,-122.656505&amp;amp;spn=1.64262,0.96517&amp;amp;source=embed" style="color:#0000FF;text-align:left"&gt;View Larger Map&lt;/a&gt;&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;I'm off to Vancouver on Sunday to spend five weeks at &lt;a href="http://www.cs.ubc.ca/"&gt;UBC&lt;/a&gt;, thanks to the people at &lt;a href="http://www.universitas21.com/"&gt;Universitas 21&lt;/a&gt;, who were kind enough to part with the required cash.  It'll be a chance to immerse myself a bit in Gregor Kiczales' current thinking on &lt;ital&gt;fluid AOP&lt;/ital&gt;.  I'm banking on fluid AOP being the "killer app" for interactive programming languages.  Every paradigm needs its killer app!&lt;br /&gt;&lt;br /&gt;Unfortunately I'm still miles away from useful applications, but I finally have something to report.  I even have some software that works, almost 800 lines of entirely uninteractive Haskell.&lt;br /&gt;&lt;br /&gt;I'm planning to submit &lt;a href="http://dynamicaspects.org/papers/OnwardSubmission.pdf"&gt;this paper&lt;/a&gt; to &lt;a href="http://onward-conference.org/"&gt;Onward!&lt;/a&gt; at the end of the week.  In terms of technical maturity (or lack of) I feel stranded half-way between "applied" conferences like OOPSLA and more formal ones like &lt;a href="http://www.icfpconference.org/"&gt;ICFP&lt;/a&gt;, so I'm not sure if this is the right forum.  The paper is rather rough in parts, particularly towards the end.  I've also gratuitously ignored the topic of &lt;ital&gt;bidirectionality&lt;/ital&gt;, which is essential to practical interactive programming.  I would welcome comments on which bits are hardest to make sense of.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-6318079984054494007?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2009/04/sleepless-near-seattle.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-4827787990667632256</guid><pubDate>Wed, 18 Feb 2009 00:11:00 +0000</pubDate><atom:updated>2009-02-18T00:38:31.117Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>bidirectional computing</category><category domain='http://www.blogger.com/atom/ns#'>fluid AOP</category><title>The road to effective informality</title><description>...is paved with meta-formalisms.&lt;br /&gt;&lt;br /&gt;A while back (&lt;a href="http://dynamicaspects.org/blog/2006/09/why-syntax-wont-go-away.html"&gt;here&lt;/a&gt; and &lt;a href="http://dynamicaspects.org/blog/2006/11/art-of-science-of-software.html"&gt;here&lt;/a&gt;), I argued that realising so-called &lt;definition&gt;fluid AOP&lt;/definition&gt; will require a more formal approach to real-world languages and tools.  This emphasis on formality seemed to be at odds with Gregor Kiczales' &lt;a href="http://www.cs.ubc.ca/~gregor/talks.html"&gt;recent advocation&lt;/a&gt; of a &lt;i&gt;less&lt;/i&gt; formal approach to software.  Gregor's goal seemed reasonable; it was the methodology which perturbed me a little.&lt;br /&gt;&lt;br /&gt;Having had several months to digest Gregor's response to my blog post, I can see now that most of the apparent incompatibility between our claims goes away if we construe them at the appropriate meta-level.  In particular if we distinguish the &lt;ital&gt;content&lt;/ital&gt; of a view from the &lt;ital&gt;computation of that content&lt;/ital&gt;, we can see that informality as a (first-order) goal is in no way incompatible with identifying formality as a (second-order) means to that goal.  One potential source of confusion, as Matt Hellige noted, is that this second-order formality can itself be viewed in both formal and informal ways.  Nothing a programmer can't handle, though.  First a recap.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Fluid AOP&lt;/h3&gt; As I touched on in my &lt;a href="http://dynamicaspects.org/blog/2008/11/many-dimensions-of-modularity.html"&gt;last post&lt;/a&gt;, fluid AOP frees the programmer from having to work with a single canonical view of a program, instead providing a variety of dynamically generated views, allowing her to use the view most suited to the task at hand.  Changes made to these views are "put back" to a persistent representation called the &lt;definition&gt;primary decomposition&lt;/definition&gt;.  Fluid AOP, at least in any kind of generality, is largely vapourware, a great idea waiting for the enabling technology which renders it feasible.&lt;br /&gt;&lt;br /&gt;Viewing the same thing in multiple ways is what we already do, in a language such as Java, when we have a class implement multiple interfaces.  But with fluid AOP, these static facts about program organisation are no longer absolute, instead being relativised to particular views.  Some organisational characteristics will made salient by a particular view, others will not.  Abstractions become ephemeral things, visualised or made explicit when they are needed, remaining &lt;definition&gt;latent&lt;/definition&gt; (Gregor's word) the rest of the time.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;First-order informality&lt;/h3&gt; The big challenge facing fluid AOP is making these flexible views &lt;a href="http://www.cs.ubc.ca/~kdvolder/binaries/Janzen_DeVolder_ECOOP2004.pdf"&gt;effective&lt;/a&gt;.  Effective means bidirectional, so that the view can mediate changes to the underlying model ("view" and "model" to be understood relatively).  Effectiveness is trivial if we work directly with the primary decomposition, but becomes arbitrarily non-trivial as we work with increasingly abstract views.  The more information the view abstracts away, the harder it is - all other things being equal - to usefully interpret a change to the view as a change to the model.  The kind of "informal" or fuzzy views that Gregor discussed in his OOPSLA talk are simply ones where the view disregards a large amount of information.&lt;br /&gt;&lt;br /&gt;We can't expect any magic resolution to the tension between effectiveness and abstraction, of course, but what we can hope for, as both Gregor and Matt suggested, is more &lt;ital&gt;access to the trade-off&lt;/ital&gt;, so that the situation becomes "parametric", rather than "binary", as Gregor put it.  We would like the difficulty of achieving bidirectionality to be broadly correlated with the gain in abstraction.  If we're not interested in abstraction or informality, we might be able to obtain automatic or near-automatic effectiveness; if we don't care about effectiveness, we may be able to make (limited) use of some very abstract or informal views.  We might even be able to achieve both, if we're prepared to settle for a part-manual, part-automated process.&lt;br /&gt;&lt;br /&gt;(A quick aside: bidirectional views have been studied since at least the '80s.  The so-called &lt;a href="http://doi.acm.org/10.1145/319628.319634"&gt;"constant complement"&lt;/a&gt; approach to relational views involves defining a "complement" of a view, which determines how view changes are put back to the underlying tables.  There can be multiple complements of a given view, each such complement defining a particular put-back policy.  More recent developments include Foster, Pierce &lt;i&gt;et al&lt;/i&gt;'s work on the bidirectional language &lt;a href="http://doi.acm.org/10.1145/1328438.1328487 "&gt;Boomerang&lt;/a&gt;, and &lt;a href="http://www.comlab.ox.ac.uk/files/711/Bidi.pdf"&gt;this paper&lt;/a&gt; by Wang and Gibbons on bidirectional transformations between algebraic data types.)&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Second-order formality&lt;/h3&gt; But how to obtain practical access to the effectiveness vs. informality trade-off?  I think we have little choice but to take a more formal (but ultimately simpler) approach to computing.  I'm not talking about the formality of the views themselves, but of the mechanism used to &lt;ital&gt;compute&lt;/ital&gt; the views.  With a caveat (which I'll come to), we will need much more of this "second-order" formality if we are to have any hope of making progress on the bidirectionality issue.  Backward computation is forward computation made a lot harder, and so to succeed at the former will require a non-ad-hoc solution to the latter.  Trying to make the jump to "informal" computing without getting "formal" computing right is like trying to make the jump to lightspeed on a tricycle.&lt;br /&gt;&lt;br /&gt;Once again I'm out of time, so I will have to defer the discussion of how our current approach is ad hoc to my next post.  But it should at least be clear that my claim that we need &lt;ital&gt;more formality&lt;/ital&gt;, and Gregor's that we need &lt;ital&gt;less&lt;/ital&gt;, are not really incompatible; we're simply talking about different meta-levels.&lt;br /&gt;&lt;br /&gt;The caveat is just the point made by Matt Hellige that I mentioned in the introduction.  The higher-order formality that I suggest should characterise the relationship between model and view will itself ultimately be viewable in various ways, some formal, some informal.  Once we &lt;i&gt;have&lt;/i&gt; fluid languages, we'll be able to use them to &lt;i&gt;implement&lt;/i&gt; fluid languages, and that's where the fun begins.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-4827787990667632256?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2009/02/road-to-effective-informality.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-5902073551513883930</guid><pubDate>Sun, 02 Nov 2008 20:02:00 +0000</pubDate><atom:updated>2009-07-07T11:51:02.932Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Expression Problem</category><category domain='http://www.blogger.com/atom/ns#'>modularity</category><category domain='http://www.blogger.com/atom/ns#'>fluid AOP</category><category domain='http://www.blogger.com/atom/ns#'>meta-programming</category><title>Modularity in many dimensions</title><description>I recently read Doug Janzen and Kris De Volder's paper &lt;a href="http://www.cs.ubc.ca/~kdvolder/binaries/Janzen_DeVolder_ECOOP2004.pdf"&gt;Programming with Crosscutting Effective Views&lt;/a&gt;.  I grok a little more clearly now what Gregor Kiczales meant by the word "effective" in the OOPSLA 2007 talk I discussed in my &lt;a href="http://dynamicaspects.org/blog/2006/11/art-of-science-of-software.html"&gt;last post&lt;/a&gt;.  In Janzen and De Volder's terms, a view is &lt;definition&gt;effective&lt;/definition&gt; when it can mediate changes to the underlying model.  The problem of making a view effective, sometimes called the problem of &lt;ital&gt;bidirectionality&lt;/ital&gt;, is a tricky one, but won't concern us here.  Instead I'm going to talk about what Kiczales and others call &lt;a href="http://doi.acm.org/10.1145/1176617.1176687"&gt;&lt;definition&gt;fluid AOP&lt;/definition&gt;&lt;/a&gt;, for which effective views are essential.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;One program, many faces&lt;/h3&gt;Aspect-oriented programming (AOP) is the latest development in our ongoing battle with the problem of &lt;ital&gt;modularity&lt;/ital&gt;.  But although AOP, in its standard form, represents a useful step forward, it ultimately succumbs to the very problem it sets out to address: the fact that that some aspects or features of a system cross-cut others.  By rearchitecting an OO system into a set of aspect declarations, one often merely inverts the modularity problem, distributing the behaviour of the original classes over the implementation of various aspects.  What would previously have been a localised change to the class structure may now involve a change to several aspects.&lt;br /&gt;&lt;br /&gt;Fluid AOP addresses this issue by taking a much less static view of programs.  The idea is to treat aspects as editable -- "effective" -- views which are generated on demand for particular coding activities.  For persistence purposes, one view is nominated as the "primary decomposition".  (With a legacy language this may just be the regular source view, but in principle the primary decomposition can be any view that suffices to determine all the others.)  Making these views effective is where bidirectionality comes in: each view must define how edits are "put back" as edits to the primary decomposition.&lt;br /&gt;&lt;br /&gt;Before we come to fluid AOP, I want to revisit its motivation, and in particular the modularity challenge which is sometimes called &lt;a href="http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt"&gt;&lt;definition&gt;The Expression Problem&lt;/definition&gt;&lt;/a&gt;.  My claim will be that, although some languages may be able to solve the Expression Problem, the more general modularity problem requires more than just fancy language features.  Some kind of "fluidity", it seems, is essential.  I'll close by suggesting that fluidity be understood in &lt;ital&gt;meta-linguistic&lt;/ital&gt; terms: views must be seen as syntax, and inspection and manipulation of views as a form of meta-programming, often refactoring.  "Effectiveness" (bidirectionality) is a challenge that needs to be tackled within this framework.&lt;br /&gt;&lt;br /&gt;But I'm getting ahead of myself.  Let's start with modularity.  I'll understand modularity to mean, roughly, the extent to which a change to or extension of functionality requires only local changes.  I want to make the case that the pursuit of "absolute" modularity is doomed: that we must always ask "modularity with respect to what kind of change?"  In effect the question "how modular is my software?" is one that should be qualified by a class of transformation.  If you're already familiar with the Expression Problem, you can skip the next section.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Modularity with respect to what?&lt;/h3&gt;Imagine we're writing an interpreter in, say, Java, for a simple language for integer arithmetic.  We crank out the usual OO class hierarchy:&lt;br /&gt;&lt;pre name="code" class="java"&gt;abstract class SyntaxNode {&lt;br /&gt;    public abstract int eval ();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Add extends SyntaxNode {&lt;br /&gt;    public SyntaxNode left, right;&lt;br /&gt;&lt;br /&gt;    public int eval () {&lt;br /&gt;        return left.eval() + right.eval();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class IntegerLiteral extends SyntaxNode {&lt;br /&gt;    public int val;&lt;br /&gt;&lt;br /&gt;    public int eval () {&lt;br /&gt;        return val;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;(Don't worry about the fact that the fields are public; that's just me being lazy.)&lt;br /&gt;&lt;br /&gt;We can make the observation here that &lt;ital&gt;adding a new kind of node&lt;/ital&gt; involves only local changes: we just add a new node class and implement &lt;code&gt;eval&lt;/code&gt;:&lt;br /&gt;&lt;pre name="code" class="java"&gt;class Multiply extends SyntaxNode {&lt;br /&gt;    public SyntaxNode left, right;&lt;br /&gt;&lt;br /&gt;    public int eval () {&lt;br /&gt;        return left.eval() * right.eval();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;What we have identified is a &lt;ital&gt;modularity&lt;/ital&gt; property: &lt;i&gt;modularity with respect to the addition of new node types&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Now let's consider a different kind of change.  Instead of a new kind of node, we want to provide a new kind of operation on nodes, say a &lt;code&gt;toString&lt;/code&gt; method.  One might be tempted to add the following code to the &lt;code&gt;SyntaxNode&lt;/code&gt; class:&lt;br /&gt;&lt;pre name="code" class="java"&gt;public final String toString () {&lt;br /&gt;    if (this instanceof IntegerLiteral) {&lt;br /&gt;        IntegerLiteral op = (IntegerLiteral)this;&lt;br /&gt;        return op.val;&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;    if (this instanceof Add) {&lt;br /&gt;        Add op = (Add)this;&lt;br /&gt;        return op.left.toString() + " + " + op.right.toString();&lt;br /&gt;    }&lt;br /&gt;    else&lt;br /&gt;        throw new AbstractMethodError();&lt;br /&gt;}&lt;/pre&gt;The problem with this approach, as we all know from standard OO doctrine, is that our über-method has to know about every kind of syntax node; in particular if we want to add a new kind of syntax node, we need to update this method as well to add a new clause:&lt;br /&gt;&lt;pre name="code" class="java"&gt;    ...&lt;br /&gt;    if (this instanceof Multiply) {&lt;br /&gt;        Multiply op = (Multiply)this;&lt;br /&gt;        return op.left.toString() + " * " + op.right.toString();&lt;br /&gt;    }&lt;br /&gt;    ...&lt;br /&gt;&lt;/pre&gt;So what we don't like about this approach is that it &lt;i&gt;violates&lt;/i&gt; modularity with respect to the addition of new node types.&lt;br /&gt;&lt;br /&gt;In a functional language like Haskell this particular kind of modularity failure isn't considered bad; in fact it's normal!  Our class hierarchy would correspond to an algebraic data type:&lt;br /&gt;&lt;pre&gt;data SyntaxNode =&lt;br /&gt;    Add SyntaxNode SyntaxNode |&lt;br /&gt;    IntegerLiteral Int&lt;br /&gt;&lt;/pre&gt;All our functions would start with a case analysis, the functional counterpart of a type switch:&lt;br /&gt;&lt;pre&gt;eval :: SyntaxNode -&gt; Int&lt;br /&gt;eval x = case x of&lt;br /&gt;    Add a b -&gt; eval a + eval b&lt;br /&gt;    IntegerLiteral n -&gt; n&lt;br /&gt;&lt;br /&gt;toString :: SyntaxNode -&gt; String&lt;br /&gt;toString x = case x of&lt;br /&gt;    IntegerLiteral n -&gt; show n&lt;br /&gt;    Add a b -&gt; toString a ++ "+" ++ toString b&lt;/pre&gt;and adding a new kind of node would require modifying every function to add the corresponding clause.&lt;br /&gt;&lt;br /&gt;But returning to the world of OO, the "right" way to define &lt;code&gt;toString&lt;/code&gt; is as follows:&lt;br /&gt;&lt;pre name="code" class="java"&gt;class SyntaxNode {&lt;br /&gt;    ...&lt;br /&gt;    public abstract String toString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Add {&lt;br /&gt;    ...&lt;br /&gt;    public String toString () {&lt;br /&gt;        return left.toString() + " + " + right.toString();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;This allows us to maintain modularity with respect to the addition of new node types.  As before, we need only define a new class and provide an implementation of the various abstract methods:&lt;br /&gt;&lt;pre name="code" class="java"&gt;class Multiply extends SyntaxNode {&lt;br /&gt;    public SyntaxNode left, right;&lt;br /&gt;&lt;br /&gt;    public int eval () {&lt;br /&gt;        return left.eval() * right.eval();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public String toString () {&lt;br /&gt;        return left.toString() + " * " + right.toString();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;But clearly this kind of modularity actually came at the expense of modularity of a different kind.  To make it easy to add node types, we had to spread our &lt;code&gt;toString&lt;/code&gt; implementation across the class hierarchy.  In other words adding new operations entails modifying each class; the design thus lacks &lt;i&gt;modularity with respect to the addition of new node operations&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;FPers usually inhabit the other corner of the trade-off space: they enjoy modularity with respect to new operations, but not with respect to new node types.  Although we could probably achieve a similar inversion of modularity in Haskell:&lt;br /&gt;&lt;pre&gt;class SyntaxNode a where&lt;br /&gt;    eval :: a -&gt; Int&lt;br /&gt;    toString :: a -&gt; String&lt;br /&gt;&lt;br /&gt;data IntegerLiteral = IntegerLiteral Int&lt;br /&gt;instance SyntaxNode IntegerLiteral where&lt;br /&gt;    eval (IntegerLiteral n) = n&lt;br /&gt;    toString (IntegerLiteral n) = show n&lt;br /&gt;&lt;br /&gt;data SyntaxNode a =&gt; Add a = Add a a&lt;br /&gt;instance SyntaxNode a =&gt; SyntaxNode (Add a) where&lt;br /&gt;    eval (Add a b) = eval a + eval b&lt;br /&gt;    toString (Add a b) = toString a ++ "+" ++ toString b&lt;br /&gt;&lt;br /&gt;data SyntaxNode a =&gt; Multiply a = Multiply a a&lt;br /&gt;instance SyntaxNode a =&gt; SyntaxNode (Multiply a) where&lt;br /&gt;    eval (Multiply a b) = eval a * eval b&lt;br /&gt;    toString (Multiply a b) = toString a ++ "*" ++ toString b&lt;/pre&gt;In either paradigm, it seems that we're torn between operations cross-cutting data types, and data types cross-cutting operations (although OO prefers the former, and FP the latter).  Which of these two alternatives is the "more modular" simply depends on whether it's operations, or data types, that we intend to modify.  That's not to say that whether a design is modular is a mere matter of taste or opinion, but just that modularity is relative to what you're trying to do.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The multi-dimensional modularity problem&lt;/h3&gt;It's tempting to look for a "linguistic" solution to this problem.  Perhaps with the right language feature (or the right design pattern), it would be possible to make a program modular with respect to both kinds of transformation simultaneously.  Some time ago Philip Wadler dubbed this challenge the &lt;a href="http://homepages.inf.ed. ac.uk/wadler/papers/expression/expression.txt"&gt;&lt;ital&gt;Expression Problem&lt;/ital&gt;&lt;/a&gt;.  (Although discussion of the problem itself goes back further: see for example &lt;a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_%_sec_2.4.3"&gt;this chapter&lt;/a&gt; of SICP.  Thanks &lt;a href="http://www.untyped.com/about/noel.php"&gt;Noel&lt;/a&gt;!)  CLOS-style multi-methods are one linguistic approach to this problem; design patterns such as &lt;a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.24.2629"&gt;&lt;definition&gt;Extensible Visitor&lt;/definition&gt;&lt;/a&gt; are another.&lt;br /&gt;&lt;br /&gt;But although there certainly are linguistic approaches to the Expression Problem, there is usually a cost in terms of design-time &lt;a href="http://en.wikipedia.org/wiki/Cohesion_(computer_science)"&gt;&lt;definition&gt;cohesion&lt;/definition&gt;&lt;/a&gt;.  Multi-methods and similar approaches work precisely by making programs &lt;i&gt;more&lt;/i&gt; granular (less cohesive), and then relying on a &lt;ital&gt;dispatch&lt;/ital&gt; mechanism to compose the fragments (restore cohesion) at run-time.  The point of the granularity is precisely to achieve modularity: behaviour can often be added or modified by just dropping in a new code fragment.  But the loss of any unified view of individual features or behaviours means the programmer has to mentally execute the composition rules in order to know what will happen when the program runs.  And the cohesion problem only gets worse when you try to generalise these approaches to multiple dimensions of composition.&lt;br /&gt;&lt;br /&gt;Standard "static" AOP is not really a response to the Expression Problem but to this more general problem of multi-dimensional composition.  It avoids the granularity problem associated with multi-methods and similar approaches by allowing us to specify aspects as cohesive design-time modules.  But the very cohesion of these definitions means that they are inevitably cross-cut by other features of the system.  These features can now only be understood by reasoning about how the aspects are woven into them.  The benefit of increased modularity in some respects has, as with our interpreter example earlier, been bought at the price of reduced modularity in others.&lt;br /&gt;&lt;br /&gt;The basic problem is that there is no static language feature that can universally resolve the tension between modularity and cohesion.  What we really need is greater &lt;ital&gt;fluidity&lt;/ital&gt;.  Since no design can anticipate its evolution, the capacity to "remodularise" a program quickly is much more valuable than any particular contingent modularity property.  Our programming tools should allow us to &lt;i&gt;eliminate&lt;/i&gt; degrees of freedom which we no longer wish to exploit (so they don't distract us from the task at hand), and &lt;i&gt;introduce&lt;/i&gt;, in their place, the degrees of freedom required to achieve that task, safely and easily.  This is the promise of tool-based approaches such as fluid AOP: "just-in-time cohesion".&lt;br /&gt;&lt;br /&gt;Cohesion-on-demand turns weaving and unweaving into a &lt;i&gt;browsing&lt;/i&gt; activity.  The programmer no longer has to reason about complex composition rules &lt;i&gt;à la&lt;/i&gt; multi-methods or static aspects, as she can simply inspect the content of the relevant view.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Where fluid tools become fluid languages&lt;/h3&gt;So it seems like fluid AOP is the only plausible approach to the problem of multi-dimensional modularity.  It's hugely exciting, but also rather daunting when one thinks about what's involved in making the vision a practical reality.  The words "indistinguishable" and "magic" come to mind.  I'm well out of time and space resources, so I'll wrap up for now by just sketching what I see as the way forward.&lt;br /&gt;&lt;br /&gt;Shortcomings aside, linguistic approaches have one indispensible property: they offer well-defined semantics for multi-dimensional composition.  (As an example, see &lt;a href="http://dx.doi.org/10.1109/SEFM.2007.5"&gt;this paper&lt;/a&gt;, which extends Hindley-Milner type inference with static advice weaving.)  The future of fluid AOP lies I think in harnessing this linguistic precision in an interactive tool.&lt;br /&gt;&lt;br /&gt;After all, if we hope to rely on "fluid aspect" views to visualise key features of our software, as well as mediate critical changes to it, then they really are "the source files of the future".  How the contents of the various views are combined, how edits are put back, and so forth, will have to be precisely defined.  In turn, this will require fluid aspects to have well-defined syntax.&lt;br /&gt;&lt;br /&gt;Indeed the difference between fluid aspects and traditional syntax trees is not one of kind, but only of lifecycle: they are built on the fly in response to the user's changing goals, and may co-exist with other effective views that share the same underlying model.  But otherwise they are just plain ol' syntax.  We see a taste of this in the "virtual source files" of Janzen and De Volder, as well as in the "fluid source code views" of &lt;a href="http://www.cs.uvic.ca/~chisel/pubs/desmond.pdf"&gt;Desmond &lt;i&gt;et al&lt;/i&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;(Of course I don't mean that we should necessarily store such syntactic artifacts in text files, or present them to users as flat, uninterpreted text; but in an uncontroversial sense they are "just syntax".  This was the point of my post &lt;a href="http://dynamicaspects.org/blog/2006/09/why-syntax-wont-go-away.html"&gt;Why syntax won't go away&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;A corollary of this perspective is that we must regard our interactions with these views as a form of &lt;ital&gt;meta-programming&lt;/ital&gt;.  Matt Hellige expressed the same idea when he suggested that we think of &lt;a href="http://matt.immute.net/content/subtext-etc"&gt;"programming-time" as a computational stage&lt;/a&gt;.  To interact is to effect a syntactic transformation.  Switching to a new view of a program is really just a refactoring.&lt;br /&gt;&lt;br /&gt;A mature AOP, then, is not a static language feature as such, but an &lt;ital&gt;interactive meta-programming activity&lt;/ital&gt;: the process of refactoring a program into a view that provides a single locus of change for the edit you want to apply.  Refactoring back to the original view distributes ("puts back") your change into all the relevant places.  We could for example implement the &lt;code&gt;toString&lt;/code&gt; method we defined earlier as a single type switch, for convenience; expand it over a class hierarchy, in order to add a new node type like &lt;code&gt;Multiply&lt;/code&gt;; collapse it back to a single method again, perhaps to modify its signature; expand it again, to add more node types; and so on.&lt;br /&gt;&lt;br /&gt;The toggling, in this hypothetical scenario, between two different points in modularity space is little more than the iterated application of the refactoring &lt;ital&gt;Inline method&lt;/ital&gt; and its inverse.  For an overriding method, &lt;i&gt;Inline method&lt;/i&gt; injects the body of the method to be inlined into a new clause of a type switch in the overridden method.  There are really just two syntactic presentations of the "same" system here, and a function that computes one view from the other, that happens to be able to compute backwards as well as forwards.  (Ok, ok: maybe there's just an incey, wincey little bit of work to do to distinguish this from magic.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-5902073551513883930?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2008/11/many-dimensions-of-modularity.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-116247353499029210</guid><pubDate>Mon, 07 Jan 2008 18:45:00 +0000</pubDate><atom:updated>2008-03-21T10:08:04.475Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>semantic computing</category><category domain='http://www.blogger.com/atom/ns#'>interactive computation</category><category domain='http://www.blogger.com/atom/ns#'>philosophy of science</category><category domain='http://www.blogger.com/atom/ns#'>superfluid AOP</category><title>The art of the science of software</title><description>Gregor Kiczales gave one of the keynotes at last year's &lt;a href="http://www.oopsla.org/oopsla2007/index.php?page=sub/&amp;id=265"&gt;OOPSLA&lt;/a&gt; (&lt;a href="http://www.cs.ubc.ca/%7Egregor/papers/kiczales-oopsla-07-for-viewing.pdf"&gt;slides&lt;/a&gt; and &lt;a href="http://www.oopsla.org/podcasts/Keynote_GregorKiczales.mp3"&gt;audio&lt;/a&gt;).  The abstract was promising, and it sounds like the talk was well received.  Nonetheless, I think Kiczales is off target.  But as the talk has a number of important themes running through it, and the subject matter is extremely pertinent to my own research interests, I will attempt some course correction, rather than just pick holes.  As with my &lt;a href="http://dynamicaspects.com/blog/2006/09/why-syntax-wont-go-away.html"&gt;last post&lt;/a&gt;, I intend these remarks as friendly constructive criticism.  The talk was in the exploratory spirit, after all, and it deserves a response in the same spirit.  Unfortunately the various strands of the talk are woven together in ways that are both confusing, and confused.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Pluralism in software, pluralism in science&lt;/h3&gt;Kiczales' central observation is this: software abstractions are &lt;ital&gt;transient&lt;/ital&gt; beasts, subservient to our equally transient purposes.  Abstractions in a sense represent &lt;ital&gt;points of view&lt;/ital&gt;, and thus flex and mutate as we shift our perspective.  Philosophers sometimes call this kind of "perspective-friendly" meta-perspective &lt;definition&gt;pluralism&lt;/definition&gt;.  Pluralism acknowledges that there can be a plurality of distinct descriptions of a system - perhaps with radically different ontologies - without requiring that at most one of these descriptions is "correct".  Put like this, pluralism sounds like plain common sense.  And it seems inevitable that one day our languages and tools will reflect this pluralism.  What's less clear of course is how painful the journey will be.&lt;br /&gt;&lt;br /&gt;Kiczales also makes the interesting point that the shift towards perspectivalism in software in many respects mirrors a similar shift in how we think about natural systems.  (At one point he asks the audience, leadingly, whether anyone believes in "scientific objectivity".)  Here it seems that Kiczales has been heavily influenced by Brian Smith's book &lt;a href="http://www.amazon.co.uk/Origin-Objects-Paper-Bradford-Book/dp/0262692090/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1196719713&amp;sr=8-1"&gt;On the Origin of Objects&lt;/a&gt;.  Smith was in the office next door to Kiczales for several years, and some of his ideas seem to have cross-pollinated.  I'll come back to Smith's book shortly.  But first let's consider this analogy between software systems and natural systems.  (I apologise for the brief philosophical digression, but I think it's one of the threads of the talk which hits on an important point.)&lt;br /&gt;&lt;br /&gt;Twentieth-century philosophy of science, certainly since the decline of &lt;a href="http://en.wikipedia.org/wiki/Logical_empiricism"&gt;logical empiricism&lt;/a&gt;, was dominated by various flavours of a metaphysical position called &lt;definition&gt;realism&lt;/definition&gt;.  The basic supposition of realism is that there exist theory-independent facts about the macroscopic organisation of the physical world, and that these facts determine whether a given successful theory is &lt;ital&gt;really true&lt;/ital&gt;, or "merely" capable of accounting for all the empirical data one could, in principle, obtain.  A realist might, for example, claim that there is an &lt;i&gt;objective fact&lt;/i&gt; about exactly how many hairs there are on my head, and that this fact exists independently of - is ontologically prior to - any particular theory of what hairs are, or indeed what heads are, or what it is for a hair to be attached to a head.  Some such commitment to an objective, theory-independent, "natural kind" ontology - what Nelson Goodman famously called a &lt;a href="http://books.google.com/books?id=Y5aMV3EE6WcC&amp;pg=PA94&amp;lpg=PA94&amp;dq=nelson+goodman+%22ready+made+world%22&amp;source=web&amp;ots=VT3aybBe7X&amp;sig=5eDCtwceixkHsarnNZBC2DFfbK4"&gt;"ready-made world"&lt;/a&gt; - is the cornerstone of any realist world-view.&lt;br /&gt;&lt;br /&gt;What's wrong with the realist picture is that there is something smelly about the idea of a fact which is &lt;i&gt;in principle&lt;/i&gt; beyond the reach of empirical science.  Scientific theories typically "parse" low-level ontologies into higher-level ontologies; these macro-ontologies are really nothing more than patterns swirling in the low-level structure, and the "truth", or otherwise, of such theories is, in scientific terms, fully exhausted by the empirical success of that theory.  From science's point of view, "molecules" are just patterns in the quantum-mechanical substrate (or whatever) which satisfy a certain behavioural or structural description, and the extent to which the theory of molecules is more (or less) objectively true than any other theory is just the extent to which that theory successfully (or unsuccessfully) systematises the phenomena.  There are no further scientific facts - no "trans-empirical" facts - which determine which theory is "the one true theory".  &lt;br /&gt;&lt;br /&gt;I can't hope to have done justice to this topic in that one paragraph, even if I knew enough about the subject to give it proper treatment (and I don't).  But my aim here is only to concede to Kiczales and Smith what I think is fair concession: that any plausible alternative to realism must be pluralistic.  It must allow for there to be multiple descriptions of the same natural system - perhaps with radically differing ontologies - without imposing the requirement that at most one of them is "correct".  A theory of quantum gravity, if we ever find one, will not reveal General Relativity to have been "false" - but mysteriously successful - all along.  It will just be a better theory.&lt;br /&gt;&lt;br /&gt;So let us grant the point that realism is a metaphysical red herring.  And I think we can also agree that the analogy with what's wrong with our traditional conception of software is compelling.  We tend to think of there as being a unique objective fact about what a piece of sofware "does" - a unique theory of its behaviour.  Our awareness of the existence of some underlying &lt;i&gt;source code&lt;/i&gt; tends to fuel this intuition.  But really we need to be much more pluralistic, and accept that what a piece of software "does" inescapably depends on your point of view.  A security engineer might have a completely different view of a system than an end user.  Each end user probably has a different view than other users, in as much as she can't see what other users are doing.  Reports or audits produced for management are really nothing more than abstractions of how the system behaves.  Even a bug-fix, without too much of a stretch of the imagination, is just a view of an erroneous program that applies a correcting delta to its behaviour.  And many of these views and perspectives aren't just design-time artifacts, but are live perspectives on a running program.  This pluralistic way of thinking about software is even more dynamic and fluid than &lt;a href="http://www.manageability.org/blog/archive/20030507%23conquering_aspects_with_caesarj"&gt;fluid AOP&lt;/a&gt;: let's call it &lt;definition&gt;superfluid AOP&lt;/definition&gt;.&lt;br /&gt;&lt;br /&gt;An exciting possibility, then, is that fixing our philosophy of the natural world and learning how to think properly about software might end up dovetailing rather nicely.  God's not a mathematician, he's a programmer, right?&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Deconvolve this&lt;/h3&gt;So far so good.  But where Kiczales' talk goes awry is in its leap from pluralism, to the ushering in of a new era of "formality-free computing".  In this fluffy new future, we will sit around engaging in &lt;definition&gt;social negotiation&lt;/definition&gt; and &lt;definition&gt;situated action&lt;/definition&gt;, interactions which will somehow manage not to be "formal all the way down".  Unfortunately, these are just Smith's bad memes at play.  I guess I can see how the kind of pluralism just discussed might be innocently mistaken for post-modernism of the sort offered by Smith in his cryptic book, but it's a serious mistake.  All I know is that if there is a place for post-modernist, lit-crit, social constructivist thinking in the modern world, it's nowhere near the field of computing.&lt;br /&gt;&lt;br /&gt;The following excerpt from the Amazon "review" of Smith's book (presumably written by his publisher) captures the sickly flavour of Smith's vision:&lt;blockquote&gt;Critics of programming practice have compared it to alchemy and Smith recalls the characterisation of Newton as the last of the magicians. Is this a pre-Newtonian phase, lacking "Laws", awaiting the differential calculus? Another position is suggested:&lt;br /&gt;&lt;br /&gt;"... that we are post-Newtonian, in the sense of being inappropriately wedded to a particular reductionist form of scientism, inapplicable to so rich an intentional phenomenon. Another generation of scientists may be the last thing we need. Maybe, instead, we need a new generation of magicians". [p362]&lt;br /&gt;&lt;br /&gt;Magician? Magus? Seeking the secret of how it is we "deconvolve the deixis" - plus ça change, plus c'est la même chose. The Alchemist: not a charlatan, but one possessed of much empirical wisdom stumbling after the scheme of things; as this new Science of the Artificial must do, self constructed, self referential, post-post-modern, a metaphysics for the 21st century.&lt;/blockquote&gt;I'm sorry, what??  When exactly did Gary Gygax get together with Jacques Derrida?  It's somewhere between uninformative and downright misleading to attach significance to the idea that software is &lt;i&gt;intentional&lt;/i&gt; (in the philosophical sense originally popularised by &lt;a href="http://www.amazon.co.uk/Intentional-Stance-Daniel-C-Dennett/dp/0262540533/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1197555319&amp;sr=8-1"&gt;Dennett&lt;/a&gt;, and somewhat misappropriated by Smith).  We can, too, skip gaily past Smith's notions of &lt;definition&gt;registration&lt;/definition&gt; and &lt;definition&gt;zest&lt;/definition&gt; with no fear that we're missing any useful insights.  Like it or not, the bedrock of computing is the scientific world view, and Smith's anti-scientistic stance and vaguely Continental-style philosophy are about as compatible with this world view as creationism.  Indeed, with the situation arguably inverting - and computation gradually becoming the conceptual foundation upon which science is built - it is even more important that we keep computing free of this kind of pretentious twaddle.  It matters too much.&lt;br /&gt;&lt;br /&gt;And while it may be true that interfaces are, unsurprisingly, often &lt;i&gt;socially negotiated&lt;/i&gt;, we must be careful what we infer from this.  So is the spelling of identifiers, the pattern of whitespace in a source file, the arrangement of plant pots in an office, after all.  What we must cleanly demarcate are the &lt;i&gt;forces that define&lt;/i&gt; a particular technical problem, and &lt;i&gt;any particular solution&lt;/i&gt; to that problem.  The problem that Kiczales has quite rightly identified is just this: &lt;i&gt;abstractions are essentially dynamic and context-sensitive&lt;/i&gt;.  There is no unique "correct" ontology for any man-made system, any more than there is a unique correct theory of any natural system.  And one of the key forces that happens to drive this dynamism and context-sensitivity - but only one among many - is social interaction.  ("One man's constant is another man's variable", as Alan Perlis nicely &lt;a href="http://portal.acm.org/citation.cfm?doid=947955.1083808"&gt;put it&lt;/a&gt;.)  But it is a mistake to think that any observations about computing as a social activity offer insight into potential solutions to this problem.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Formality all the way down&lt;/h3&gt;This leads us to the final Smithesque strand we need to extract from Kiczales' talk and lay to one side.  We are all familiar with the observation that simple interactions between parts often give rise to "emergent" phenomena, behaviours that are somehow novel or surprising, such as the macroscopic behaviour of ant colonies or eBay shoppers, but which are not in any way mystical or magical.  As Figure 1 attempts to show, emergent behaviours are in a sense dual to the &lt;i&gt;requirements&lt;/i&gt; on a solution.  Requirements are known and &lt;ital&gt;obligate&lt;/ital&gt; the system in certain ways, whereas emergent behaviours ("emergents", one could call them) are those which are &lt;ital&gt;permitted&lt;/ital&gt; by the system, but which were not known &lt;i&gt;a priori&lt;/i&gt;.&lt;table class="image"&gt;&lt;br /&gt;&lt;caption align="bottom"&gt;Figure 1: Required behaviours vs. emergent behaviours&lt;/caption&gt;&lt;tr&gt;&lt;td&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://dynamicaspects.org/blog/uploaded_images/Kiczales-708480.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://dynamicaspects.org/blog/uploaded_images/Kiczales-708475.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;Emergence is an important topic.  But again, we must be careful not to make the leap from the uncontroversial phenomenon of emergence, to the highly controversial idea that reality (and by analogy software) might not be "formal all the way down", as Kiczales, following Smith, suggests.  Formal all the way down is exactly what reality is.  What else could it possibly be?&lt;br /&gt;&lt;br /&gt;Smith's new-age version of emergentism is just an invalid inference from the failure of the &lt;a href="http://plato.stanford.edu/entries/physics-interrelate/"&gt;reductionist&lt;/a&gt; programme in science.  In the 1960's, many scientists, as well as philosophers such as &lt;a href="http://en.wikipedia.org/wiki/Ernest_Nagel"&gt;Ernest Nagel&lt;/a&gt;, were optimistic that we would eventually be able to deductively derive all of science from fundamental physics, by establishing the right "bridge laws" between theories.  Half a century later, this optimism looks naive.  There has been only limited success, for example, in deriving much of chemistry from quantum mechanics on a "first principles" basis.  &lt;br /&gt;&lt;br /&gt;But the failure of this kind of reductionist programme does not mean giving up on formalism.  We simply need a more mature perspective on the relationship between two theories, perhaps seeing the relationship as closer to one of &lt;ital&gt;computational abstraction&lt;/ital&gt; than one of deductive derivation.  During the Q&amp;A session after the talk, someone asked whether "biology rather than formalism" was a better model of software.  Yet much of the recent success in biology has come from developing new technical perspectives and formalisms.  Witness the fast-evolving population of process calculi, equipped with &lt;a href="http://lucacardelli.name/Papers/MobileAmbients.A4.pdf"&gt;ambients&lt;/a&gt;, &lt;a href="http://www.wisdom.weizmann.ac.il/~biospi/heidelberg.ps"&gt;stochasticity&lt;/a&gt;, &lt;a href="http://www.google.co.uk/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.pps.jussieu.fr%2F~danos%2Fpdf%2Fpbc.pdf&amp;ei=iI9UR_SHOIyu0wSPk_nwCg&amp;usg=AFQjCNE5HQzuvNpWZ076eEfzJwAnNy09KQ&amp;sig2=DyC_cn2DXS7Yf7BS9cI7dw"&gt;branes&lt;/a&gt;, and whatnot, which are fast becoming mainstream tools in systems biology.  Biological reductionism may no longer be plausible, but there is no inference to the inadequacy of formalism.&lt;br /&gt;&lt;br /&gt;Once we concede this, then as with social negotiation, we can see that emergence is only indirectly related to the technical problem of enabling "perspectival programming".  We don't need to design for emergence; what we mean by "emergent" is, after all, just &lt;i&gt;that which doesn't come built-in&lt;/i&gt;.  There are no insights we can export from emergence itself to the foundations of computing.  Emergence comes about from the way we use things, the way things contingently interact, not from the &lt;ital&gt;mechanisms of interaction&lt;/ital&gt; per se, which can and indeed &lt;i&gt;can only&lt;/i&gt; be strictly formal.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The technical challenge: a new paradigm for interactive computing&lt;/h3&gt;So at last, I think we can distill the central challenge lurking at the heart of Kiczales' talk.  How do we expect to realise the task-centric, perspectival model of programming that we know is coming?  If abstractions indeed need only exist only in the service of specific interactions the programmer or user has with the program, then in the future we may be abstracting and unabstracting as frequently as we switch between edit buffers today.  In their various ways, systems like &lt;a href="http://www.eclipse.org/mylyn/"&gt;Mylyn&lt;/a&gt;,  fluid AOP, and &lt;a href="http://subtextual.org"&gt;Subtext&lt;/a&gt; offer a glimpse of what this world might look like (although Subtext is the only one of these that offers a glimpse of just how fluid the new paradigm might be).  But do we have the technical maturity to realise this superfluid, aspects-on-steroids vision?&lt;br /&gt;&lt;br /&gt;I suspect that Kiczales would agree that the answer is no.  We simply lack a compelling paradigm for building robust interactive systems.  But contra Kiczales, and as I argued in my last post, working out this new paradigm will require us to to embrace the formal, not reject it.  The answer is not going to be to make things less &lt;definition&gt;effective&lt;/definition&gt; (in his semi-technical sense of the word - roughly synonymous with "executable", I think, or perhaps "live" or "connected") but precisely the opposite.  My own suspicion is that to make this sort of fancy stuff work properly, we will ultimately need a paradigm where software components are intrinsically, persistently and bidirectionally connected, and where interactive computation is the automatic and incremental synchronisation of distributed state.  I've talked about this before, and will hopefully have more to say about it in the future, but for now I only wish to suggest that this, or something like it, is where we should focus our attention.  It's where the real challenge lies.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Conclusion: less pop, more sci&lt;/h3&gt;To sum up, I sincerely doubt that there is an impending "post-formalist" reconstruction of the foundations of computing.  If we want things to be fluffy, they're damn well going to have to be fluffy in some kind of technical, mathematically robust sense, not in some...well, &lt;ital&gt;fluffy&lt;/ital&gt; sense.  We should embrace pluralism and perspectivalism, both in science and computing, but not at the price of sloppy pop sci or new-age philosophy.  The member of the audience who wondered whether Kiczales' "radical thesis" had more in common with quantum mechanics than classical mechanics should be sent to bed without any tea.&lt;br /&gt;&lt;br /&gt;What this kind of question, the popularity of Smith's book, and to a lesser degree, Kiczales' talk, ultimately brings home is perhaps this: that if it's socially negotiated artifacts we're after, we need look no further than the world of &lt;ital&gt;technical ideas&lt;/ital&gt;, mediated by the situation action of conference attendance.  &lt;a href="http://www.sciam.com/article.cfm?articleID=0002F4E6-8CF7-1D49-90FB809EC5880000"&gt;Smart people often believe strange things&lt;/a&gt;; maybe that's the object lesson.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-116247353499029210?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2006/11/art-of-science-of-software.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-115951873197429326</guid><pubDate>Sun, 11 Nov 2007 11:35:00 +0000</pubDate><atom:updated>2008-10-28T09:59:40.903Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>semantic computing</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming languages</category><title>Why syntax won't go away</title><description>&lt;a href="http://alarmingdevelopment.org/?p=44"&gt;Some time ago&lt;/a&gt; Jonathan Edwards wrote:&lt;blockquote&gt;Let’s face it: syntax is a simple and intuitive way to represent structure. But a fundamental principle of Subtext is to avoid syntactically encoding programs so that their semantics are explicit and immediate. It should be possible to use syntactic techniques as a visualization in the UI instead of as a representation of the source.&lt;/blockquote&gt;Jonathan's hope is that we will one day extricate ourselves from the muddy waters of syntax and float free in the semantic stratosphere.  It's hard to argue with the spirit of this hope, and his recent achievement with &lt;a href="http://subtextual.org/subtext2.html"&gt;Subtext 2.0&lt;/a&gt; is an exciting glimpse of the kinds of virtual realities for programming we might inhabit in 5 to 10 years' time.  (Let's recap...he did all that thinking about schematic tables on paper - ok, electronic paper - and then just went ahead and implemented it, only to have it &lt;ital&gt;actually work&lt;/ital&gt;...I'm jealous.)&lt;br /&gt;&lt;br /&gt;The demo itself is a nice reminder of how we are still in the pre-dawn of the computing age, fumbling forlornly in the dark, largely ignorant of our own ignorance.  (Paraphrasing Jonathan's OOPSLA presentation: "In the beginning was the static void...")  Subtext is far from a fumbling exercise, though; or at least it's &lt;ital&gt;clever fumbling&lt;/ital&gt;, fumbling in the direction of the light switch.  But Subtext is both nascent, and philosophically radical, and like most radical youth it's still a little confused: not all of its ideas quite make sense yet.  My own research interests are largely compatible with Jonathan's, and I have a few thoughts on how Subtext might come of age...a little friendly constructive criticism (although I guess Jonathan would agree with much of what I have to say), but also some more general considerations for the long-term future of these sorts of highly visual, highly interactive languages.&lt;br /&gt;&lt;br /&gt;So where is Jonathan trying to go with his idea of "explicit and immediate semantics"?  Just what is a UI visualisation of a program, after all, if it is not a representation of "the source"?  Conversely, what modern tools really use unstructured text - character sequences interspersed with line-terminators - as representations for programs?  Compilers certainly don't, and nor do any non-trivial editors.  Most work with richer representations.  (How successfully they do so is another question.  The fact that they are often flaky and unrobust is perhaps what feeds our intuition that they are still just working with flat files "under the hood".)  Flat files endure as an interoperability format, but they are not how anything that &lt;i&gt;does anything&lt;/i&gt; with programs represents programs.  So the thought must be something deeper: that we should be able to somehow present the "semantics" of the program &lt;i&gt;directly&lt;/i&gt; to the user - for example using direct links in place of textual names - reaping significant ergonomic benefits by so doing.&lt;br /&gt;&lt;br /&gt;Appealing though this idea obviously is, it is problematic.  The problem is not with the claim that there are significant ergonomic gains to be had from advances in UIs, but with the idea that non-textual UIs are doing something different - deeply different - from textual UIs.  Because &lt;ital&gt;user interfaces are syntactic&lt;/ital&gt;...and not just in some academic sense, but quite straightforwardly. They have a recursive, tree-like structure; they can be described inductively by a term algebra over a fixed set of constructors.  They have semantically irrelevant flourishes, like &lt;ital&gt;rounded corners&lt;/ital&gt; and &lt;ital&gt;drop shadows&lt;/ital&gt;; like most textual syntaxes, in fact, with their &lt;ital&gt;curly braces&lt;/ital&gt; and &lt;ital&gt;fancy keywords&lt;/ital&gt;.  UI's &lt;i&gt;must&lt;/i&gt; have syntax because that's how they convey meaning: there's no way to represent a set or a function (qua mathematical object), or whatever it is you take your program to mean, "directly"; you have to denote it in some way.  (And unless you're some kind of mathematical Platonist, perhaps there are only denotations.  If you are you need help.)&lt;br /&gt;&lt;br /&gt;I'm being pedantic, I admit, but I'm not &lt;i&gt;just&lt;/i&gt; being pedantic.  I think it's crucial that we start to treat fancy UIs as fancy syntaxes, for the following reason.  As UIs become more powerful and interactive - and as VPLs become more compelling - they need to become better behaved.  We need to stop thinking of our programming environments as (metaphorically, as well as often quite literally) little "windows" through which we squint awkwardly at the "real" program underneath.  Instead our UIs need to become our programs, and our programs our UIs.  This is exactly the vision Jonathan has for Subtext, of course.  But it can only be practically achieved if we understand UIs as bona fide syntactic structures in their own right, so that we can treat &lt;ital&gt;interaction&lt;/ital&gt; (by end-users or other software processes) as the creation and manipulation of views and transformations of that structure.  Think of those cool projections that approximate "method views" in Subtext: if they are to be any use for building real-world programs (whose [partial] meaning we need to be able to grasp from a [partial] visualisation), then these views need to both have a well-defined structure - yes, a syntax - and a well-defined interpretation.  To borrow from Jonathan again: &lt;ital&gt;notation matters&lt;/ital&gt;.&lt;br /&gt;&lt;br /&gt;So here's my main thesis: only if we take the syntactic nature of UIs seriously we can turn advanced browsing and editing features into the powerful multi-dimensional &lt;ita;&gt;programming constructs&lt;/ital&gt; that they should be.  Such features become robust and well-defined transformations: sometimes preserving behaviour, sometimes changing behaviour in well-defined ways.  In this hypothetical future, refactoring, browsing and AOP become closely interrelated: browsing becomes a kind of refactoring, where the "factors" are something like aspects.  This may sound fanciful, but this is just what the Subtext 2.0 UI gives us a tantalising glimpse of.  Refactoring is already an interactive activity, but is nothing like robust enough: for refactoring to come of age it needs to be as formally reliable as the kind of batch-mode transformations that a (well-behaved) optimising compiler might implement.  The same applies to advanced browsing features, particularly if they support "putback" editing - otherwise we won't be able rely on these views or trust edits mediated by them.  And conversely, traditional AOP is a robust batch-mode transformation, but lacks interactivity: and so for AOP to come of age, we need to turn aspect-weaving into a live, interactive browsing activity - a UI, in other words, that allows programs to be woven and unwoven while they are being edited [&lt;a href="http://www.cs.ubc.ca/~tyehon/ao_asia_2006.pdf" title="Fluid AOP Join Point Models"&gt;HoK05&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;So VPLs have the potential to turn UIs, in an important and I hope non-contrived sense, into rich and full-featured languages for meta-programming.  This is potentially in tension with the fact that, to be practical to design, describe, and implement, programming languages need to be simple, or at least modular.  Are schematic tables part of a programming language or part of a UI?  Think about all the advanced features that schematic tables provide: rendering of predicates in Blake canonical form, enforcement of partioning. Are these features part of the Subtext language or the Subtext UI?  And if this distinction is never to be made, how is anyone else to implement Subtext? Must we require bona fide implementations to be isomorphic to the full Subtext UI?  (Must it be possible to encode the entire state of the Subtext UI in the state of the candidate implementation, and vice versa?)  If we agree this is almost certainly an unreasonable burden to place on implementors, then it is not clear where to draw the line.  The engineering risk to which Subtext is thus exposed is &lt;ital&gt;non-modularity&lt;/ital&gt;: neatly sidestepping all the horrible complexity of maintaining a live mapping to textual syntax, only to gradually mire itself in a new kind of complexity that arises from pushing all those fancy views and direct manipulation features into a single "language".&lt;br /&gt;&lt;br /&gt;The way to avoid this potential tarpit is, I suggest, not to shun syntax, but to embrace it.  Visual programming languages do not get rid of syntax; they enrich it and make it come alive.  But to think of powerful UIs as syntaxes and interactions as syntactic transformations that satisfy certain semantic properties presents a significant architectural challenge.  We need be able to layer views of top of views on top of views...so that it's views all the way down, until we reach a "primitive" view.  (In MVC language, we could just as well call them models: the point is that "model" and "view" are, as with "syntax" and "UI", just relative notions.) The primitive view, or model, is simply the lowest level of syntax for the language, but it is not otherwise distinguished ontologically.  These syntaxes are related by semantic functions (homomorphisms), and ideally those mappings would execute both automatically and incrementally, so that changes in one syntactic structure are interpreted as changes in any dependent syntactic structures.  The biggest challenge facing this paradigm is perhaps that many of these semantic functions will need to be bidirectional - i.e. functional in both directions, like Pierce's lenses [&lt;a href="http://www.cis.upenn.edu/~bcpierce/papers/newlenses-popl.pdf" title="Combinators for BiDirectional Tree Transformations"&gt;FGMP05&lt;/a&gt;] - so that we can edit at our chosen perspective...and it is this that really blurs the distinction between syntax and user interface &lt;ital&gt;from the end-user's perspective&lt;/ital&gt;, providing the rich, integrated experience required for a programming tool, without compromising the modularity of the language.  In fact each tier, of a system so conceived, is a &lt;ital&gt;separate language&lt;/ital&gt; and each homomorphism on languages is a &lt;ital&gt;denotational semantics&lt;/ital&gt; which interprets the syntax of one language in the syntax of another. But it's syntax all the way down.  These languages are live, like visual programmings languages, but they need not be visual; my preferred term is &lt;definition&gt;interactive programming language&lt;/definition&gt; (IPL).&lt;br /&gt;&lt;br /&gt;So do schematic tables belong in a programming language or a UI?  The question turns out to be ill-posed, because these are really relative terms.  A similar analysis can be applied to Subtext's proposed treatment of names (or lack thereof).  Theoreticians are familiar with the formal redundancy of names (or at least of bound names): they prefer to work with terms "up to alpha conversion of bound variables", or to rely on encodings like de Bruijn indices to sidestep name-related issues.  But for programming purposes, does life without names get easier or harder?  There are no doubt ergonomic benefits to be had from using direct links instead of names.  But there are almost certainly ergonomic benefits associated with names too.  Imagine a Subtext-like language with only direct links equipped with comment-like annotations.  For any non-trivial programming exercise it would probably not be long before we started embedding naming conventions into comments - in other words treating them as structured, rather than flat.  We might for example adopt an informal rule whereby no two sibling program elements can have the same comment, so that we can unambiguously find an element by finding its parent and then searching the comments of its children.  We might then want to be able to "repoint a link" by overtyping on the comment.  At other times, we might expect to be able to maintain the identity of the referent and update the text of the comment instead. &lt;br /&gt;&lt;br /&gt;I don't propose any resolution to the tension between names and links here, because I suspect the ultimate requirement is going to be to have characteristics of both.  Methodologically, at any rate, it seems unwise to rule out forever the use of textual names on a priori grounds.  So the risk for Subtext as it stands is that if its goal of emancipating us from the world of textual names turns out to be untenable for the kinds of reasons just mentioned, it may be forced to reintroduce names on the sly, by providing various naming-like features in its UI (and effectively embedding a complex language extension).  It then faces the very "creeping complexity" dilemma that I suggested arises with schematic tables.  On the one hand, if we are not careful to design the language to be layered and modular, implementations become unmanageably complex and lack clarity on exactly what they must provide.  Yet if we accept the challenge of designing our language to be layered and modular, and propose language extensions to deal specifically with names - new syntaxes, plus semantics which map terms in our "nominal algebra" to direct links - then we still seem to be lacking a robust implementation paradigm.  (And no, MVC doesn't touch the sides.)  &lt;br /&gt;&lt;br /&gt;As Alan Perlis said, "There's no such thing as a free variable." Or as the counterpart of Fred Brooks probably said in a nearby possible world, &lt;ital&gt;no syntactic silver bullets&lt;/ital&gt;.  Maybe we're forced to accept that there's a significant bootstrapping issue here: to build mature IPLs, we will need powerful IPLs.  Closing the &lt;ital&gt;bootstrap gap&lt;/ital&gt; is one of the focuses of my own research, so maybe one day Jonathan and I will meet in the middle.&lt;br /&gt;&lt;br /&gt;From the sublimity of Subtext to...the &lt;i&gt;Charles Petzoldiness&lt;/i&gt; of &lt;a href="http://www.charlespetzold.com/etc/CSAML.html"&gt;Charles Petzold&lt;/a&gt;.  I have the disturbing (but in a good way) feeling that this guy is completely serious; as a precautionary measure, however, I shall be taking his observation with a suitably large pinch of monosodium glutamate.  Clearly this dude is a comic genius, and the joke is on me for not spotting it.  He writes:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Here’s another example of perhaps the most notorious syntactical absurdity in all of traditional C# — the for loop:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;for (i=0, j=0; i &lt; 1000; i++)&lt;br /&gt;if (IsPrime(i))&lt;br /&gt;j++;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In CSAML, that jumble of symbols and semicolons is abandoned for a structural beauty that can almost induce the modern programmer to weep with joy:&lt;/blockquote&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;ForLoop&amp;gt;&lt;br /&gt;    &amp;lt;ForLoop.Initializer&amp;gt;&lt;br /&gt;        &amp;lt;StatementExpressionList&amp;gt;&lt;br /&gt;            &amp;lt;Assignment LValue="i"&amp;gt;&lt;br /&gt;                &amp;lt;Assignment.Expression&amp;gt;&lt;br /&gt;                    &amp;lt;Literal Type="{x:Type Int32}"&lt;br /&gt;                             Value="0" /&amp;gt;&lt;br /&gt;                &amp;lt;/Assignment.Expression&amp;gt;&lt;br /&gt;            &amp;lt;/Assignment&amp;gt;&lt;br /&gt;        &amp;lt;/StatementExpressionList&amp;gt;&lt;br /&gt;    &amp;lt;/ForLoop.Initializer&amp;gt;&lt;br /&gt;    &amp;lt;ForLoop.Condition&amp;gt;&lt;br /&gt;        &amp;lt;BooleanExpression&amp;gt;&lt;br /&gt;            &amp;lt;LessThanExpression LeftSide ="i"&amp;gt;&lt;br /&gt;                &amp;lt;LessThanExpression.RightSide&amp;gt;&lt;br /&gt;                    &amp;lt;Literal Type="{x:Type Int32}"&lt;br /&gt;                             Value="1000" /&amp;gt;&lt;br /&gt;                &amp;lt;/LessThanExpression.RightSide&amp;gt;&lt;br /&gt;            &amp;lt;/LessThanExpression&amp;gt;&lt;br /&gt;        &amp;lt;/BooleanExpression&amp;gt;&lt;br /&gt;    &amp;lt;/ForLoop.Condition&amp;gt;&lt;br /&gt;    &amp;lt;ForLoop.Iterator&amp;gt;&lt;br /&gt;        &amp;lt;StatementExpressionList&amp;gt;&lt;br /&gt;            &amp;lt;PreIncrementExpression Identifier="i" /&amp;gt;&lt;br /&gt;        &amp;lt;/StatementExpressionList&amp;gt;&lt;br /&gt;    &amp;lt;/ForLoop.Iterator&amp;gt;&lt;br /&gt;    &amp;lt;ForLoop.EmbeddedStatement&amp;gt;&lt;br /&gt;        &amp;lt;IfStatement&amp;gt;&lt;br /&gt;           &amp;lt;IfStatement.Condition&amp;gt;&lt;br /&gt;               &amp;lt;BooleanExpression&amp;gt;&lt;br /&gt;                     &amp;lt;InvocationExpression MemberAccess="IsPrime"&amp;gt;&lt;br /&gt;                         &amp;lt;InvocationExpression.ArgumentList&amp;gt;&lt;br /&gt;                             &amp;lt;Variable Identifier="i" /&amp;gt;&lt;br /&gt;                         &amp;lt;/InvocationExpression.ArgumentList&amp;gt;&lt;br /&gt;                    &amp;lt;/InvocationExpression&amp;gt;&lt;br /&gt;               &amp;lt;BooleanExpression&amp;gt;&lt;br /&gt;        &amp;lt;/IfStatement.Condition&amp;gt;&lt;br /&gt;           &amp;lt;IfStatement.EmbeddedStatement&amp;gt;&lt;br /&gt;               &amp;lt;StatementList&amp;gt;&lt;br /&gt;                   &amp;lt;PreIncrementExpression Identifier="j" /&amp;gt;&lt;br /&gt;               &amp;lt;/StatementList&amp;gt;&lt;br /&gt;           &amp;lt;/IfStatement.EmbeddedStatement&amp;gt;&lt;br /&gt;              &amp;lt;/IfStatement&amp;gt;&lt;br /&gt;    &amp;lt;/ForLoop.EmbeddedStatement&amp;gt;&lt;br /&gt;&amp;lt;/ForLoop&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I'm not sure that &lt;ital&gt;weeping with joy&lt;/ital&gt; is quite the response the CSAML code would elicit (but I think I'm in agreement that it would involve some kind of bodily function).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-115951873197429326?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2006/09/why-syntax-wont-go-away.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-1124750658323113348</guid><pubDate>Mon, 01 Oct 2007 21:49:00 +0000</pubDate><atom:updated>2007-10-01T23:15:25.166Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>monads</category><category domain='http://www.blogger.com/atom/ns#'>modality</category><category domain='http://www.blogger.com/atom/ns#'>laziness</category><category domain='http://www.blogger.com/atom/ns#'>interactive computation</category><category domain='http://www.blogger.com/atom/ns#'>memoisation</category><title>Sweet Home West Midlands</title><description>Not my &lt;ital&gt;actual&lt;/ital&gt; home, obviously.  I'll still be living in Bristol.  But Birmingham is going to be my &lt;ital&gt;spiritual&lt;/ital&gt; home: where I go when I lose the faith and stop believing in life after Dynamic Aspects.  My first day left me feeling refreshingly (if inaccurately) only &lt;ital&gt;mildly stupid&lt;/ital&gt;.  My supervisor &lt;a href="http://www.cs.bham.ac.uk/~pbl/"&gt;Paul Levy&lt;/a&gt; seems to be an all round nice bloke; handy, as we've got to hang out for the next three years.&lt;br /&gt;&lt;br /&gt;I'm currently learning &lt;a href="http://www.cambridge.org/uk/catalogue/catalogue.asp?isbn=9780521527149"&gt;modal logic&lt;/a&gt;.  It's turning out to be awesome.  I'm hoping, sometime (oh, in the next hundred years or so) to be able to use it to formalise the &lt;definition&gt;possible worlds&lt;/definition&gt; view of interactive systems which I've been informally mincing about with for the last 6 years or so.  The basic idea of modal logic is that a modal formula is a little automaton that can wander about in a structure of worlds which are mutually accessible through various relations, taking on different values at different worlds.  Different access relations between worlds induce different kinds of structural properties on the space of worlds (or contexts, states, instants or points, depending on how you want to construe the relata).&lt;br /&gt;&lt;br /&gt;Any kind of labelled transition system can be talked about modally, but so can many other things, such as time.  A simple example: defining two modalities &lt;code&gt;F&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; (future and past) plus their respective duals &lt;code&gt;G&lt;/code&gt; and &lt;code&gt;H&lt;/code&gt;) such that &lt;code&gt;F&lt;/code&gt; and &lt;code&gt;P&lt;/code&gt; are inverses means that theorems such as &lt;br /&gt;&lt;p style="text-align: center;"&gt;&lt;code&gt;p -&gt; GPp&lt;/code&gt;&lt;/p&gt; &lt;br /&gt;and &lt;br /&gt;&lt;p style="text-align: center;"&gt;&lt;code&gt;p -&gt; HFp&lt;/code&gt;&lt;/p&gt; &lt;br /&gt;are universally true of such systems.  (Respectively: if something is true now then at all future times it will have been true in the past; if something is true now, then at all past times it was going to be true in the future.)  Temporal modal logic is obviously relevant to interaction [&lt;a href="http://books.google.com/books?id=wIpPmdc1eIsC&amp;dq=pnueli+temporal+logic&amp;printsec=frontcover&amp;source=web&amp;ots=Wlq9NRJfsT&amp;sig=FaUTqRaG6U0wapFJTVsbazNi5zE" title="Zohar Manna and Amir Pnueli: The Temporal Logic of Reactive and Concurrent Systems"&gt;Pnu92&lt;/a&gt;], but modality in general seems to offer a nice framework for thinking about lots and lots of things: state, control, and dynamic scoping, to mention some existing applications, but also incremental computation, transactional concurrency, declarative concurrency, mobile code; the list goes on.  And on.&lt;br /&gt;&lt;br /&gt;That's the theory side of things, for now.  On the practical front, I'm trying to understand monads and monad transformers well enough to implement a backtracking interpreter in Haskell that addresses the famously poor interaction between a normal-order or lazy reduction strategy and function caching or memoisation.  The problem is simple: to be any good as an incrementalisation technique, memoisation needs to know the values of arguments to functions up front.  But normal-order reduction defers the evaluation of arguments until they're needed.  A prima facie conflict of interests.  &lt;br /&gt;&lt;br /&gt;I have a vague notion of a solution, an idea gleaned from Avi Pfeffer's work on IBAL [&lt;a href="http://www.eecs.harvard.edu/~avi/Papers/ibal-ch.pdf" title="Avi Pfeffer: The Design and Implementation of IBAL: A General-Purpose Probabilistic Language"&gt;Pfe06&lt;/a&gt;], but much more investigation is required.  The nice thing about implementing the interpreter using monads is that it should transfer easily into a modal language, as it turns out monads themselves are closely related to modal logic [&lt;a href="http://dx.doi.org/10.1016/S0304-3975(96)00169-7" title="Satoshi Kobayashi: Monad as modality"&gt;Kob97&lt;/a&gt;][&lt;a href="http://journals.cambridge.org/action/displayIssue?jid=MSC&amp;volumeId=11&amp;issueId=04#" title="Frank Pfenning and Rowan Davies: A Judgemental Reconstruction of Modal Logic"&gt;Pfe01&lt;/a&gt;].&lt;br /&gt;&lt;br /&gt;(Actually call-by-need - the technique usually used to implement call-by-name - uses something like memoisation to avoid evaluating arguments more than once.  But call-by-need is still a &lt;ital&gt;just-in-time&lt;/ital&gt; evaluation strategy.  What I'm looking for is something with the useful termination characteristics of call-by-name, for unneeded arguments, but the eagerness, for needed arguments, of call-by-value, without requiring a full global strictness analysis.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-1124750658323113348?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2007/10/sweet-home-west-midlands.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-5011997432515811308</guid><pubDate>Sat, 10 Mar 2007 21:56:00 +0000</pubDate><atom:updated>2007-03-10T23:14:19.603Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>semantic computing</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming languages</category><category domain='http://www.blogger.com/atom/ns#'>micro-refactoring</category><title>Whither domain/j?</title><description>One or two people have wondered what happened to our self-styled refactoring tool to end all refactoring tools, &lt;ital&gt;domain/j&lt;/ital&gt;.  It no longer really exists; it is a mere &lt;a href="http://dynamicaspects.org/domain-j/demo.asp"&gt;flash demo&lt;/a&gt; of its former self.  This demo and associated papers and abstracts is pretty much all that remains.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-5011997432515811308?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2007/03/whither-domainj.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-2731707500172358404</guid><pubDate>Fri, 02 Mar 2007 23:40:00 +0000</pubDate><atom:updated>2008-07-29T21:33:05.907Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>semantic computing</category><category domain='http://www.blogger.com/atom/ns#'>modality</category><category domain='http://www.blogger.com/atom/ns#'>interactive computation</category><category domain='http://www.blogger.com/atom/ns#'>persistent computation</category><category domain='http://www.blogger.com/atom/ns#'>transactional concurrency</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming languages</category><category domain='http://www.blogger.com/atom/ns#'>meta-programming</category><category domain='http://www.blogger.com/atom/ns#'>declarative interaction</category><title>FInCo 2007</title><description>Here is the &lt;a href="http://dynamicaspects.org/papers/FInCo2007.pdf"&gt;draft&lt;/a&gt; of a &lt;a href="http://www.cs.brown.edu/sites/finco07/"&gt;FInCo 2007&lt;/a&gt; paper which elaborates (although still entirely informally) the programming model called &lt;definition&gt;declarative interaction&lt;/definition&gt; which I mentioned in my first posting.  FInCo is one of the satellite workshops of &lt;a href="http://www.di.uminho.pt/etaps07/"&gt;ETAPS 2007&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The review comments were useful, and reasonably positive.  I'm looking forward to some interesting discussions.  I conspicuously failed to give even a passing nod to &lt;ital&gt;agent-oriented programming&lt;/ital&gt;; given the likely focus at the workshop, this is something I need to learn about.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-2731707500172358404?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2007/03/finco-2007.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-33378235.post-9128829090053332635</guid><pubDate>Tue, 02 Jan 2007 23:50:00 +0000</pubDate><atom:updated>2007-03-02T23:52:07.431Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>modality</category><category domain='http://www.blogger.com/atom/ns#'>interactive computation</category><category domain='http://www.blogger.com/atom/ns#'>persistent computation</category><category domain='http://www.blogger.com/atom/ns#'>transactional concurrency</category><category domain='http://www.blogger.com/atom/ns#'>interactive programming languages</category><category domain='http://www.blogger.com/atom/ns#'>meta-programming</category><category domain='http://www.blogger.com/atom/ns#'>declarative interaction</category><title>Programming languages for interactive computing</title><description>Almost all software systems today are &lt;ital&gt;interactive&lt;/ital&gt;, in that they maintain ongoing interactions with their environments, rather than simply producing a result on termination [&lt;a href="http://www.springer.com/east/home?SGWID=5-102-22-173670283-0&amp;changeHeader=true&amp;amp;referer=www.springeronline.com&amp;SHORTCUT=www.springer.com/3-540-34666-X"&gt;GSW06&lt;/a&gt;].  Indeed, a consistent trend since the beginning of the digital era has been towards increasingly interactive systems.  The trend has progressed on at least two fronts: enhancements to end-user interactivity, and increasingly &lt;ital&gt;integrated&lt;/ital&gt; systems.  The trend began with the first teletype and textual interfaces and continued through early GUIs and LAN-based operating systems.  It continues with today's 3D virtual worlds and applications deployed over the wide-area network.  &lt;br /&gt;&lt;br /&gt;With the Internet emerging as the "global operating system", the pressure on our software to be interactive is greater than ever before.  Consider how the following requirements can be understood in terms of enhanced interactivity:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Ability to reconfigure or repair applications without taking them offline &amp;rarr; &lt;span style="font-weight:bold;"&gt;interaction with code as well as data&lt;/span&gt;&lt;br /&gt;&lt;li&gt;Long-running, continously-available applications &amp;rarr; &lt;span style="font-weight:bold;"&gt;interaction must be robust&lt;/span&gt;&lt;br /&gt;&lt;li&gt;Sessions resumable from wherever we happen to be located &amp;rarr; &lt;span style="font-weight:bold;"&gt;persistence of interactions&lt;/span&gt;&lt;br /&gt;&lt;li&gt;Transparent recovery from latency problems and intermittent connectivity &amp;rarr; &lt;span style="font-weight:bold;"&gt;interaction should not be semantically sensitive to the network&lt;/span&gt;&lt;br /&gt;&lt;li&gt;Mobile code whose behaviour depends on execution context &amp;rarr; &lt;span style="font-weight:bold;"&gt;dynamically scoped interactions&lt;/span&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;A variety of process algebras and other formalisms have been developed for modelling and reasoning about interactive systems.  Yet despite the trend towards greater interactivity, we continue to lack a simple and coherent paradigm for building robust interactive systems.  The main bugbear that has faced us has been what we might characterise as an "impedance mismatch" between traditional algorithmic programming languages and the way interactive systems abstractly work.  Whereas an algorithmic language treats a program as a black box which produces a final value on termination, an interactive system allows other systems to observe and influence its behaviour as it executes, and must adjust its internal state in response to each interaction to maintain the consistency of the computation.&lt;br /&gt;&lt;br /&gt;In current desktop systems, the mismatch is usually resolved by representing the state of the system as a set of mutable stores and then employing a notification scheme to maintain the consistency of the state.  Rather than the host language being used to execute a single sequential program to termination, it is employed to execute fragments of imperative code as interactions occur.  Each executed fragment must produce exactly the side-effects required to synchronise the state of the system correctly.&lt;br /&gt;&lt;br /&gt;Unfortunately this near-universal reliance on the imperative to support interaction has come at an enormous cost in complexity.  It will be useful here to recall Brooks' distinction between &lt;ital&gt;essential&lt;/ital&gt; and &lt;ital&gt;accidental&lt;/ital&gt; (or &lt;ital&gt;inessential&lt;/ital&gt;) complexity [&lt;a href="http://www-inst.eecs.berkeley.edu/~maratb/readings/NoSilverBullet.html"&gt;Bro87&lt;/a&gt;].  Complexity inherent in the problem itself (from a user's perspective), or which can be attributed to human factors, is essential; what remains is accidental or inessential.  Interactive systems as currently implemented are dominated by inessential complexity, the main culprits being this ad hoc management of state, explicit concern with flow of control, and unnecessary use of non-deterministic concurrency.  Imperative languages (ab)used in this way are the "Turing tar-pit in which everything is possible but nothing of interest is easy" [&lt;a href="http://doi.acm.org/10.1145/947955.1083808"&gt;Per82&lt;/a&gt;].  Web applications only complicate things further, by adding a variety of ill-defined staging policies and interaction models into the mix.&lt;br /&gt;&lt;br /&gt;Ironically, what unifies much of this inessential imperative complexity is that it exists in the service of &lt;ital&gt;essentially declarative ends&lt;/ital&gt;.  Indeed, I suggest that the reason the current paradigm works at all is that systems implemented in this way approximate a much simpler, declarative model of interactive computation.  Experienced software designers rely tacitly on something like this declarative model in order to make decisions about what counts as reasonable behaviour.  Rather than being ill-suited to interaction, as is sometimes assumed, perhaps because of the somewhat arcane feel of techniques such as &lt;ital&gt;monads&lt;/ital&gt; [&lt;a href="http://doi.acm.org/10.1145/158511.158524"&gt;JW93&lt;/a&gt;][&lt;a href="http://doi.acm.org/10.1145/289423.289429"&gt;Wad99&lt;/a&gt;] for modelling effectful computation, the declarative paradigm - with a simple orthogonal extension to support interactivity - fits the abstract behaviour of interactive, stateful systems surprisingly well.  But today, because this declarative behaviour is achieved only indirectly, interactive systems are significantly less reliable and understandable than they need to be, despite the widespread use of design patterns such as &lt;ital&gt;Observer&lt;/ital&gt; [&lt;a href="http://www.aw-bc.com/catalog/academic/product/0,1144,0201633612,00.html"&gt;GHJV95&lt;/a&gt;] to manage some of the inessential complexity.  State-related dysfunctions in particular, such as the gradual degradation of a system over time, spurious sensitivities to the order in which two operations take place, deadlocks and race conditions, are common.  I propose that the best way to address the impedance mismatch between algorithmic languages and interactive systems is not to wallow in the tar-pit of imperative languages, but to lift declarative languages into a computational model which supports interaction directly.&lt;br /&gt;&lt;br /&gt;The aim of this blog is to explore the conceptual foundations of such a programming model, which I shall refer to as the &lt;definition&gt;declarative interaction&lt;/definition&gt; model.  Developing a formal semantics will be a topic for later treatment.  Like some other declarative approaches to interaction, the declarative interaction model maintains a clean separation of (stateless, deterministic) &lt;ital&gt;declarative&lt;/ital&gt; computation and (stateful, non-deterministic) &lt;ital&gt;reactive&lt;/ital&gt; computation.  The model is distinguished by its &lt;ital&gt;modal&lt;/ital&gt; construal of interaction, whereby an interactive system is taken to be a space of canonically represented "possible worlds", each expressing a purely declarative computation, along with an index into that space indicating the "actual world", which represents the system's current &lt;ital&gt;state&lt;/ital&gt;.  To interact with such a system is to select a new &lt;ital&gt;actual&lt;/ital&gt; state from this space of possible states.  Interactions (effectful operations) are lifted to &lt;ital&gt;meta-programs&lt;/ital&gt; that manipulate values of modal type; crucially, they are unable to interfere with the purely declarative semantics of each possible state, and in any case are only required when they are essential to application logic.  Non-determinism arises from concurrent interactions, which are handled transactionally.&lt;br /&gt;&lt;br /&gt;The declarative interaction model relates to many active research areas, including modal type systems, incremental computation, meta-programming, declarative concurrency, transactional concurrency, dataflow computing, interactive computing, and wide-area computing.  As we shall see, four closely related concepts in particular are central to the model: modality, incrementality , concurrency, and persistence.  A key validation of the model will be the development of an &lt;definition&gt;interactive programming language&lt;/definition&gt; which supports the model directly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33378235-9128829090053332635?l=dynamicaspects.org%2Fblog' alt='' /&gt;&lt;/div&gt;</description><link>http://dynamicaspects.org/blog/2007/01/programming-languages-for-interactive.html</link><author>noreply@blogger.com (Roly Perera)</author><thr:total>0</thr:total></item></channel></rss>