Lots of Intriguinging Scheme Parentheses.

The venerable image manipulation package GIMP still continues to surprise me.

Version 2.8 was released recently, and it can now run seamlessly on OSX, without the need for XServer.

One feature I hadn’t explored until yesterday is the built in scripting facilities.  Pretty much anything you can do in GIMP can be scripted and programmed.  This being open source software, there is of course more than one scripting language available.  Python is available via the Python-Fu menu, but the default scripting language is Scheme, a variant of LISP.

This is my first real adventure into the world of LISP dialects.  It fascinates me how so many language constructs can be made available using only one syntactic structure – the bracket.

LISP has sometimes been said to stand for ‘Lots of Irritating Silly Parentheses.’

But I find this fascinating.

We use brackets for function calls:

(myfunction arg1 arg2)

We use brackets to define functions

(define (AddXY inX inY) (+ inX inY) )

and we even use brackets to manage the scope of variables

(let* ( (a 1) (b 2) ) (AddXY a b))

Which evaluates to ‘3’.

In any other language I’ve used, such as C, or Python, or Javascript, those three different semantic constructs would use three different syntactic structures – curly brackets, keywords, indentation etc.

I can see why people find LISP and Scheme hard to fathom, but it has a certain elegance that appeals to me.

 


Ridiculously Easy Javascript Experimentation

My current favourite online tool is jsfiddle. This is an incredibly well designed tool.

If you ever find yourself wanting to quickly try out some HTML, CSS or javascript, without any edit-save-publish-reload cycle, then jsfiddle is the tool for you.  It keeps surprising me how well put together it is.  Sharing snippets of work with friends and colleagues just requires cutting and pasting a simple URL.  Forking is literally a one-click process.  Versioning is built in so seamlessly you hardly notice it.  And although you can set up an account to manage your code snippets, you don’t need to login to start using it.

This is a lesson to me on user-centric design.  The barrier to entry is absurdly low, and there are a bunch of powerful features that are easily discoverable when you want to go beyond the basics.  You have the option of pre-loading any number of popular javascript libraries such as jQuery and Prototype, and even Coffeescript is supported.

So, go give it a try.  jsfiddle could quite easily be integrated into your development processes in the next ten minutes.


Redacted.

Now this is fascinating.

Thanks to wikileaks, it is now possible to compare versions of some U.S. government documents that have been released under Freedom of Information Act requests, but in redacted form, with the actual raw documents themselves.  Thus we can have an insight not only into the material the documents cover, but also what topics the government censors feel must be withheld.

http://www.aclu.org/wikileaks-diplomatic-cables-foia-documents

In software development, one of the most frequently used tools is something we call diff.   A diff tool compares two versions of a text file, typically a design document or a the source code for a program, and highlights the changes between them.  For the programmer, this is a useful tool to see what has changed between versions, to see if any errors have crept into the source, to see what modifications other team members may have made to the file, and to see how the code has evolved over time.

I have a feeling that in the future this technology will become more prevalent in the legal and governmental world.   It will be possible to track all the changes on a government bill as it proceeds through the legislative process.  Any attempt by a politician to make significant changes shortly before the bill is passed will become very obvious.  In fact I hope that with the rise of this kind of tool, along with collaborative websites along the lines of Wikipedia, the Canadian population can become much more involved in understanding, reviewing and  contributing to the legislative process.


Wither Bitcoin?

http://www.flickr.com/photos/tradertim/

Bitcoin is possibly the most interesting and game-changing technology to have been created in the last 10 years.  I think that there is a real possibility that it will succeed where other alternative currencies have failed.

What’s interesting me at the moment is what the path of adoption will be.  Until recently I assumed that the early adopters would all be geeks: people wanting to buy and sell virtual goods, World of Warcraft weaponry, or technical services such as programming and graphical design.

Now that I’m more familiar with the various bitcoin exchanges I wonder whether the currency is more likely to find early use as a Forex tool.  It’s very easy to transfer money from a source currency to bitcoin to a target currency, and transferring bitcoins around the world doesn’t require middlemen, fees, or regulation.

We’re obviously a long way from being able to buy a coffee at Tim Hortons with a cryptocurrency, but I think that eventually a healthy market may well emerge, with a large number of goods and services being traded for bitcoin.  I shall be following developments with interest.


Coffeescript

New technology of the week, and hot contender for the title of ‘my current favourite language’, is coffeescript.

I’ve thought for a long time that javascript is a horrible language with a wonderful language inside trying to get out.   Coffeescript may well be that language.  While at it’s heart it is still fundamentally javascript, and can be used anywhere javascript can (so far I’ve used it in node.js and in the browser), it steers you around the worst mistakes of the underlying language.  Variable scoping and binding is handled better, function declarations are clearer, iterations and comprehensions are integrated neatly into the language, and your code can be more succinct.

This week I re-wrote our mobile web platform, replacing our existing jquery-ui based rendering with coffeescript and backbone.  There was definitely a learning curve involved, but the effort was worthwhile; and now we have a code base that is considerably more manageable than the previous version.

Examples

l=[1,2,3]
square = (x) -> x*x
squares = (square(x) for x in l)

Or even

squares = (x*x for x in [1,2,3])

And from our actual code: we store data as json-encoded strings in the browser’s local storage.  This function takes a predicate (i.e. any function that returns a boolean) and uses it to find the keys of all elements in local storage that match.

view : (predicate) ->
    (key for own key,value of localStorage when predicate (JSON.parse(value))

Which could then be used to get all objects that have a field ‘type’ set to ‘response’ as follows:

dockeys = view (doc) -> doc.type=='response'

Neat, huh?   Head over to http://jashkenas.github.com/coffee-script/ and try it out yourself!