<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Bound Variable</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.boundvariable.com/atom.xml" />
    <id>tag:www.boundvariable.com,2008-06-03://1</id>
    <updated>2010-01-05T23:42:54Z</updated>
    <subtitle>Somewhere on the edges of code, user interface and philosophy.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.31-en</generator>

<entry>
    <title>What humans would look like if they were invented today</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2010/01/06/what-humans-would-look-like-if-they-were/" />
    <id>tag:www.boundvariable.com,2010://1.54</id>

    <published>2010-01-05T23:00:11Z</published>
    <updated>2010-01-05T23:42:54Z</updated>

    <summary>The human body just wasn&#8217;t designed for modern times. Here&#8217;s what the redesign looks like: There is a PDF of the full article from Scientific...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>The human body just wasn&#8217;t designed for modern times. Here&#8217;s what the redesign looks like:</p>

<p><img alt="human.gif" src="http://www.boundvariable.com/images/human.gif" width="382" height="375" class="mt-image-none" style="" /></p>

<p>There is a <a href="http://web.mac.com/sjayo/SJayOlshansky/Background_files/SciAm-Evolution.pdf">PDF</a> of the full article from Scientific American.</p>

<p>While we&#8217;re on the topic of things that need a redesign, human language is pretty crap&#8230; what we really need is something carefully constructed (like <a href="http://www.lojban.org/tiki/Lojban">Lojban</a>) instead of the the complete mess we have with languages such as English. </p>

<p>Don&#8217;t we just know this Lojban thing is going to sell like hotcakes?</p>

<p>Even if they&#8217;re better, our designs suck before we&#8217;ve even started on them&#8230; they remain that way until users have taken them away and claimed ownership and we no longer feel like calling them <em>our</em> designs.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Closure drive</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/11/11/closure-drive/" />
    <id>tag:www.boundvariable.com,2009://1.51</id>

    <published>2009-11-10T22:42:32Z</published>
    <updated>2009-11-18T12:05:30Z</updated>

    <summary>I don&#8217;t much like Google&#8217;s new Closure library and compiler. Here&#8217;s why&#8230; I have a vivid memory of watching the David Lynch movie Eraserhead where...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="JavaScript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>I don&#8217;t much like Google&#8217;s new Closure library and compiler. Here&#8217;s why&#8230;</p>

<p>I have a vivid memory of watching the David Lynch movie Eraserhead where towards the end I finally turned to the person next to me and we both slowly voiced the phrase &#8220;what was that?&#8221;</p>

<p>I had déjà vu recently when I waded through the announcement on Google&#8217;s Closure compiler and library for JavaScript.  Had I just walked into a David Lynch movie set on planet Google? Had somebody just pulled a Gordian knot tight around me? If so, with what razor could I cut it apart?</p>

<p>Some <a href="http://bolinfest.com/javascript/inheritance.php">smart</a> <a href="http://erik.eae.net/archives/2009/11/09/21.12.16/">people</a> have chimed in on the side of Google and spoken poorly of a number of common coding techniques for JavaScript programmers with  Crockford&#8217;s module pattern being one example. Their complaint? That modern techniques employed by JavaScript coders were inefficient&#8230;</p>

<p><a href="http://dmitry.baranovskiy.com/">Dmitry</a> then had a look at some of the Closure source code and <a href="http://www.sitepoint.com/blogs/2009/11/12/google-closure-how-not-to-write-javascript/">pointed out</a> that compilers aside, some of the coding techniques used in Closure are inefficient for JavaScript.. and that some others are just plain silly. Borrowing a phrase from Dmitry&#8230; I don&#8217;t know what they call that in Java, but I call it irony.</p>

<p>For the record, and to clear up any potential ambiguity caused by my often circuitous writing style. I agree with Dmitry. Other libraries such as jquery may have their issues but the design of the part that <em>people</em> interact with (you know, the API) is overall something other libraries would, for the most part, do good to emulate.</p>

<p>I had a look through the source for closure myself and whilst there&#8217;s some useful stuff in there it feels a bit like a bag of nails and is about as inspiring as one. Slider examples that use 44 different individual scripts (I&#8217;m sure the compiler fixes that right?), a unit testing framework apparently from 2009 shoehorned into code apparently written in 2004 (better late than never) and a bunch of things that really don&#8217;t seem like they belong in a decent general purpose library such as pretend constants like the one for the default size of a popup window and finally some stuff that really shouldn&#8217;t be in any JavaScript code anywhere, such as <code>!= 0</code>. Now, there may be good reasons for these and I&#8217;m not questioning the coding ability of the people who wrote it. Instead, I&#8217;m questioning the extent to which they might still (if they ever did) consider themselves JavaScript natives. Most people coding in JavaScript stopped writing code the way suggested by the proponents of the closure compiler years ago because we were sick of fighting the language. Dmitry is one of those people and library authors should pay attention.</p>

<p>What bothered me about Closure more than anything though was the (apparent) accompanying mentality that they know the <em>right</em> way to do things and that other JavaScript programmers are living in the dark ages banging rocks together. Still, I shouldn&#8217;t be that offended that somebody has a different idea about how to write good code&#8230; and yet, there I was&#8230;</p>

<p>What was it that bothered me so much?</p>

<p>The real thing that pissed me off is a suggestion that <em>I</em> should write worse code to optimise for <em>their</em> compiler. Last I checked it was 2009 and I gladly wrote my last malloc more than ten years ago. If the interpreter or compiler wants to run better then somebody ought to fix the compiler. I&#8217;ve had enough IE6 for the last eight years to know that having to tailor my development approach to a computer, instead of to a human is nothing but pain from start to finish and that worse&#8230; spending all my time looking inwards to the computer instead of outwards invariably results in a crap user experience for the people that really matter - my users - whether that&#8217;s coders I work with or who inherit my code or users of the UI that I&#8217;m writing.</p>

<p>Some of us who work in JavaScript every day are trying to improve JavaScript and the coding environment to make it better. We all want to make JavaScript suck less&#8230; these other guys (yes, I&#8217;m deliberately phrasing this divisively), they&#8217;re trying to make the language suck more by making JavaScript developers kowtow to their compiler. Or worse, by making people write Java that compiles to JavaScript&#8230; but that&#8217;s a story for another day.</p>

<p>Pseudo-classical inheritance simply doesn&#8217;t make sense in JavaScript. JavaScript works better with object cloning, mixins, shallow (think wading pool) hierarchies, literal notation, and closures. Trying to do elaborate inheritance in JavaScript generally ends up in dog shit. I know because I&#8217;ve stepped in it.</p>

<p>It would be nice to get some more of <a href="http://selflanguage.org/">Self</a> into JavaScript&#8230; in other words, it would be nice to have a better prototypal system with dynamic inheritance and traits. I would need to see the associated complexity tax tested first though as I&#8217;m not sure if the language can float those but perhaps&#8230; and perhaps multi-methods, perhaps macros&#8230; I&#8217;m not sure, I&#8217;ll leave that to the language designers.</p>

<p>Anyway, it would <em>not</em> be better to get more of C++ into JavaScript. People absolutely need to remember that. The world has moved on.</p>

<p>Yes, personal preference but&#8230; Friends of Closure, please stop telling people they&#8217;re doing things wrong because based on <em>your</em> development style and using <em>your</em> compiler <em>your</em> way works better for you.</p>

