<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Speaking my mind</title>
	<atom:link href="http://frankmccabe.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://frankmccabe.wordpress.com</link>
	<description>The whole is more than the sum</description>
	<lastBuildDate>Fri, 07 Jun 2013 14:18:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='frankmccabe.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Speaking my mind</title>
		<link>http://frankmccabe.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://frankmccabe.wordpress.com/osd.xml" title="Speaking my mind" />
	<atom:link rel='hub' href='http://frankmccabe.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A Tale of Three Loops</title>
		<link>http://frankmccabe.wordpress.com/2013/05/02/a-tale-of-three-loops/</link>
		<comments>http://frankmccabe.wordpress.com/2013/05/02/a-tale-of-three-loops/#comments</comments>
		<pubDate>Fri, 03 May 2013 00:28:45 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[Star]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=71</guid>
		<description><![CDATA[This one has been cooking for a very long time. Like many professional programmers I have often wondered what is it about programming that is just hard. Too hard in fact. My intuition has led me in the direction of turing completeness: as soon as a language becomes Turing complete it also gathers to itself [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=71&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This one has been cooking for a very long time. Like many professional programmers I have often wondered what is it about programming that is just <strong>hard</strong>. Too hard in fact.</p>
<p>My intuition has led me in the direction of turing completeness: as soon as a language becomes Turing complete it also gathers to itself a level of complexity and difficulty that results in crossed eyes. Still, it has been difficult to pin point exactly what is going on.</p>
<h3>A Simple Loop</h3>
<p>Imagine that your task is to add up a list of numbers. Simple enough.</p>
<p>If you are a hard boiled programmer, then you will write a loop that looks a bit like:<br />
<code><br />
int total = 0;<br />
for(Integer ix:table)<br />
total += ix;<br />
</code><br />
Simple, but full of pitfalls. For one thing we have a lot of extra detail in this code that represents additional commitment:</p>
<ul>
<li>We have had to fix on the type of the number being totaled.</li>
<li>We have had to know about Java&#8217;s boxed v.s. unboxed types.</li>
<li>We have had to sequentialize the process of adding up the numbers.</li>
</ul>
<p>While one loop is not going to hurt anyone; real code is stuffed with them. There have been occasions (not many thankfully) where I have written loops nested to a depth of 7 or 8. Such code really does become impossible to follow; let alone to write.</p>
<h3>A Functional Loop</h3>
<p>In a functional programming language, there are two ways to accomplish the task. The apprentice&#8217;s approach might be to write a recursion:<br />
<code><br />
total(nil) is 0;<br />
total(cons(E,L)) is total(L)+E;<br />
</code><br />
While workman-like, for many instances a smarter way is to use a fold:<br />
<code><br />
fold((+),0,L)<br />
</code><br />
Apart from being more concise; the <strong>fold</strong> is higher-level: it abstracts away the machinery of the loop itself and it is also independent of the representation of the collection of numbers.</p>
<p>(That is assuming that you have a functional language with overloading).</p>
<p>What is really interesting in relation to my original thesis is that the <strong>fold</strong> expression is closer to a problem-solving representation of the task.</p>
<p>However, ask any functional programmer about their use of <code>fold</code> and you will likely encounter a fairly procedural interpretation of how it works and how it should be used. (Something about how it successively applies the <code>+</code> function to each element of the list accumulating the answer as it goes.)</p>
<p>I.e., <strong>fold</strong> is better than <strong>for</strong>; but is not good enough.</p>
<h3>A Totalization Query</h3>
<p>My third version of this would be familiar to any SQL programmer:</p>
<p><code><br />
total X where X in L<br />
</code></p>
<p>I.e., if you want to add up the elements of the list, then say so!</p>
<p>This query — which is based on notation in the Star programming language — declaratively states what is required. Although it&#8217;s form is a little too specific, a more realistic variant would be:</p>
<p><code><br />
fold X with (+) where X in L<br />
</code></p>
<p>I argue that either of these queries is better than either of the previous solutions because it comes closest to the original description and makes the fewest assumptions about the nature of the collections or the arithmetic.</p>
<p>It is also much closer to a problem oriented way of thinking about the world. I would argue that more people — especially non-programmers — would be able to follow and even to write such a query than either of the earlier formulations.</p>
<p>Why is that?</p>
<h3>The Homunculus</h3>
<p>Traditional programming is often taught in terms of programs being sequences of steps that must be followed. What does that imply for the programmer? It means that the programmer has to be able to imagine what it is like to be a computer following instructions.</p>
<p>It is like imagining a little person — a homunculus — in the machine that is listing to your instructions and following them literally. You the programmer have to imagine yourself in the position of the homunculus if you want to write effective programs.</p>
<p>Not everyone finds such feats of imagination easy. It is certainly often tedious to do so.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=71&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2013/05/02/a-tale-of-three-loops/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>The true role of domain specific languages</title>
		<link>http://frankmccabe.wordpress.com/2012/04/05/the-true-role-or-domain-specific-languages/</link>
		<comments>http://frankmccabe.wordpress.com/2012/04/05/the-true-role-or-domain-specific-languages/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 05:10:02 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Policy and research]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[policy]]></category>

		<guid isPermaLink="false">https://frankmccabe.wordpress.com/?p=65</guid>
		<description><![CDATA[It is easy to be confused by the term domain specific language. It sounds like a fancy term for jargon. It is often interpreted to mean some form of specialized language. I would like to explore another role for them: as vehicles for policy statements. In mathematics there are many examples of instances where it [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=65&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It is easy to be confused by the term domain specific language. It sounds like a fancy term for jargon. It is often interpreted to mean some form of specialized language. I would like to explore another role for them: as vehicles for <em>policy statements</em>.</p>
<p>In mathematics there are many examples of instances where it is easier to attack a problem by solving a more general, more uniform, problem and then specializing the result to get the desired answer.</p>
<p>It is very similar in programming: most programs take the form of a general mechanism paired with a policy that controls the machine. Taken seriously, you can see this effect down to the smallest example:<br />
<code>fact(n) where n&gt;0 is n*fact(n-1);<br />
fact(0) is 1</code><br />
is a general machine for computing factorial; and the expression:<code>fact(10)</code> is a policy &#8216;assertion&#8217; that specifies which particular use of the factorial machine is intended.</p>
<p>One important aspect of policies is that they need to be intelligible to the owner of the machine: unlike the machine itself which only needs to be trusted by the owner.</p>
<p>So, one critical role for a DSL is to be the policy language for the user of a mechanism.</p>
<p>Starting from this light leads to interesting conclusions. In particular, DSLs should be ubiquitous not rare; in particular, DSLs support the role that abstractions play in programming: by layering an appropriate syntax on top of the expression of the abstraction. It also means that programming languages should be designed to make it easy to construct and use DSLs within systems as well as externally.</p>
<p>A simple example: the query notation in Star, as well as in formalisms such as LINQ, may be better viewed as simple DSLs where the user is the programmer. The difference between these and more traditional DSLs is that the DSL expressions are embedded in the program rather than being separated from the code.</p>
<p>I think that embracing the DSL in this way should make it easier for a programming language to survive the evolution of programming itself. With an effective DSL mechanism a language &#8216;extension&#8217; encoding a new language concept (for example, queries over C# or objects over C) and be done without invalidating the existing language. (The mechanisms in Star go further: it is possible to construct a DSL in Star that either augments the base language or even replaces it. We have used both approaches.)</p>
<p>It also explains why LISP&#8217;s macro facilities have allowed it to survive today more-or-less unchanged (nearly 60 years after being invented) whereas languages like Java and C++ have had to undergo painful transitions in order to stay relevant.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/65/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/65/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=65&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2012/04/05/the-true-role-or-domain-specific-languages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>Single Inheritance and Other Modeling Conundrums</title>
		<link>http://frankmccabe.wordpress.com/2011/03/17/single-inheritance-and-other-modeling-conundrums/</link>
		<comments>http://frankmccabe.wordpress.com/2011/03/17/single-inheritance-and-other-modeling-conundrums/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 19:36:29 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[programming language]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=63</guid>
		<description><![CDATA[Sometimes a restriction in a programming language makes sense and no sense at all &#8212; all at the same time. Modeling the real world Think about the Java restrictions on the modeling of classes: a given class can only have one supertype and a given object&#8217;s class is fixed for its lifetime. From a programming [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=63&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Sometimes a restriction in a programming language makes sense and no sense at all &mdash; all at the same time.</p>
<h2>Modeling the real world</h2>
<p>Think about the Java restrictions on the modeling of classes: a given class can only have one supertype and a given object&#8217;s class is fixed for its lifetime.</p>
<p>From a programming language perspective these restrictions make a good deal of sense: all kinds of ambiguities are possible with multiple inheritance and the very idea of allowing an object to be &#8216;rebased&#8217; fills the compiler writer with horror. (Though SmallTalk allows it.)</p>
<p>The problem is that, in real life, these things do happen. A &#8216;natural&#8217; domain model is quite likely to come up with situations involving multiple inheritance and dynamic rebasing.</p>
<p>For example, a person can go from being a customer, to an employee, to a manager to being retired. A given person might be both an employee and a customer simultaneously (someone else may not be).</p>
<p>Given a domain that is as flexible as this one if forced to &#8216;simulate&#8217; it in Java. I.e., one cannot use a Java class called <code>Customer</code> to represent a customer; because Java&#8217;s idea of class is not rich enough to model the domain.</p>
<p>At the same time, the modeling is not random and a good architect will try to ensure some discipline in the application.</p>
<p>The logical conclusion is that large applications tend to contain a variant of &#8216;the type system&#8217; where the domain model is represented. Java is used to implement the meta model, not the domain model.</p>
<p>This dynamic type system may or may not be based on a well founded model (such as that of description logic); but in any case the programming language is not helping as much as it should.</p>
<h2>What is a language to do?</h2>
<p>On the face of it, it seems that the logical thing is to make a programming language&#8217;s type system sufficiently flexible to actually model real world scenarios.</p>
<p>However, there is a difficulty with that: it is not the case that any one modeling system is best suited to all applications. In addition, a modeling system that is well-suited to modeling domain knowledge is not guaranteed to be equally well suited to regular programming tasks.</p>
<p>A better approach is to embrace diversity. A combination of DSLs and libraries enable one to build out a particular modeling system and to support the programmer with direct appropriate syntax.</p>
<p>For example, this pseudo-code example:</p>
<pre>
  customer isa person 
  customer has account
  ...
  person has name
  ...
  C instance of customer
  ...
  if overdrawn(C's account) then
    ...
</pre>
<p>shows one example of a modeled customer. The &#8216;actual&#8217; code implied by this fragment might look like:</p>
<pre>
  C : object;
  ...
  if overdrawn(findAttribute(C,"account")) then 
    ...
</pre>
<p>The principal point here is that the syntactic sugar offered by a DSL is not mere syntactic sugar: it can help the application programmer to use a language that is appropriate for her needs while at the same time enforcing sanity checks implied by the particular modeling language.</p>
<p>At the same time, there is no implied permanent commitment to one particular way of modeling with the host language.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=63&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2011/03/17/single-inheritance-and-other-modeling-conundrums/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>Too Many Moving Parts</title>
		<link>http://frankmccabe.wordpress.com/2011/02/23/too-many-moving-parts/</link>
		<comments>http://frankmccabe.wordpress.com/2011/02/23/too-many-moving-parts/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 06:41:57 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[macros]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=61</guid>
		<description><![CDATA[A common, if somewhat informal, observation about a large code base is that there are &#8220;too many moving parts&#8221; in it. In my experience, this is especially true for large Java systems but is probably universally true. What do we mean by ‘too many moving parts’? Simply put, there is always a significant semantic gap [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=61&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A common, if somewhat informal, observation about a large code base is that there are &#8220;too many moving parts&#8221; in it. In my experience, this is especially true for large Java systems but is probably universally true.</p>
<h2>What do we mean by ‘too many moving parts’?</h2>
<p>Simply put, there is always a significant semantic gap between a programming language and the program. The larger this gap, the more that has to be expressed in the language, as opposed to simply using it.</p>
<p>For example, consider the problem of traversing a recursive tree structure. In Java, we can iterate over an <code>Iterable</code>; structure using a loop, for example, to count elements:</p>
<pre>
int count = 0;
for(E el:tree)
{
&nbsp;&nbsp;count++;
}
</pre>
<p>If the <code>Tree</code> class did not implement <code>Iterable</code> we would be forced to construct an explicit iterator (or worse, write a recursive one-off function):</p>
<pre>
int count = 0;
for(Iterator&lt;E&gt; it=tree.iterator(); it.hasNext();)
{
&nbsp;&nbsp;E el = it.next();
&nbsp;&nbsp;count++;
}
</pre>
<p>This version illustrates what happens when a programming language does not quite meet us halfway in our programming task. There is a lot of extra clutter (managing the iterator) that makes it hard to see what is really going on.</p>
<p>In this case, Java&#8217;s <code>for</code> notation makes it significantly easier to see the program. However, there are many cases where this is not true. For example, you cannot use a similar technique for reading files, searching or removing elements from a tree, etc. etc.</p>
<h2>Language Extensions</h2>
<p>One way of reducing clutter is to permit the programmer to extend the language. Of course, the designers of Java set their face against this — there is no macro facility in Java — for a reasonable if misguided reason: to prevent programmers lying to each other.</p>
<p>The Star language does permit language extensions to be introduced by the programmer. This has the effect of encapsulating not only data abstractions but also control abstractions.</p>
<p>For example, to count the elements of a tree in Star, we can do:</p>
<pre>
var count:=0;
for E in tree do
&nbsp;&nbsp;count := count+1;
</pre>
<p>The program depends on the programmer implementing the type contract for <code>_search</code> and a macro expansion rule:</p>
<pre>
# for ?Ptn in ?Exp do ?Act ==&gt;
&nbsp;&nbsp;__search(Exp,procedure(X){ if X matches Ptn then Act})
</pre>
<p>No apologies for the macro definition itself, but the effect is that the language has been lifted into one that fits the requirements more closely. This, in turn, reduces the semantic gap between the language as used by the programmer and the application.</p>
<p>
Of course, there is quite a bit more to reducing clutter than macro definitions. However, it should be an important goal of language design to ensure that programmers can express themselves with minimum extraneous concepts.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=61&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2011/02/23/too-many-moving-parts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>Late Binding in Programming Languages</title>
		<link>http://frankmccabe.wordpress.com/2011/01/30/late-binding-in-programming-languages/</link>
		<comments>http://frankmccabe.wordpress.com/2011/01/30/late-binding-in-programming-languages/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 00:36:13 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Computer Languages]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=59</guid>
		<description><![CDATA[Late binding is key to enhanced productivity in programming languages. I believe that this is the single most important reason why so-called dynamic typed languages are so popular. This note is part of an ongoing &#8216;language design&#8217; series which aims to look at some key aspects of programming language design. What do we mean by [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=59&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Late binding is key to enhanced productivity in programming languages. I believe that this is the single most important reason why so-called dynamic typed languages are so popular.</p>
<p>This note is part of an ongoing &lsquo;language design&rsquo; series which aims to look at some key aspects of programming language design.</p>
<h2>What do we mean by late binding?</h2>
<p>Simply put, a programmer should not have to say more than they mean at any particular time. </p>
<p>To see what I mean, consider a function that computes a person&#8217;s name from a first and last name. In Star, I can write this:</p>
<pre>
fullName(P) is P.firstName()++P.lastName()
</pre>
<p>This constitutes a complete definition of the function: there is no need to declare types; furthermore this function will work with any type that has a first and last name. </p>
<p>Contract this with a typical well-crafted Java solution:</p>
<pre>
boolean fullName(Person P){
  return P.firstName()+P.lastName();
}
</pre>
<p>Not so different one might argue.</p>
<p>Except that we have had to define a type <code>Person</code>; at best this is an interface and not a class. The Java <code>fullName</code> method will only work with objects of type <code>Person</code>.</p>
<p>In designing the Java version we have to find and/or create a type <code>Person</code>. In addition, we must make sure that all classes that we want to compute the full name of implement the <code>Person</code> type.</p>
<p>This last aspect can be a real productivity killer. Suppose that we want to be able to compute the full name of many different kinds of objects; then we must arrange them all to implement the <code>Person</code> type. This may not even be possible if the classes in question are from a library that you don&#8217;t have the source to.</p>
<h2>Late Binding does not mean dynamic typing</h2>
<p>One of the common perceptions is that you lose the safety of a type checker if you want to allow late binding. This is not true; at least, it is not true for Star.</p>
<p>Star is a statically typed language which supports a range of type constraints. In the case of the <code>fullName</code> function, the constraint is that the type of <code>P</code> has the <code>firstName</code> and <code>lastName</code> attributes. (The details of how this is done are too gory to go into here.) </p>
<p>These constraints can be checked; so, for example, every time the <code>fullName</code> function is used on an argument, the checker can verify that the type of the argument is consistent with having a first and last name. This check can be performed at compile-time.</p>
<p>It is even possible (necessary) to go one step further and allow generic functions to use the <code>fullName</code> function.</p>
<h2>Other forms of Late Binding</h2>
<p>Late binding shows up in other ways. For example, when specifying an imported library of some form or other, it should be possible to declare the requirement for a library in terms of what is needed, rather than the name of the library. I.e., instead of:</p>
<pre>
import java.util.List;
import java.util.ArrayList;
</pre>
<p>we should be able to say:</p>
<pre>
require List of integer;
</pre>
<p>or some such expression.</p>
<p>The difference is that the former says &mdash; in the source code &mdash; which package to import whereas the latter merely declares a contract requirement. How the contract is fulfilled is a separate step; one that a smart compiler system may even be able to automate.</p>
<p>(Some language do work this way. Typically LISP language systems organize their modules in terms of requires and provides.)</p>
<h2>Take Away</h2>
<p>It can be hard to know what features should go into a programming language. Having a few principles to guide us make the task of designing a language more tractable. </p>
<p>In this case, the message is that programmers should be able to program in terms of their requirements, not the compiler&#8217;s. This need not come at the expense of safety or of performance.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=59&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2011/01/30/late-binding-in-programming-languages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>Productivity gains are permanent, Performance losses are temporary</title>
		<link>http://frankmccabe.wordpress.com/2011/01/22/productivity-gains-are-permanent-performance-losses-are-temporary/</link>
		<comments>http://frankmccabe.wordpress.com/2011/01/22/productivity-gains-are-permanent-performance-losses-are-temporary/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 05:19:07 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[Computer Languages]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=57</guid>
		<description><![CDATA[This is the first in a short series of notes about language design. The goal is to identify what is truly important about programming language design. It is all about productivity There are &#8216;too many moving parts&#8217; in a typical Java program. Here is a simple straw-man example: iterating over a collection. Before Java 5, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=57&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is the first in a short series of notes about language design. The goal is to identify what is truly important about programming language design.</p>
<h2>It is all about productivity</h2>
<p>There are &#8216;too many moving parts&#8217; in a typical Java program.</p>
<p>Here is a simple straw-man example: iterating over a collection. Before Java 5, the paradigmatic way of iterating over a collection was to use a fragment like:</p>
<pre>
for(Iterator it=coll.iterator();it.hasNext();){
  SomeType el = (SomeType)it.next();
  ...
}
</pre>
<p>There is a lot of &#8216;clutter&#8217; here; but worse, there are a lot of concepts that are not really that important to the problem at hand.</p>
<p>Compare that to the Java 5 version:</p>
<pre>
for(SomeType el:coll){
 ...
}
</pre>
<p>Here we can focus on exactly what is needed: the collection and the iteration.</p>
<p>This kind of example can be repeated fractally up the entire stack of abstractions: not just at this micro level but also at the level of using standard JDK class libraries on through to using features such as Spring/Hibernate or Wicket.</p>
<h2>The elements of productivity</h2>
<p>I believe that the list of requirements is not that long:</p>
<h3>Digestibility</h3>
<p>A programming language is an artifact, and needs to be understood in order to be effectively used. So, a language with a well crafted structure is going to be easier to learn and use than one with many ill fitting pieces.</p>
<p>Note that this does not mean a small number of pieces (or features). The classic example of this is natural languages (such as English or Spanish). There are at least 500,000 words in the English language. A daunting task for someone wishing to learn the language. But, the grammar of English is relatively simple compared to other languages (such as German or modern Greek). This has helped English to become the dominant second-language globally.</p>
<h3>Semantic Lifting</h3>
<p>Structure in software is evident at many levels: in the micro structure of individual fragments of code, to the organization of libraries to the ecosystem of multiple applications.</p>
<p>A powerful tool for managing this complexity is abstraction. Commonly abstraction is thought of as a technique that enables one to ignore inessential details.</p>
<p>But a better concept might be semantic lifting. Semantic lifting is a common technique in Mathematics. For example, vector geometry is layered over cartesian geometry but permits powerful statements to be expressed in a simple way.</p>
<p>A programming language that can support similar techniques for lifting the language &mdash; like the iteration example &mdash; enables higher productivity.</p>
<h3>Late Binding</h3>
<p>Programming languages are often quite fussy in character: requiring all kinds of details to be established quite early in the design process. For example, Java (like most languages) requires that all types have names.</p>
<p>This emphasis on detail makes a significant barrier to developing a program: the programmer is forced to focus on issues that she may not actually be ready or willing to.</p>
<p>A language that supports late binding allows programmers to delay such choices until they are needed.</p>
<p>For example, one reason that type inference is so powerful is that it permits a programmer to program in a &#8216;type-free&#8217; way while knowing that the compiler will verify the type safety of the program. Establishing types of functions is a detail that can often be left to later. However, ultimately, type inference still ensures that the program is &#8216;correct&#8217;.</p>
<h3>Declarative Semantics</h3>
<p>This one is a hard one!</p>
<p>But the fundamental benefits of a declarative semantics arise from the tractability that follows. Having a declarative semantics makes program manipulation of all kinds more straightforward. That, in turn, means that some high-powered transformations &mdash; such as those required for scaling on parallel hardware &mdash; much easier to accomplish without requiring enormous input from the programmer.</p>
<h2>What does the future language look like?</h2>
<p>According to this thesis, a language based on these principles would have a sound semantic foundation, would be easy to understand and would not require more from the programmer than was required by the problem. And it would be easy to deploy on systems consisting of many cores.</p>
<p>What&#8217;s not to like? In the subsequent posts I will look at each of these principles in turn in a little greater depth.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=57&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2011/01/22/productivity-gains-are-permanent-performance-losses-are-temporary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>(Software) Architecture = Policy + Mechanism</title>
		<link>http://frankmccabe.wordpress.com/2010/12/06/software-architecture-policy-mechanism/</link>
		<comments>http://frankmccabe.wordpress.com/2010/12/06/software-architecture-policy-mechanism/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 10:49:53 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[computer architecture]]></category>
		<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[semantic web]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=55</guid>
		<description><![CDATA[In the early 1980&#8242;s Bob Kowalski made famous an interesting equation: Program = Logic + Control. The idea of that equation was that programming was essentially a combination of logic &#8212; i.e., what you wanted done &#8212; with algorithm &#8212; how you wanted it done. It is a fairly commonplace fact that any non-trivial program [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=55&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the early 1980&#8242;s Bob Kowalski made famous an interesting equation: Program = Logic + Control. The idea of that equation was that programming was essentially a combination of logic &#8212; i.e., what you wanted done &#8212; with algorithm &#8212; how you wanted it done.</p>
<p>It is a fairly commonplace fact that any non-trivial program has a similar flavor to it: there is often a substantial amount of machinery that is used to deliver the value in the program; together with some form of policy statement/expression that governs the precise requirements for a particular execution of the program.</p>
<p>The larger the program, the more obvious it is that there is this layering into mechanisms and policies. For example, one could argue that a word processor&#8217;s mechanisms are all the pieces need to implement text editing, formatting and so on. If the word processor supports styles, especially named styles, then these styles are a simple form of policy.</p>
<p>At larger scales, when considering networked applications for example, there are often formal languages used to express the different kinds of policy that apply: security policies, management policies and so on.</p>
<p>So, my thesis of the day is that Architecture consists of the specification of the mechanisms together with the specification of the policies that may apply.</p>
<p>Is this useful? Being clear about the `natural divisions&#8217; in a complex structure is the first step in making that structure tractable.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=55&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2010/12/06/software-architecture-policy-mechanism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>Sub-turing complete programming languages</title>
		<link>http://frankmccabe.wordpress.com/2008/09/30/sub-turing-complete-programming-languages/</link>
		<comments>http://frankmccabe.wordpress.com/2008/09/30/sub-turing-complete-programming-languages/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 19:01:46 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[computer architecture]]></category>
		<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[semantic web]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=52</guid>
		<description><![CDATA[Here is an interesting intuition: the key to liberating software development is to use programming languages that are not, by themselves, turing-complete. That means no loops, no recursion &#8216;in-language&#8217;. Why? Two reasons: any program that is subject to the halting problem is inherently unknowable: in general, the only way to know what a turing-complete program [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=52&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Here is an interesting intuition: the key to liberating software development is to use programming languages that are not, by themselves, turing-complete.</p>
<p>That means no loops, no recursion &#8216;in-language&#8217;.</p>
<p>Why? Two reasons: any program that is subject to the halting problem is inherently unknowable: in general, the only way to know what a turing-complete program means is to run it. This puts very strong limitations on the combinatorics of turing-complete programs and also on the kinds of support tooling that can be provided: effectively, a debugger is about the best that you can do with any reasonable effort.</p>
<p>On the other hand, a sub-turing language is also &#8216;decidable&#8217;. That means it is possible to predict what it means; and paradoxically, a lot easier to provide a rich environment for it etc. etc. An interesting example of two languages on easier side of the turing fence are TeX and CSS. Both are designed for specifying the layout of text, TeX is turing complete and CSS is not.</p>
<p>CSS is still young but, for all its warts, an order of magnitude easier to work with than TeX. Further more, there is actually no much that TeX can do that CSS cannot; with the proviso that sometimes missing functionality must be &#8216;buried&#8217; in the CSS language.</p>
<p>For example, TeX is powerful enough to implement an indexing scheme, CSS is not. It would be easy enough to extend a CSS engine to provide key indexing mechanisms.</p>
<p>I think that there are many fundamental merits to this approach to programming languages. The biggest is that a sub-turing complete language would (have to) be inherently more high-level than a turing-complete language. Secondly I believe (no evidence presented here) that such a language could be closer to the way people think about tasks than programming in Java (or even Haskell).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=52&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2008/09/30/sub-turing-complete-programming-languages/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>On programming languages and the Mac</title>
		<link>http://frankmccabe.wordpress.com/2008/05/25/on-programming-languages-and-the-mac/</link>
		<comments>http://frankmccabe.wordpress.com/2008/05/25/on-programming-languages-and-the-mac/#comments</comments>
		<pubDate>Sun, 25 May 2008 17:05:51 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[computer architecture]]></category>
		<category><![CDATA[Computer Languages]]></category>
		<category><![CDATA[Open Standards]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/?p=51</guid>
		<description><![CDATA[Every so often I dig out my Xcode stuff and have a go at exploring developing an idea for Mac OS X. Everytime the same thing happens to me: Objective-C is such an offensive language to my sensibilities that I get diverted into doing something else. All the lessons that we have learned the hard [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=51&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Every so often I dig out my Xcode stuff and have a go at exploring developing an idea for  Mac OS X. Everytime the same thing happens to me: Objective-C is such an offensive language to my sensibilities that I get diverted into doing something else.</p>
<p>All the lessons that we have learned the hard way over the years &#8212; the importance of strong static typing, the importance of tools for large scale programming &#8212; seem to have fallen on deaf ears in the Objective-C community. How long did it take to get garbage collection into the language?  I also feel that some features of Objective-C represent an inherent security risk (in particular categories) that would make me very nervous to develop a serious application in it.</p>
<p>As it happens, I am currently developing a programming language for Complex Event Processing.<br />
Almost every choice that I am making in that language is the opposite to the choice made for Objective-C &#8212; my language is strongly, statically typed; it is designed for parallel execution, it uses a functional programming foundation, it is symbolic in nature, designed to permit development of large programs, etc. etc. </p>
<p>Hence my allergic reaction and yet again I veer off into something that does not involve actually making a beautiful application for a platform that I much admire.</p>
<p>I have to also admit that I regret Apple&#8217;s choice to abandon Java development. I am not an apologist for Java, but it is significantly better for programming in than Objective-C. </p>
<p>I have heard that some of the features of Cocoa are impossible to do in Java. I have strong doubts about that.</p>
<p>I just wish that Apple&#8217;s sense of design extended to the underlying technologies as much as it does to user engineering.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/frankmccabe.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/frankmccabe.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=51&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2008/05/25/on-programming-languages-and-the-mac/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
		<item>
		<title>About the right tools for the job</title>
		<link>http://frankmccabe.wordpress.com/2008/01/11/about-the-right-tools-for-the-job/</link>
		<comments>http://frankmccabe.wordpress.com/2008/01/11/about-the-right-tools-for-the-job/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 23:29:56 +0000</pubDate>
		<dc:creator>Francis McCabe</dc:creator>
				<category><![CDATA[computer architecture]]></category>
		<category><![CDATA[logic programming]]></category>
		<category><![CDATA[semantic web]]></category>

		<guid isPermaLink="false">http://frankmccabe.wordpress.com/2008/01/11/about-the-right-tools-for-the-job/</guid>
		<description><![CDATA[Some time ago I was involved in a running debate about whether we should be using Ruby on Rails rather than the Java stack (junkyard?) that we were using. At the time, I did not really participate in the discussion except to note that everything seemed to be at least 5 times too difficult. I [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=50&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Some time ago I was involved in a running debate about whether we should be using Ruby on Rails rather than the Java stack (junkyard?) that we were using. At the time, I did not really participate in the discussion except to note that everything seemed to be at least 5 times too difficult. I had this strong intuition that there were so many moving parts that that was the problem. The application itself was not really that hard. My assertions really ticked some of my colleagues off; for which I apologize; sort of.</p>
<p>I guess that I come from a tradition of high-level programming languages, by high level, I would say that I would consider LISP to be a medium level language, and Prolog is slightly better. I would say that it is a pretty common theme of my career that I end up having to defend the position of using high-level tools. I have gotten a number of arguments, ranging from &#8220;it will not be efficient enough&#8221; to &#8220;how do you expect to find enough XX programmers?&#8221;. I used to try to answer these questions, because I thought that they are raised in good faith. Most of them, with the possible exception of the last, have all but been made moot by progress in silicon and compiler technology.</p>
<p>Anyway, afterwards, I decided to take a more serious look at RoR. I picked up a book on it, and followed along. At the end of three days, I had managed to replicate perhaps 60-70% of the functionality of the site I had been working on; and I became furious.</p>
<p>If we had used RoR at the beginning, I began to think, it is entirely possible that I would still have a share in a company that was going to go places. Not that RoR is perfect; far from it. For example, when something goes wrong with your Ruby program a neophyte has very little support. And Ruby is a pretty weird language. But, to replicate 60% of an application that had taken 5 man years of developer effort in two days really pissed me off. </p>
<p>You see, one key reason that everything fell apart was that we had a competitor; a competitor who got out into the market before we did. It is hard to be sure, but we did not get the feeling that they had started before us even. What they did do was use a much easier to get going technology (PHP). So, maybe PHP does not scale; but so what? The first to market can gain enough time to re-implement should the idea prove sufficiently interesting.</p>
<p>So, the next time someone says that they can&#8217;t find programmers, or some other reason for not using advanced techniques; my response is likely to be more robust. If we need to train people, then so be it. Using technology that lets you get going quickly can make the difference between life or death for a startup. </p>
<p>I may even start pushing some of the languages that I have been involved in developing&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/frankmccabe.wordpress.com/50/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/frankmccabe.wordpress.com/50/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frankmccabe.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frankmccabe.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmccabe.wordpress.com&#038;blog=253895&#038;post=50&#038;subd=frankmccabe&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmccabe.wordpress.com/2008/01/11/about-the-right-tools-for-the-job/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1c9da3a12f7ee3ba36184164a2f95e3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">frankmccabe</media:title>
		</media:content>
	</item>
	</channel>
</rss>