<p>Finally&#8230; just to really nitpick, the name really blows. Both because the library doesn&#8217;t feel especially functional and because it sounds too much like the completely awesome <a href="http://clojure.org/">Clojure</a> language&#8230;</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Note to self... String.split borked</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/10/13/note-to-self-stringsplit-borked/" />
    <id>tag:www.boundvariable.com,2009://1.50</id>

    <published>2009-10-13T05:52:06Z</published>
    <updated>2009-10-13T11:41:23Z</updated>

    <summary>I&#8217;m writing this one down because despite being burned by it before I still haven&#8217;t learned my lesson and got caught out once again. I...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="JavaScript" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>I&#8217;m writing this one down because despite being burned by it before I still haven&#8217;t learned my lesson and got caught out once again. I thought that perhaps posting it up here would finally prompt me to remember it.</p>

<p><code>String.prototype.split</code> with a regular expression has for a long time generally been stuffed across the major browsers. This has been documented before, <a href="http://blog.stevenlevithan.com/archives/cross-browser-split">Steven Levithan</a> even has a nice replacement available.</p>

<p>Whilst there are issues in several browsers, the biggest pain-in-the-butt award though has to go to&#8230; wait for it&#8230; IE.</p>

<p>Why does <code>"...".split(/\./)</code> not produce the same result as <code>"...".split(".")</code>?</p>

<p>I know the old ES3 spec had some issues but really&#8230; aneurysm inducing stuff.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Surface tension</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/09/08/surface-tension/" />
    <id>tag:www.boundvariable.com,2009://1.47</id>

    <published>2009-09-08T06:14:05Z</published>
    <updated>2009-09-08T06:42:46Z</updated>

    <summary>For some problems a talented designer is able to create a tiny solution that floats on water. Sometimes a solution like that is exactly what...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>For some problems a talented designer is able to create a tiny solution that floats on water. Sometimes a solution like that is exactly what is required at the time. However, the very real limits to the size of a solution that will float in such a way should be observed. If the problem changes it&#8217;s usually better to find a new solution instead of struggling to find ways to get the tiny one to float with a donkey on its back.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Higher order programming?</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/09/04/higher-order-programming/" />
    <id>tag:www.boundvariable.com,2009://1.46</id>

    <published>2009-09-04T03:07:50Z</published>
    <updated>2009-09-04T04:31:44Z</updated>

    <summary>So this year I entered codejam and decided to write all my answers in JavaScript. Usually I would solve any given problem in the language...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="c" label="C" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="codejam" label="codejam" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="lisp" label="lisp" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="polyglotprogramming" label="polyglot programming" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>So this year I entered <a href="http://code.google.com/codejam/">codejam</a> and decided to write all my answers in JavaScript. Usually I would solve any given problem in the language I felt most suitable but, I write much more JavaScript than I do anything else and the familiarity means I can write a bit faster&#8230;</p>

<p>It&#8217;s not going too well.</p>

<p>I got through the qualification round ok despite &#8220;hitting the wall&#8221; by the third of the three problems on offer. The reason I say it&#8217;s not going too well is the rubbish code I&#8217;ve created. My JavaScript looks like bad C.</p>

<p>My code is too crap to post here. Anybody who really wanted to could probably find it on the codejam site with some effort. I suggest nobody bother.</p>

<p>Anyway, hopefully by now there&#8217;s not many people around who still need convincing that JavaScript isn&#8217;t bad C or indeed, a C derivative at all&#8230; despite the semicolons and curly braces.</p>

<p>Still, apart from one decent object mapping section in my solution to the second problem, my solutions so far look and feel like C. Bad C. What happened to all the functional, higher order and prototypical object system code? What happened to using JavaScript the <em>right way</em>?</p>

<p>At first I told myself that the types of problems presented were really geared towards that style of coding and that it wasn&#8217;t my fault. Then I went over and had a look at some <a href="http://www.go-hero.net/jam/08/">statistics</a> from the 2008 competition.</p>

<p>The first thing I looked at was the <a href="http://www.go-hero.net/jam/08/lang/Lisp">competition stats for Lisp</a>. There weren&#8217;t many people in the competition using Lisp but those that did use it were doing fine. Some really elegant solutions among the answers.</p>

<p>It&#8217;s interesting to go through the solutions in different languages and see how people are using those languages under the pressure of a limited amount of time for code that they know is immediately throw-away. I&#8217;ve been doing a bit of <a href="http://clojure.org/">Clojure</a> lately which may influence my opinion but the good Lisp solutions read much better that anything else I found. I know that there are a lot of exceptional C and C++ programmers out there and they were well represented in the best performers in the 2008 codejam but to me, looking at some of the code&#8230; if it was me I would probably choose not to solve the problems at all than have to write some of that code&#8230; No fun.</p>

<p>Personal preference? I know there&#8217;s a million C programmers out there who are much more talented programmers than I am. It&#8217;s just that, if I somehow became an awesome C programmer I&#8217;d also have an awesome migraine.</p>

<p>I&#8217;m a JavaScript guy and I do User Interface. If my code feels ugly and I&#8217;m not enjoying writing it that tends to infect the User Interface&#8230; and it&#8217;s the User Interface that <em>really</em> matters.</p>

<p>Anyway, for me I think it&#8217;s going to be back to <a href="http://mitpress.mit.edu/sicp/">SICP</a> or <a href="http://www.ccs.neu.edu/home/matthias/BTLS/">The Little Schemer</a> to see if I can rewire my brain to start solving programming problems in more elegant ways. If you&#8217;re like me, and wouldn&#8217;t want to be an exceptional C programmer even if you magically became talented enough to be one then I might suggest you do the same.</p>

<p>After that? Perhaps <a href="http://www-cs-faculty.stanford.edu/~knuth/taocp.html">The Art of Computer Programming</a>.</p>

<p>On another note, looking through some of the contestants there are a few examples of polyglot programmers who write solutions in a dozen different languages. Impressive stuff. </p>
]]>
        

    </content>
</entry>

<entry>
    <title>Toxic</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/09/01/toxic/" />
    <id>tag:www.boundvariable.com,2009://1.41</id>

    <published>2009-08-31T23:18:57Z</published>
    <updated>2009-09-02T12:44:19Z</updated>

    <summary>Since before the beginning of the industrial age man has been cutting, burning and dumping waste on the land and in the river. At times,...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>Since before the beginning of the industrial age man has been cutting, burning and dumping waste on the land and in the river.</p>

<p>At times, (m|b)illion dollar companies have laid waste to the terrain, maimed people and destroyed lives and ecosystems.</p>

<p>The Internet, whilst man-made has evolved something of a digital ecosystem. It&#8217;s not as precious and probably reproducable but that doesn&#8217;t mean any more that it&#8217;s acceptable to dump pollutants into the river.</p>

<p>Thirty years from now, will some names be infamously associated with toxic waste on The Internet?</p>
]]>
        

    </content>
</entry>

<entry>
    <title>How far have we come?</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/08/03/how-far-have-we-come/" />
    <id>tag:www.boundvariable.com,2009://1.44</id>

    <published>2009-08-03T11:03:53Z</published>
    <updated>2009-08-11T01:20:13Z</updated>

    <summary>Note: this is a sketchy rant and I haven&#8217;t backed up my arguments to any great detail. I don&#8217;t know why I feel the need...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>Note: this is a sketchy rant and I haven&#8217;t backed up my arguments to any great detail. I don&#8217;t know why I feel the need to state that on my blog but&#8230; there it is. </p>

<p>Anyway&#8230;</p>

<p>The recent release of the source code for the Lunar Lander had me thinking about the relative value of code and whether programming has really advanced much in the last fifty years in terms of what people are actually achieving with software. How far have we come?</p>

<p>I&#8217;m probably like most &#8220;modern&#8221; programmers - when I looked at the source code for the Lunar Lander I was simultaneously astonished, horrified and embarrassed. My single adventure into the land of assembly programming left me with painful memories of hours spent writing and testing hundreds of lines of machine code for the Motorola Z80 in order to get a speaker to beep. Writing assembly code is painful. How on earth did programmers manage to write assembly code to send man to the moon?</p>

<p>Reading <a href="http://www.netjeff.com/humor/item.cgi?file=ApolloComputer">this interview</a> from Allan Kump managed to shed some light on it for me. The Lunar Lander module code was designed by about 300 people over a 7 year period for 46 million dollars in 1967. This puts the apparent pyramid building feat of the LM into some perspective. They succeeded because they had to. It took a great deal of time, money and people to succeed.</p>

<p>Even then, I might question how they managed to achieve what they did without modern development techniques and engineering practices&#8230; or a drawn out beta period. How did they avoid bugs? How did they manage this task without a higher level language.</p>

<p>I don&#8217;t know much about their development process. I don&#8217;t think I need to and, really, I don&#8217;t find it that interesting to ponder. How about the question of bugs and no higher level language? Well&#8230;.</p>

<p>Firstly, they <em>did</em> write it in a higher level language which they hand-compiled to the machine code and secondly the code was never bug free and at least one of those bugs could have been catastrophic.</p>

<p>However, it still disturbs me that in fifty years, we haven&#8217;t really come all that far. 1967, what else happened in 1967?</p>

<p>A fully mechanical ABS was in the Ferguson P99 (Mercedes had the first electronic version in their 1978 S-class).</p>

<p>Not that interesting. What is interesting though is this: <strong>Lisp was first specified in 1958</strong>.</p>

<p>You know what McCarty said about Lisp?</p>

<p>&#8220;Lisp will become obsolete when someone makes a more comprehensive language that dominates Lisp practically and also gives a clear mathematical semantics to a more comprehensive set of features.&#8221;</p>

<p>Note that it says obsolete, not untrendy.</p>

<p>I don&#8217;t want to get into debates around the why of Lisp not particularly been a popular success but it was first specified <em>before</em> work commenced on the lunar module. Would it have been a good idea to design the lunar module in Lisp?</p>

<p>The answer, I think, is no. </p>

<p>Why? The designers needed to keep touch with the input, output and with the system that they were interfacing. I don&#8217;t know how this would be achieved in Lisp at the time. I have no backing evidence for this but (this is the web and I&#8217;m writing on a blog so hey, I don&#8217;t need any) I&#8217;d say Lisp would not have been very close to the problem domain the developers were working in given that they ultimately had to <em>hand compile</em> it down to machine code.</p>

<p>What if it was 2009 instead of 1967 though? What about finding 300 developers in 2009 to write the Lunar Lander control module? What language?</p>

<p>For 300 developers today, chances are that Lisp still wouldn&#8217;t be chosen, or any functional language for that matter. Parentheses aside, cultural issues aside, accidents and convenience aside - the thing is that really, most developers simply do not grok the concepts <em>at all</em>&#8230;</p>

<p>I&#8217;ve been looking at some legacy code recently and the same old pattern has emerged there as I see everywhere else. The list of things that many developers seem to understand sufficiently to be comfortable using is about four things: SQL, procedures, global variables, XML.</p>

<p>For front-end developers just replace SQL with CSS.</p>

<p>Either most developers only know those things or most developers simply feel they can solve any problem with that magical quartet. Well yeah, they probably <strong>can</strong> solve all their problems with that - in a completely non-flexible, non-extensible and generally kludgy manner. Nobody cares though right? It&#8217;s all abandonware anyway, somebody will come back in ten years with an even bigger budget and redo the whole thing again exactly the same in a different system but this time use thirty times the CPU as last time.</p>

<p>Lisp (or another functional language) is simply too hard because it&#8217;s almost impossible to write the kind of really ugly, shit code that I know - because I&#8217;ve seen it - exists in too many code bases for legacy and modern systems written, in many cases, by decent programmers. Sure, it&#8217;s possible to write another sort of rubbish code but in my experience people who are going to write rubbish code aren&#8217;t bothered to learn clever ways to do so&#8230; The most basic features of the most accessible language will do just fine.</p>

<p>The solution to the <em>nobody gets it</em> problem, according to some pundits, was going to be Object Oriented programming. I&#8217;m actually quite confident that to a large extent that was a massive success. Why? Because, despite a bit of initial confusion it seems that a greater percentage of developers than are able to grasp other composing techniques are able to grasp the concept that instead of having lots of procedures they can partition their code into&#8230; ummm&#8230; <em>things</em> and attach procedures (methods) to those things/objects. Not making great use of OO but it&#8217;s a start.</p>

<p>Even given that, too many developers will still code by creating a bunch of procedures, initiate them from a starting point and pass any shared state they need to via whatever global mechanism the language allows. Why? Because it&#8217;s easier and they don&#8217;t need to know much of the language to do it. This is a curse that has struck many languages. JavaScript, meet the curse. Curse, meet JavaScript.</p>

<p>Going back to the legacy system I mentioned earlier&#8230; What is the dirty, horrible barbarian language it was written in? I&#8217;d rather not say, but&#8230; it has lambda (hand-waving version at least) among some other nice language features that help to compose software. Sure it&#8217;s got some oddities but&#8230; It has lambdas!</p>

<p>Perhaps this is the same tired old story paraded around but really; this legacy system might as well have been written in <strong>any</strong> language if&#8230; and only if, that language was used for nothing but lots of (basically) global procedures and variables. The developers (or most of them) had a language with some expressive power and they used none of it. Again, reminds me of JavaScript. At least JavaScript stopped short of letting people ram most of their code into SQL or XML&#8230; No wait, somebody figured out how to do that in JavaScript too.</p>

<p>So the new, non-legacy, replacement system is written in a modern Object Oriented language. I haven&#8217;t looked at the code base but my bet is that really it&#8217;s only Object Oriented as far the developers were forced to code in a (kinda) Object Oriented language. The attention in the code to actually doing Object Oriented is probably only as much as the developers are baptised members of the church of Object Orientation and they&#8217;re really scared of being excommunicated. Oh sure, there&#8217;s probably a bit of a perverse bastardisation of MVC shoved in there somewhere and they might map objects to the db and they probably have lots and lots of middleware and instead of a custom configuration script conjured up by a developer there&#8217;s probably nine hundred XML files instead but&#8230; you get the idea.</p>

<p>Of course, what the new system has is libraries and API&#8217;s ready to go that reduce the amount of actual code that any developer on the current system has to write. Now, instead of learning a language and how to program effectively in that language there&#8217;s a tendency for people to learn the language basics and then refer everything to an API that serves as a tourist dictionary. Of course, there&#8217;s more than one API and these language tourists are walking around with a bag full of dictionaries trying to communicate. This has nothing to do with the merit of one language versus another or the incredible usefulness of well designed API&#8217;s&#8230; It has everything to do with tools being applied where they should or being used as a crutch for an unrelated deficiency.</p>

<p>How far have we really come? I wonder.</p>

<p>Ever noticed how C presents with some immediacy those language features that are the first to be learned? <em>Hello World.</em> <em>My Name is&#8230;</em> <em>Count to ten.</em></p>

<p>There are many powerful mechanisms in C and many more powerful language constructs but fundamentally the simplest of programmers really only groks just enough of a programming language to get around as a tourist. Oddly enough, the popularity of most programming languages is independent of their actual merits and most closely tied to how easily a tourist is able to find the nearest public toilet.</p>

<p>Perhaps because of this shortcoming the general approach over time seems to have been removing the language aspect of programming as much as possible. Given that developers are not capable storytellers in the programming language they have to use a whole heap of effort goes into IDE&#8217;s and tools by which developers are able to avoid writing programs. So great was the extent of this that the era of GUI programming came about in many arenas from WYSIWYG to a misguided hope that one day developers could create UML diagrams and have a large proportion of their code written for them. </p>

<p>That was the dream. People would go to the nth degree to model everything and design everything up front and the handle got cranked and out popped a UML diagram. The model would be run through a model checker and then the handle would get another crank and out popped all the code nicely done. Application finished.</p>

<p>Then what?</p>

<p>Then it&#8217;s discovered that nobody can use it because the &#8220;developers&#8221; were too busy navel gazing to check at any point if the original specification provided something that anybody could use&#8230; assuming anybody even wanted anything like it in the first place.</p>

<p>I think it is a mistake for anybody to think that programming is purely an exercise in symbol manipulation with developers sitting in their <a href="http://en.wikipedia.org/wiki/John_Searle">Searle</a> Chinese Room translating symbols from one representation to another.</p>

<p>Actually, I don&#8217;t think it&#8217;s <em>just</em> a mistake. I think it is exactly the wrong idea. The removal of emphasis from language is wrong. Humans are good at language, exceptional at language, but instead of applying that linguistic ability the trend was towards making people push coloured blocks around a page as if the extent of their creative ability was on par with a parrot such as <a href="http://www.primidi.com/Alex_The_Brainy_Parrot_Who_Knows_About_Zero">Alex</a>.</p>

<p>Alex can&#8217;t tell stories. Programming is about telling a story. </p>

<p>Good programmers have a concept in their head about the software they&#8217;ve written, a narrative through a story told by the code they have written. Code smell? It&#8217;s a result of a poorly constructed story, a bad plot, wooden dialogue.</p>

<p>Programming <em>should</em> be a linguistic activity, it should be a craft and it should have a design component. A good program should read well and be entertaining all by itself. It makes absolutely no sense to me that anybody would want to remove the language component for programmers unless we really want to start using parrots to do software architecture&#8230; pushing those coloured blocks around and churning out software.</p>

<p>As for that Lunar Lander&#8230; I bet every single person working on that project was excited to be working on a system that was involved in sending humans to the moon. That&#8217;s a pretty good incentive for making sure it works regardless of what it was coded in. </p>

<p>Anyway, apparently they built the pyramids without any computers at all. I sure bet they had language though.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Dynamic inheritance?</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/07/24/dynamic-inheritance/" />
    <id>tag:www.boundvariable.com,2009://1.42</id>

    <published>2009-07-24T04:03:26Z</published>
    <updated>2009-07-24T07:12:14Z</updated>

    <summary>Chris Double has some nice examples over on his blog for using dynamic inheritance in Self and Io. As JavaScript is similar to Self and...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>Chris Double has some nice <a href="http://www.bluishcoder.co.nz/2009/07/prototype-based-programming-languages.html">examples</a> over on his blog for using dynamic inheritance in <a href="http://selflanguage.org/">Self</a> and <a href="http://www.iolanguage.com/">Io</a>. As JavaScript is similar to Self and Io (as far as it also has a prototypical object system) Chris mentions with regards to JavaScript:</p>

<blockquote>
  <p>JavaScript is also a prototype based programming language. Unlike Self or Io it only allows one object to be used as the prototype in any given object. This is stored in a hidden &#8216;__proto__&#8217; member and cannot be updated once set on construction (some implementations allow changing it however). Objects are created by using the &#8216;new&#8217; keyword on a constructor function that initializes the object. For now I&#8217;ll leave it as an exercise for the reader to implement the examples above in JavaScript. I&#8217;d be interested in the approaches people take.</p>
</blockquote>

<p>So, interested at seeing how I might approach this I sat down to recreate the Self example in JavaScript without resorting to manipulating __proto__ which isn&#8217;t in the spec and will not work cross-browser.</p>

<p>Failed miserably.</p>

<p>Without multiple inheritance and with the prototype reference locked in for the life of the object I only ended up chasing code down rabbit holes.</p>

<p>Finally, in desperation I settled on what I thought was the least crappy option:</p>

<pre>
// In the absense of ES5's Object.create
function object(o) {
    function F() {}
    F.prototype = o;
    return new F();
}


var file = (function () {  

    var that = {
        close: function () {
            console.log("closing");
            this.close = null;
            this.open = that.open;
        },
        open: function () {
            console.log("opening");
            this.open = null;
            this.close = that.close;
        }
    },
    stub = object(that);

    stub.close();

    return stub; 
}());


var myFile = object(file);
myFile.open();  
myFile.close(); 
myFile.open(); 


var myFile2 = object(file);
myFile2.open(); 
</pre>

<p>Whilst the prototype link may be fixed at construction I know that in JavaScript all the &#8220;user&#8221; object properties are dynamic and able to be set (unless it&#8217;s ES5 and the object has been frozen or the property been made non-writable) - meaning that I can dynamically turn properties &#8220;on&#8221; and &#8220;off&#8221; as needed.</p>

<p>This only superficially achieves the results of the example by switching functions in and out of slots on <code>this</code>, it does not give a flexible prototypes with traits system as outlined in Ungar&#8217;s <em><a href="http://research.sun.com/self/papers/organizing-programs.html">Organizing Programs Without Classes</a></em> paper. However, JavaScript is a flexible language and it wouldn&#8217;t be all that hard to implement something more sophisticated that would get the desired effect. Unfortunately, as with attempts to foist class systems onto JavaScript the end result is typically kludgy and the resulting code built on top of such an approach would not be idiomatic JavaScript.</p>

<p>Sure, multiple inheritance and dynamic inheritance is powerful in Self and might have gone nicely with JavaScript&#8217;s prototypical objects but they aren&#8217;t there and trying to get too clever in a scripting language can make you Br&#8217;er Rabbit stuck to a <a href="http://en.wikipedia.org/wiki/Tar_baby">tar baby</a>. I think that in JavaScript it&#8217;s best to stick to a shallow inheritance hierarchy that doesn&#8217;t use traits and use other compositional techniques that feel more natural to the language.</p>

<p>That said, somebody else may have a particularly elegant way to do this that I have completely missed. If so, I&#8217;d definitely like to see it.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Renounced magic</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/06/27/renounced-magic/" />
    <id>tag:www.boundvariable.com,2009://1.39</id>

    <published>2009-06-26T13:56:53Z</published>
    <updated>2009-06-29T04:17:00Z</updated>

    <summary>I started working on a quick port of blosxom to JavaScript running on v8cgi mostly because every programming language needs a blogging engine and JavaScript...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
    <category term="opinion" label="opinion" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>I started working on a quick port of <a href="http://www.blosxom.com/">blosxom</a> to JavaScript running on <a href="http://code.google.com/p/v8cgi/">v8cgi</a> mostly because every programming language needs a blogging engine and JavaScript kinda doesn&#8217;t have one.<a href="#footnote1" id="footnote1-a">*</a> Despite being potentially superfluous, a post on it might have made a good read. Unfortunately I temporarily lost interest so that will have to wait for another day.</p>

<p>Instead, I decided to write something that&#8217;s barely related to JavaScript because, well, if I don&#8217;t write I quickly forget <em>how</em> to write - to point where I&#8217;ll spend ten minutes composing a two sentence email only to delete and never send it because it didn&#8217;t make sense. Anyway, here goes. I&#8217;m breaking a few rules in the following text so I can only hope the reason won&#8217;t be lost in the reflection.</p>

<p>In order to pay the &#8220;bills&#8221; during my years at university I used to tutor high school Maths, Physics and English. At first the syllabus for each subject was fairly close to what I&#8217;d been through myself but as each year passed I noticed bizarre things happening to each subject as they were morphed into things I barely remembered until eventually every last equation had been removed from Physics and <a href="http://en.wikipedia.org/wiki/Higher_School_Certificate">HSC</a> English students started telling me they were studying <em>Blade Runner</em>. </p>

<p>Truth be told, I don&#8217;t really like maths all that much (many years since leaving uni it&#8217;s still possible to give me a mild panic attack by asking me to calculate an <a href="http://en.wikipedia.org/wiki/Autocorrelation">autocorrelation</a> coefficient) so I could probably have done without tutoring HSC Maths. I did generally enjoy tutoring English though.</p>

<p>The first lesson with a new student was always interesting. Generally it would begin with a fifteen minute chat with the parents - a chat that would tell me nothing about the student except that their parent had absolutely no idea what their children were doing at school. I&#8217;m not much for making light conversation but the preamble seemed important in making the parents feel comfortable and involved and they always liked it when I told them their child was talented and capable of doing well in English but had never been taught how. (I also had to teach some of the kids to spell despite the parent assuring me it wasn&#8217;t necessary because, you know, computers meant nobody needed to spell anymore.)</p>

<p>The student would be ready with the texts they had been assigned for the year and a stack of notes given to them by their teacher. That stack of notes would invariably contain a few sheets containing quotes that the teacher thought students were supposed to learn. For every student that I tutored though, there were only really ever two problems that needed work.</p>

<p>The first was that all-too-often they hadn&#8217;t actually read the text, or if they had read it they hadn&#8217;t taken the time to understand it. The solution to that was fairly easy. Tell them to read it and come back the following week promising to do nothing but sit there for an hour whilst they explained the text to you. It&#8217;s amazing what most people will do to avoid an hour of awkward silence.<a href="#footnote2" id="footnote2-a">&#8224;</a></p>

<p>The second problem was the important one. Every single person that I tutored HSC English to had absolutely no idea how to approach composition. It might have been tempting to think that they had no idea how to write effectively because they had missed that day in school but that wasn&#8217;t the case. I don&#8217;t know if it&#8217;s been different in other times or other parts of the world but most of what these kids learnt at school was about turning up in the morning and sitting at a desk all day.<a href="#footnote3" id="footnote3-a">&#8225;</a></p>

<p>These kids, or teenagers, had no idea what they were supposed to write except that somebody had told them that they needed to produce something called an essay with an introduction, body and conclusion and that they should litter it with the quotes supplied in the relief package. These essays were terrible, starting with &#8220;In this essay I will talk about&#8221; and rapidly declining from there.</p>

<p>So, I would spend one hour telling these kids how I approached composition (not sure if that part helped) and then assigned them a truck load of writing exercises which we&#8217;d look at the following week.</p>

<p>The writing exercises worked. </p>

<p>I don&#8217;t know if any of those former students still write anything longer than an SMS but the impact of seeing smart kids with valuable ideas completely unable to put them across on paper has always stuck with me.</p>

<p>I think writing matters. More importantly I think <em>good</em> writing matters.  I also think that like most of the things I grew up with it will eventually be put through the photocopier enough times that only a <a href="http://en.wikipedia.org/wiki/Loch_Ness_Monster">surgeon&#8217;s photo</a> will remain. I think that&#8217;s a shame.</p>

<p>I think writing matters and that&#8217;s one of the motivations for spending the time to write (and rewrite) the posts on this site.  I also think it helps me extract my mind from programming flatland&#8230; though I have little supporting evidence for that one.</p>

<p>Anyway, finally to the point. One of the great things about the web for me has always been that it gave more people an opportunity to explore and express the ideas they had to an engaged community.</p>

<p>I may be subscribing to the wrong sites but watching the declining quality of posts in my feed reader doesn&#8217;t seem encouraging. The number of link blogs, top ten lists, twitter summaries, spam, trolling and product whoring seems to be steadily increasing. I know some of these things have traditionally been considered synonymous with The Internet but for a while there it actually seemed like there was a lot of effort going to producing quality writing. Am I still looking at originals or is it all photocopies? Do people still write or is it all just out takes, bloopers and greatest hits? Does anybody care?</p>

<p>&#8212;</p>

<p><small id="footnote1">* There is actually at least one built on Helma used on reasonably high traffic production sites such as <a href="http://www.blogger.de/">blogger.de</a> but I am conveniently choosing to ignore them for the moment. <a href="#footnote1-a">&#8593;</a></small></p>

<p><small id="footnote2">&#8224; In hindsight there may have been some motivation in not wanting to pay me to sit there for an hour and do nothing. Hard to say. <a href="#footnote2-a">&#8593;</a></small></p>

<p><small id="footnote3">&#8225; I don&#8217;t mean to criticise the education system for teaching kids these two things as they are as essential for keeping a job as brushing and flossing are essential for keeping teeth. <a href="#footnote3-a">&#8593;</a></small></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Cascading</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/06/24/cascading/" />
    <id>tag:www.boundvariable.com,2009://1.38</id>

    <published>2009-06-24T12:58:44Z</published>
    <updated>2009-06-25T12:16:05Z</updated>

    <summary>It&#8217;s possible to criticise CSS for solving the wrong set of problems. Whilst I am talking about CSS here, I am not talking about that....</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
    <category term="opinion" label="opinion" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>It&#8217;s possible to criticise CSS for solving the wrong set of problems. Whilst I am talking about CSS here, I am not talking about <em>that</em>. CSS has been an undeniable success in terms of removing a heap of cruft from HTML. I don&#8217;t think people should be happy to stop at that though. There are problems.</p>

<p>Anyway, I&#8217;ve written a fair amount of CSS in my time. At least, I&#8217;ve written enough CSS that there&#8217;s a chance that I&#8217;m partly responsible for the great wad of legacy CSS that you hate working on every day.</p>

<p>If I might quote Toad from the <a href="http://www.amazon.com/Wind-Willows-Richard-Pearson/dp/B0002V7NXO/ref=pd_cp_d_0">claymation movie</a> version of <em>Wind in the Willows</em>&#8230;</p>

<p>I&#8217;m not sorry so it&#8217;s no good saying I am.</p>

<p>At one point in time a front-end developer working on legacy code would be staring at a vast sea of nested tables created by a tool such as FrontPage - trying to figure out where in that sea they needed to add their code such that it won&#8217;t cause the layout to barf table everywhere.</p>

<p>These days it&#8217;s just as likely that a front-end developer will be working on legacy code and be starting at a vast sea of <strong>my</strong> CSS trying to figure out what last-minute 2am bug report had prompted the use of so much &#8220;!important&#8221;.</p>

<p>Actually, it&#8217;s worse than that. These days it&#8217;s just as likely that as a front-end developer you will be working on a vast sea of <strong>your own</strong> legacy CSS&#8230; written only three months ago. The thing with CSS is that most of it is legacy as soon as it&#8217;s written. This is not a criticism of people writing CSS, I&#8217;ve seen people with good ideas put a lot of thought into the best way to maintain CSS with good results. I just don&#8217;t think CSS is really helping those people solve their problems.</p>

<p>Let&#8217;s say that you decide to write new CSS to replace somelegacy code. What&#8217;s the usual approach? </p>

<p>Start with a blank file, insert standard browser reset code and off you go.</p>

<p>I can&#8217;t think of another coding discipline where even proficient, thoughtful coders achieve so little reuse from project to project.</p>

<p>Now, in the time since I last wrote any large amount of CSS that somebody else has had to work on, I&#8217;ve seen a lot of promises about the latest trend in writing or organising CSS. Indent it this way, indent it that way. Put these comments in. Group by specicifity. Group by function. Break it down this way. Break it down that way. Make it Object Oriented!</p>

<p>Yup&#8230; I heard that news about using component based architecture for CSS. Component based architecture makes a lot of sense. I <em>still</em> bet the next time you work on a completely new project you start with an empty file and CSS every single line from go to woe without reusing more than half a dozen classes from the last project you worked on.</p>

<p>It&#8217;d be nice if a component based approach actually resulted in front-end developers being able to <em>compose</em> a new site from an existing set of components. It&#8217;d be nice if there was, I dunno, meta-CSS.</p>

<p>Unfortunately, I can&#8217;t see that happening. Instead, it seems that some front-end developers love writing CSS selectors so much that the only thing they wish to change about that particular 4GL is the lack of variable spaghetti to add to their CSS minestone. I don&#8217;t think variables would help.</p>

<p>It looks like developers love those selectors so much that they&#8217;ve transported them <strong>and</strong> the development technique wholesale to other places such as JavaScript where instead of ever writing an abstraction or component themselves they start with a blank file, a selector engine and&#8230; well, you know&#8230; potato programming all the way. It looks like that because it <strong>is</strong> like that. The reason? CSS <strong>encourages</strong> it.</p>

<p>Just like SQL&#8230; Just like XML. CSS - and the attached mindset - seems to be one of those things that&#8217;s frequently over-applied and relied on too heavily in places where it either doesn&#8217;t belong at all or should only be a small component. There&#8217;s nothing wrong with supporting XML in a programming language but there&#8217;s definitely something wrong when XML becomes the programming language. Similarly, there&#8217;s nothing wrong with supporting CSS selectors in Javascript but there&#8217;s definitely something wrong when CSS selectors become the programming language.</p>

<p>Some may disagree, but I think that as a developer, I shouldn&#8217;t be trying to make everything else look like what I&#8217;m familiar with&#8230; instead I should be trying to make what I&#8217;m familiar with <em>better</em>. I think CSS could be better and I don&#8217;t think much more ground can be gained whilst the language remains as it is.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Space Invaders</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/05/22/space-invaders/" />
    <id>tag:www.boundvariable.com,2009://1.33</id>

    <published>2009-05-21T14:37:42Z</published>
    <updated>2009-05-23T08:23:28Z</updated>

    <summary>A while ago I started experimenting with Dmitry&#8217;s handy Raphaël SVG/VML library for doing some charting. The charting work has not yet seen the light-of-day...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="JavaScript" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="game" label="game" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="raphaeljs" label="raphaeljs" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>A while ago I started experimenting with <a href="http://dmitry.baranovskiy.com/">Dmitry</a>&#8217;s handy <a href="http://raphaeljs.com/">Raphaël</a> SVG/VML library for doing some charting.</p>

<p>The charting work has not <em>yet</em> seen the light-of-day but during some spare moments I had a look at implementing an old arcade game using Raphaël. A very rough, incomplete and buggy approximation of the original Space Invaders.</p>

<p>Given that this is an &#8220;alpha release&#8221; of something on my blog and also that I don&#8217;t really like IE, despite Raphaël supporting IE I never tested this game in IE and hence, in that browser you probably can&#8217;t currently get beyond the intro screen because I didn&#8217;t wire up the keyboard controls. I <em>may</em> get it to &#8220;work&#8221; in that browser if somebody eventually guilts me into it. I probably should get it working in IE because, well, otherwise I&#8217;m partly wasting the benefits of Raphaël over pure SVG? Anyway&#8230;</p>

<p>It does work in Firefox, Chrome and Opera&#8230; possiby Safari, though again&#8230; untested so far.</p>

<p>I used Raphaël for the graphics, <a href="http://www.schillmania.com/projects/soundmanager2/">SoundManager2</a> for the sounds and implememented the top scores over on <a href="http://appjet.com/">AppJet</a> which unfortunately seems to be having occasional problems so I might have to move that to an install of couchdb I have.</p>

<p>Some observations</p>

<ol>
<li><p>JavaScript in the browser is probably fast enough right now for games of this type though you would have to do some optimisation. Apart from some time shift corrections my game code got no speed optimisations. That said, setTimeout and setInterval seem fairly inadequate and difficult to work with. I didn&#8217;t use a global/world clock but that is probably going to be necessary for decent synchronisation.</p></li>
<li><p>I didn&#8217;t spend much time on polishing the game and it shows.To make a highly playable game a huge amount time is going to be tweaking the UI, playability, difficulty progression and generally getting it polished. If web developers consider the amount of effort put into the final polishing stages for a website and multiply it by&#8230; ten&#8230; they might get an idea of how much time would go into polishing something as interactive as a game like Space Invaders.</p></li>
<li><p>I used a boatload of closures and prototypal inheritence via object cloning and didn&#8217;t care about doing any memory cleanup. I don&#8217;t typically use Chrome but V8 really handled that unoptimised code really well. I would expect Tracemonkey to be as good whereas the release of FF3 I&#8217;m using seems to struggle a little.</p></li>
<li><p>Raphaël worked nicely but in order to get the two animation states for the invaders I ended up doing them as sprites and constantly changing the sprite source for all the invaders. Without spending more than thirty seconds looking at Raphaël&#8217;s internals I suspect my code would perform better to do them as actual SVG and just change the path for each state instead of constantly adding and removing sprites.</p></li>
<li><p>I don&#8217;t really think it matter but the code for this Space Invaders version is not MVC. All the objects are responsible for calling the draw and sound API&#8217;s directly based on their own state. I used what is probably more of a morphic style which seemed much more natural for what I was writing.</p></li>
</ol>

<p>For the game, no guarantees given as to whether or not it will crash any browser at any time. There&#8217;s a bunch of timeouts still running when you die so try to not leave your browser sitting on the high score page for any length of time just yet.</p>

<p>Anyway, here it is: <a href="http://static.boundvariable.com/space-invaders/">Space Invaders</a>. </p>

<p>Be warned that <em>it has sound</em>, the sound is a bit crap&#8230; and you can&#8217;t (yet) disable it. Also, I&#8217;m well aware that the second level is basically impossible at the moment. I&#8217;ll look at some improvements in the coming days and weeks.</p>

<p>If anybody wants to see the game code, without having to view source the game itself you can see that <a href="http://static.boundvariable.com/space-invaders/space-invaders.js">over here</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Objects, messages, users, people</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/05/11/objects-messages-users-people/" />
    <id>tag:www.boundvariable.com,2009://1.34</id>

    <published>2009-05-10T23:23:47Z</published>
    <updated>2009-05-20T00:47:13Z</updated>

    <summary>One of the highlights for me at JAOO Sydney 2009 was Dave Thomas&#8217; talk on Cloud computing. Among other things, he talked about the vast...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="language" label="language" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="observations" label="observations" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="programming" label="programming" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>One of the highlights for me at <a href="http://jaoo.com.au/sydney-2009/">JAOO Sydney 2009</a> was <a href="http://www.davethomas.net/">Dave Thomas</a>&#8217; talk on Cloud computing. Among other things, he talked about the vast dinosaur swamp of <acronym title="Object Oriented">OO</acronym> middleware that Java developers will be having fun maintaining for the next thirty years. </p>

<p>As somebody whose programming time is mostly either <acronym title="User Interface">UI</acronym> related in JavaScript or hobby coding in whatever takes my fancy in a given week (this week it&#8217;s <a href="http://factorcode.org/">factor</a>) I was in a good position to laugh in a &#8220;it&#8217;s funny because it&#8217;s not happening to me&#8221; way at the humorous insights from Dave, the self confessed <em>former</em> Pied Piper of Objects. Actually, I found it especially amusing because my recollection of computer science at university in the late 90&#8217;s was that almost every student at the time was begging, demanding, wailing and gnashing their teeth&#8230; to be trained as a member of this army of average Java middleware programmers. </p>

<p>Of course, opting to code UI in JavaScript long ago revoked my membership to the fraternity of real programmers so my hyperbole on these things can freely be dismissed as nonsense by that part of the world shepherding business objects for a living.</p>

<p>I was raised on objects. I like objects. I do not like what we did with them.</p>

<p>In particular, I don&#8217;t like that I can sit in a meeting of non-programmers who <em>once</em> walked past a Computer Science 101 lecture and hear somebody saying that &#8220;we should take an object-oriented approach&#8221; to the problem.</p>

<p>I don&#8217;t like that anybody doing architecture ever talked in terms of <acronym title="Unified Modelling Language">UML</acronym> class diagrams where all the business objects were drawn and detailed and then all the <em>messages</em>, you know the <em>actual stuff going on</em> was reduced to zero. It&#8217;s all interface, all objects and nothing happening. That&#8217;s not designing a living system for code, it&#8217;s designing a pyramid to bury people in.</p>

<p>All objects with no messages, no configurability, no data. Everything else got moved or obliterated until finally, finally when somebody turned around and realised &#8220;Hey, we need ways to do a bunch of this other stuff&#8221; the answer that came forth was <acronym title="Extensible Markup Language">XML</acronym>. So now there&#8217;s this whole universe of people programming all the important parts of their software in XML. I don&#8217;t care to take a guess at how that is going to work out.</p>

<p>Of course, that was all too hard for many people and instead of following the musical pipe they went off to use PHP, broke every single principle of good, bad and ugly software design - including some that weren&#8217;t invented yet, and still managed to get things done. That said, I&#8217;ve done enough work with things such as the Wordpress template system to be reasonably confident that something has gone horribly awry and that there&#8217;s a good chance that a whole community of programmers will also be keeping <em>themselves</em> in jobs maintaining the mess they&#8217;ve created in PHP.</p>

<p>Back to JAOO though, it was good to see a strong representation for dynamic languages, <acronym title="Domain Specific Languages">DSL</acronym>&#8217;s, functional programming and on top of all that, it was good to hear all types of people with a good sense of history and architects talking about service oriented architectures and composition.</p>

<p>Now, at this point I would assume that any lispers still paying attention to current trends can only be wondering why it took so many dances around the prickly-pear tree before more people started to &#8220;get it.&#8221; The lispers may have questions such as &#8220;Did it really take fifty years for lambda to even start entering mainstream consciousness?&#8221; and &#8220;Is XML really what you made of s-expressions?&#8221; and those would be just warm up questions&#8230; what happened?</p>

<p>The shift to <acronym title="Domain Specific Languages">DSL</acronym>&#8217;s is encouraging&#8230; I can only hope that this time we can actually get them right as almost everything that has come before has been an abomination. That goes double for most of the <acronym title="fourth-generation programming language">4GL</acronym>&#8217;s around, I&#8217;m looking at you CSS. The problem with most 4GL&#8217;s is that they were designed to suit the problem, not the people who had to solve the problem. I think one of the big challenges going forward will be how to design languages, or design the space around which languages can develop, that work better for users&#8230; while still maintaining conceptual purity and elegance.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>More or less</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/05/05/more-or-less/" />
    <id>tag:www.boundvariable.com,2009://1.32</id>

    <published>2009-05-05T11:12:03Z</published>
    <updated>2009-05-29T00:38:58Z</updated>

    <summary>I seem to remember once sitting in a software project meeting where the following discussion took place&#8230; &#8216;What day of the month is it?&#8217; he...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="Nothing" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="agile" label="agile" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="baudrillard" label="baudrillard" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="nietzsche" label="nietzsche" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="nonsense" label="nonsense" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="twitter" label="twitter" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>I seem to remember once sitting in a software project meeting where the following discussion took place&#8230;</p>

<blockquote>
  <p>&#8216;What day of the month is it?&#8217; he said, turning to Alice: he had taken his watch out of his pocket, and was looking at it uneasily, shaking it every now and then, and holding it to his ear.</p>
  
  <p>Alice considered a little, and then said &#8216;The fourth.&#8217;</p>
  
  <p>&#8216;Two days wrong!&#8217; sighed the Hatter. &#8216;I told you butter wouldn&#8217;t suit the works!&#8217; he added looking angrily at the March Hare.</p>
  
  <p>&#8216;It was the best butter,&#8217; the March Hare meekly replied.</p>
  
  <p>&#8216;Yes, but some crumbs must have got in as well,&#8217; the Hatter grumbled: &#8216;you shouldn&#8217;t have put it in with the bread-knife.&#8217; &#8224;</p>
</blockquote>

<p>Then again, perhaps it was a dream because I can&#8217;t remember if everybody was standing up or not.</p>

<p>Besides&#8230; in this new hyperreality it all would have been tweets and there&#8217;d be no watch and nobody watching - just a handful of autonomous iPhones tweeting away whilst their owners slept. Roomba style.</p>

<p>In this new hyperreality there are nine thousand eminently usable ways to do useless things and no usable ways to do anything useful. I&#8217;m not sure whether that matters though because at some point &#8220;usable&#8221; will become heterological.</p>

<p>If nobody knows how to write or design software there are at least two options:</p>

<p><ol style="list-style-type:decimal"><li><p>Stare at our navels and argue over a neologism for &#8220;poison the language.&#8221;</p></li></p>

<p><li><p>Repurpose some old software. That may be all we could do regardless because really, there are probably only five different possible software applications, just like there are only seven plots and eskimos have&#8230; what was it at last count?&#8230; nine thousand words for snow.</p></li></p>

<p>Going back to that first scene though. If it were, in fact, a dream then in the next sequence I begin to describe the latest poster child of this trend before quickly being interrupted by a network execubot:</p>

<blockquote>
  <p>Silence hack! We&#8217;ve been monitoring our Nielsen families carefully and during the 12 seconds &#8230; was on screen, viewer eyeball focus was up 90%.&#8225;</p>
</blockquote>

<p>I find it encouraging that everybody is getting better at inventing value from these things. Perhaps the web really is ready to supplant <em>all</em> aspects of television.</p>

<p>If questioned, I will claim that this post <em>may</em> be either the <a href="http://www.imdb.com/title/tt0074486/">Eraserhead</a> of posts on this blog or the <a href="http://www.imdb.com/title/tt0052077/"> Plan 9</a>.</p>

<p>&#8212;</p>

<p>&#8224; Of course, the quote is actually from <em>Alice in Wonderland</em><br/>
&#8225; This one from Futurama Episode 5-15.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>decorate-sort-undecorate</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/03/16/decorate-sort-undecorate/" />
    <id>tag:www.boundvariable.com,2009://1.29</id>

    <published>2009-03-15T23:38:45Z</published>
    <updated>2009-03-16T11:18:49Z</updated>

    <summary>Most Perl programmers would be familiar with the Schwartzian transform which derives from the lisp decorate-sort-undecorate idiom. If you&#8217;re not familiar with it then reading...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="JavaScript" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="idiom" label="idiom" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>Most Perl programmers would be familiar with the <a href="http://en.wikipedia.org/wiki/Schwartzian_transform">Schwartzian transform</a> which derives from the lisp decorate-sort-undecorate idiom. If you&#8217;re not familiar with it then reading the wikipedia article should be a sufficient introduction. Essentially it avoids recalculating the comparisons for each call to sort.</p>

<p>In 1994, Randal Schwartz replied to a question in <code>comp.unix.shell</code> asking how to sort on the last name for a list like this:</p>

<pre class="not-js">
adjn:Joshua Ng
adktk:KaLap Timothy Kwong
admg:Mahalingam Gobieramanan
admln:Martha L. Nangalama
admrp:Michael R. Pearson
adshl:Siu Lung Henry Lee
adsyh:So Yi Ho
adtkk:Tariq K. Khan
adtkl:Terence K. H. Leung
advld:Vickie L. Dwyer
alaen:Alfred E. Neuman
anedp:Erin D. Picard
</pre>

<p>The answer:</p>

<pre class="not-js">
#!/usr/bin/perl
require 5; # new features, new bugs!
print
    map { $_->[0] }
    sort { $a->[1] cmp $b->[1] }
    map { [$_, /(\S+)$/] }
    <>;
</pre>

<p>Map, sort, map.</p>

<p>Anyway, here&#8217;s a version in JavaScript 1.6<sup>&#8224;</sup>. If we have the following array:</p>

<pre class="not-js">
var myArray =  ["adjn:Joshua Ng",
"adktk:KaLap Timothy Kwong",
"admg:Mahalingam Gobieramanan",
"admln:Martha L. Nangalama",
"admrp:Michael R. Pearson",
"adshl:Siu Lung Henry Lee",
"adsyh:So Yi Ho",
"adtkk:Tariq K. Khan",
"adtkl:Terence K. H. Leung",
"advld:Vickie L. Dwyer",
"alaen:Alfred E. Neuman",
"anedp:Erin D. Picard"];
</pre>

<p>We can sort on the last name like so:</p>

<pre class="not-js">
var sorted = myArray.map( function (e) {
    return {o: e, s: e.split(/[\s]/gi).pop()};
}).sort( function (a, b) {
    return a.s > b.s;
}).map( function (e) {
    return e.o;
});
</pre>

<p>Note that the value used to sort is calculated in the <code>map()</code>.</p>

<p>I&#8217;d be interested in further examination into how well this works in current JavaScript implementations (and any <code>map</code> provided for older implementations); and whether there are more appropriate ways to code it up in JavaScript.</p>

<p>&#8212;</p>

<p>&#8224; Map isn&#8217;t in until <a href="https://developer.mozilla.org/en/New_in_JavaScript_1.6">1.6</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Plugins... and JavaFx</title>
    <link rel="alternate" type="text/html" href="http://www.boundvariable.com/2009/02/23/plugins-and-javafx-script/" />
    <id>tag:www.boundvariable.com,2009://1.27</id>

    <published>2009-02-23T03:27:03Z</published>
    <updated>2009-05-29T01:17:05Z</updated>

    <summary>So I&#8217;ve complained about JavaFX before but I&#8217;m going to mention it again because, well, every time I see these examples I feel like a...</summary>
    <author>
        <name>Patrick</name>
        
    </author>
    
        <category term="User Interface" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.boundvariable.com/">
        <![CDATA[<p>So I&#8217;ve complained about JavaFX before but I&#8217;m going to mention it again because, well, every time I see these examples I feel like a 2009 web user trapped in a 1995 world. </p>

<p>There&#8217;s an example of a <a href="http://javafx.com/samples/Carousel/index.html">Carousel implemented in JavaFX</a> over on JavaFX.com. Here&#8217;s what you get when you try to view it:</p>

<p>First up, it&#8217;s loading&#8230;</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="JavaFX carousel screen one" src="http://www.boundvariable.com/i/jfx-carousel.gif" width="512" height="456" class="mt-image-none" style="" /></span></p>

<p>Now I have to verify that I want to run <code>org.jdesktop.applet.util.JNLPAppletLauncher</code>. Ok. Why not? I <em>always</em> trust things with names like that when they ask.</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="JavaFX carousel screen two" src="http://www.boundvariable.com/i/jfx-carousel2.gif" width="512" height="321" class="mt-image-none" style="" /></span></p>

<p>Which takes me back to the loading page for about five seconds whilst it continues loading.</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="JavaFX carousel screen one" src="http://www.boundvariable.com/i/jfx-carousel.gif" width="512" height="456" class="mt-image-none" style="" /></span></p>

<p>Until finally I see a carousel.</p>

<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="JavaFX carousel screen three" src="http://www.boundvariable.com/i/jfx-carousel3.gif" width="512" height="512" class="mt-image-none" style="" /></span></p>

<p>To adapt a quote from Bill Moggridge&#8230; <em>kind to Java developers, cruel to users</em>.</p>
]]>
        

    </content>
</entry>

</feed>
