<?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/"
	>

<channel>
	<title>The Safety Net</title>
	<atom:link href="http://safehammad.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://safehammad.com</link>
	<description>Grey matters in technology by Safe Hammad</description>
	<lastBuildDate>Fri, 28 Oct 2011 17:43:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Our days are numbered</title>
		<link>http://safehammad.com/2011/10/28/our-days-are-numbered/</link>
		<comments>http://safehammad.com/2011/10/28/our-days-are-numbered/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 17:43:00 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Words]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=402</guid>
		<description><![CDATA[Whenever I learn a new word in any language, I often find myself comparing that word with equivalent words in other languages. I was recently thinking about words for days of the week in various languages. For related languages, not only are there similarities in the words themselves, but the origins of those words also [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I learn a new word in any language, I often find myself comparing that word with equivalent words in other languages.  I was recently thinking about words for days of the week in various languages.  For related languages, not only are there similarities in the words themselves, but the origins of those words also fall into a small number of distinct categories.</p>
<p>I chose three groups of related languages, partly for reasons of familiarity and interest, and partly to allow me to compare words within and across groups:</p>
<ul>
<li>English and German (Germanic)</li>
<li>French and Spanish (Romance)</li>
<li>Arabic and Hebrew (Semitic)</li>
</ul>
<p>Interestingly, the origins of the words for days of the week can almost all be placed into the categories <em>Planetary</em>, <em>Pagan Gods</em>, <em>Religious</em> and <em>Numeric</em>.  The following table lists the words for days of the week in each language together with their meaning / origin:</p>
<p style="text-align: center;">
<div id="attachment_414" class="wp-caption aligncenter" style="width: 496px"><a href="http://safehammad.com/wp-uploads/2011/10/days.png"><img class="size-full wp-image-414  " title="The origins of words for days of the week" src="http://safehammad.com/wp-uploads/2011/10/days.png" alt="The origins of words for days of the week" width="486" height="311" /></a><p class="wp-caption-text">The origins of words for days of the week</p></div>
<p style="text-align: center;">
<p style="text-align: left;">What struck me immediately is that this table is strongly reminiscent of the <a href="http://wikipedia.org/wiki/Periodic_table" onclick="pageTracker._trackPageview('/outgoing/wikipedia.org/wiki/Periodic_table?referer=');">Periodic Table</a>.  This probably isn&#8217;t surprising considering that related languages have been placed adjacent to each other.</p>
<p>Head over to this <a href="http://wikipedia.org/wiki/Weekday_names" onclick="pageTracker._trackPageview('/outgoing/wikipedia.org/wiki/Weekday_names?referer=');">Wikipedia page</a> for a more complete study of the origins of the words for days of the week (but without the colourful table).</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2011/10/28/our-days-are-numbered/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be good to your colon</title>
		<link>http://safehammad.com/2011/08/10/be-good-to-your-colon/</link>
		<comments>http://safehammad.com/2011/08/10/be-good-to-your-colon/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 13:30:15 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=360</guid>
		<description><![CDATA[Programmers spend more time reading code than writing it (a fact well known by most programmers who tend not to publicise this to their employers).  It therefore stands to reason that (most?) programming languages should be designed as much for human consumption as for machine consumption and should be as readable as possible. Python is [...]]]></description>
			<content:encoded><![CDATA[<p>Programmers spend more time reading code than writing it (a fact well known by most programmers who tend not to publicise this to their employers).  It therefore stands to reason that (most?) programming languages should be designed as much for human consumption as for machine consumption and should be as readable as possible.</p>
<p>Python is a very readable language (a fact which contributes to its popularity) and has been termed &#8220;executable pseudocode&#8221; on account of its readability.  An aspect of Python which makes it readable is its avoidance of syntactic fluff, extraneous words and symbols which add nothing to the code&#8217;s meaning but serve to detract from it.</p>
<p>In the past I&#8217;ve felt somewhat negative about Python&#8217;s terminal colon &#8220;:&#8221;, the symbol used to terminate <code>if</code>, <code>while</code>, <code>def</code> and <code>class</code> statements and to signify the start of a new block of indented code.  For example:</p>
<pre class="brush: python; light: true;">
if a == 1:
    b = do_something_cool()

def do_something_cool():
    return 'Doing something cool'
</pre>
<p>Even without the colon, it&#8217;s quite clear that we&#8217;re starting a new block of indented code because (a) the statement starts with the keyword <code>if</code>, <code>while</code>, <code>def</code> or <code>class</code> and (b) the next line of code is indented.  For comparison, <a href="http://www.ruby-lang.org/en/" onclick="pageTracker._trackPageview('/outgoing/www.ruby-lang.org/en/?referer=');">Ruby</a> gets on just fine without the colon after its <code>def</code> statement.  So why the need for a colon in Python?  Is it syntactic fluff?</p>
<p>The <a href="http://docs.python.org/faq/design.html#why-are-colons-required-for-the-if-while-def-class-statements" onclick="pageTracker._trackPageview('/outgoing/docs.python.org/faq/design.html_why-are-colons-required-for-the-if-while-def-class-statements?referer=');">Python FAQ</a> explains that the colon enhances readability and helps editors with syntax highlighting and code indentation.  Lets face it, any self respecting editor should be capable of parsing a line beginning with an <code>if</code>, <code>while</code>, <code>def</code> or <code>class</code>, so the &#8220;helps editors&#8221; argument is bogus.  I do however buy the argument that the code is visibly more readable.  But <em>how</em> does it enhance readability?</p>
<p>I&#8217;ve already mentioned that a programmer spends more time reading than writing code.  What I haven&#8217;t yet suggested is that a programmer will often <em>reread</em> and scan the same code repeatedly to form a mental picture of a larger codebase.  It&#8217;s what the eyes do when they&#8217;re scanning code that&#8217;s key to the importance of the colon.  There is <a href="http://www.ncbi.nlm.nih.gov/pubmed/20373225" onclick="pageTracker._trackPageview('/outgoing/www.ncbi.nlm.nih.gov/pubmed/20373225?referer=');">some evidence</a> to suggest that the eyes linger at the beginning and at the end of a sentence when reading text and draw especially from visual cues at those locations.  Let&#8217;s assume for the moment that this holds true for a line of code.  So the visual cue heralding an indented block of code is clear at the beginning of a line of code, namely an <code>if</code>, <code>while</code>, <code>def</code> or <code>class</code> followed by an indented line.  The only visual cue at the end of a line of Python code is the colon, and without the colon there would be no cue.  So even though the colon is not strictly necessary, there is an argument that its existence is there for human consumption and aids readability.</p>
<p>When all&#8217;s said and done, the advantage of the colon is probably slight at best, and then probably only for a newcomer to the language.  (This sort of advantage possibly completely vanishes for experienced users of any language).  Never-the-less, on balance, I&#8217;m now happy it&#8217;s there!</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2011/08/10/be-good-to-your-colon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django JavaScript Integration: AJAX and jQuery</title>
		<link>http://safehammad.com/2011/04/10/django-javascript-integration-ajax-and-jquery/</link>
		<comments>http://safehammad.com/2011/04/10/django-javascript-integration-ajax-and-jquery/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 18:18:58 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=336</guid>
		<description><![CDATA[Django JavaScript Integration: AJAX and jQuery is a book about the building of Ajax-enabled web applications using Django and jQuery.  Django has rapidly shot to fame as the most popular web development framework for the Python programming language.  Similarly, jQuery has taken the Javascript world by storm as a client-side Javascript framework making the development [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://safehammad.com/wp-uploads/2011/04/django-jquery-ajax.png"><img class="alignright size-full wp-image-337" style="border: 0px;" title="django-jquery-ajax" src="http://safehammad.com/wp-uploads/2011/04/django-jquery-ajax.png" alt="" width="125" height="152" /></a><a href="http://www.packtpub.com/django-javascript-integration-ajax-and-jquery/book" onclick="pageTracker._trackPageview('/outgoing/www.packtpub.com/django-javascript-integration-ajax-and-jquery/book?referer=');">Django JavaScript Integration: AJAX and jQuery</a> is a book about the building of Ajax-enabled web applications using Django and jQuery.  Django has rapidly shot to fame as the most popular web development framework for the Python programming language.  Similarly, jQuery has taken the Javascript world by storm as a client-side Javascript framework making the development of sophisticated browser based clients both easier and even more pleasurable than using Javascript alone.  The strapline to this book is: &#8220;Develop AJAX applications using Django and jQuery&#8221; and I would suggest that this describes the aim of the book more accurately than its title.</p>
<p>There&#8217;s a wealth of both online and dead-tree texts covering Django and jQuery, however by comparison, there&#8217;s far less information covering the integration of both technologies so the arrival of this book is timely.  I&#8217;m also always happy to see new books aimed at the more experienced Python programmer in a time when the rapid (and very welcome) growth in the adoption of Python has led to the recent publication of a large number of beginners&#8217; books.</p>
<p>To get the most out of this book, a knowledge of Python is expected and a working knowledge of Javascript and Django highly recommended.  The author also makes occasional (and perhaps inevitable) comparisons between Javascript and the Java language in the first couple of chapters, however a working knowledge of Java is definitely not needed.</p>
<p>The first chapter covers Python and Javascript.  As a Django/jQuery developer you&#8217;ll be using both languages and the author provides some interesting comparisons between the two.  The author is also quite candid and realistic about the weaknesses of Javascript and its cross-browser incompatibilities whilst carefully highlighting its strengths:  &#8220;If you can figure out why Python is a good language, you can figure out why JavaScript is a good language.&#8221;</p>
<p>The second chapter gets stuck into the basics of jQuery and the constructs which simplify the implementation of Ajax.  The third chapter then dives into Django with a tour of Django validation and a detailed discussion of validation in general.  The remainder of the book builds a reasonably large web application with each chapter pulling together a good number of disparate features you&#8217;d want to provide in any self-respecting Web 2.0 application.  Autocompletion, form validation, server-side validation, client-side and server-side search and login handling are all described and integrated into the application.  Even the creation of a &#8220;favicon.ico&#8221; is mentioned to put a company logo on your users&#8217; web browser tabs and make them look distinctive.</p>
<p>It quickly became apparent that this book  is not a regurgitation of &#8220;the same old stuff&#8221;, rather it makes the effort not only to show you <em>what</em> to do, but also to discuss <em>why</em> you do something in a particular way and how you can improve on it, leaving the reader with a deeper understanding.  For example, the book is quite happy to extend the provided Django classes where they fall short, and show validation of more unusual types such as GPS coordinates not natively supported by Django.  Another example is the book&#8217;s excellent treatment of validation discussing cultural awareness and the suggestion that a &#8220;less is more&#8221; approach to validation can sometimes make sense.</p>
<p>Apart from a couple of typos here and there (which are possibly restricted to my electronic copy), a minor annoyance is what I felt to be a rather unorthodox Javascript formatting style.  For example:</p>
<pre>set: function(newValue)
   {
   var value = parseInt(newValue.toString());
   if (isNaN(value))
       {
       return false;
       }
   else
       {
       field = value;
       return true;
       }
   }</pre>
<p>It&#8217;s quite possible again that this is a formatting issue restricted to my electronic copy (and I&#8217;ll investigate and update this review accordingly).  I also acknowledge that you can never please everyone with your coding style and layout!</p>
<p>The book stops short of helping you organise the inevitable growing mass of Javascript code, a difficult but increasingly important topic.  A little information around the modularisation of Javascript files or strategies and libraries for implementing MVC in client side code would have gone a long way.  Another aspect of the book which is notably glossed over is the topic of testing.  Testing can be hard, and testing web applications can be very hard, particularly those which rely on a lot of Javascript.  Admittedly this isn&#8217;t a book about testing, but implementing tests is a very important part of a developer&#8217;s life and a section or chapter setting the reader on the right path would have been welcome.</p>
<p>There are several parts of the book which deserve a special mention, however Chapter 11 particularly stands out.  The topic of usability is one often brushed over in technical books in favour of delivering more how-to&#8217;s and code examples.  The author devoted an entire chapter to usability, a chapter which I can only hope the authors of many web applications I&#8217;ve used might one day read.</p>
<p>I find it hard to characterise the author&#8217;s style of writing but I&#8217;d probably describe it as intellectual bordering on philosophical with a colourful vocabulary, a style which I enjoy but might not be to everyone&#8217;s taste.  An amusing example of the intellectual nature of the book can be found in Chapter 2: &#8220;Prototypal inheritance is more like the evolutionary picture of single-celled organisms that can mutate, reproduce asexually by cell division, and pass on (accumulated) mutations when they divide.&#8221;  I actually found this an interesting and useful analogy however it&#8217;s probably a little hard to relate to unless you remember your school biology!</p>
<p>In summary, I like this book.  I like the the fact that it&#8217;s filled with gems of information you won&#8217;t easily find online.  I like the colourful language and the interesting discussion around the concepts the author is conveying.  Most importantly, this book is written by someone who has clearly developed real web applications.  If you&#8217;re someone merely looking to get cracking on a project using Django and jQuery in the shortest time possible, then this book might disappoint.  But then again, the online tutorials and references are there to get you started and this book can take over where they leave off.</p>
<p>Finally, the author strikes me as someone both interesting and accomplished and I look forward to reading other books he might have in the works.</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2011/04/10/django-javascript-integration-ajax-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pro Python &#8211; Book Review</title>
		<link>http://safehammad.com/2011/03/14/pro-python-book-review/</link>
		<comments>http://safehammad.com/2011/03/14/pro-python-book-review/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 18:21:29 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python3]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=316</guid>
		<description><![CDATA[A recent thread on the Python Northwest mailing list asked for opinions on Marty Alchin&#8216;s book Pro Python.  I thought I&#8217;d reproduce the answer I gave and expand on it a little. I&#8217;ve owned Marty Alchin&#8217;s first book, Pro Django, for some time and was very happy with that purchase.  Based on that, I decided [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://safehammad.com/wp-uploads/2011/03/pro-python.gif"><img class="alignright size-full wp-image-317" style="border: 3px solid black;" title="pro-python" src="http://safehammad.com/wp-uploads/2011/03/pro-python.gif" alt="" width="125" height="165" /></a>A recent thread on the <a href="http://pynw.org.uk" onclick="pageTracker._trackPageview('/outgoing/pynw.org.uk?referer=');">Python Northwest</a> mailing list asked for opinions on <a href="http://martyalchin.com/" onclick="pageTracker._trackPageview('/outgoing/martyalchin.com/?referer=');">Marty Alchin</a>&#8216;s book <a href="http://apress.com/book/view/9781430227571" onclick="pageTracker._trackPageview('/outgoing/apress.com/book/view/9781430227571?referer=');">Pro Python</a>.  I thought I&#8217;d reproduce the answer I gave and expand on it a little.</p>
<p>I&#8217;ve owned Marty Alchin&#8217;s first book, Pro Django, for some time and was very happy with that purchase.  Based on that, I decided to buy his Pro Python book last year.  Pro Python is targeted at readers who are proficient with basic Python but are looking to push their skills further.  Quite naturally there&#8217;s a large number of beginners&#8217; Python books out there but a shortage of more advanced books so it was nice to see this published.</p>
<p>Marty Alchin starts his book with a refreshing approach.  Rather than regurgitating Python facts to the reader, he takes a step by step tour of <a href="http://www.python.org/dev/peps/pep-0020/" onclick="pageTracker._trackPageview('/outgoing/www.python.org/dev/peps/pep-0020/?referer=');">The Zen of Python</a> discussing how it&#8217;s philosophy can be practically applied to make your programming more Pythonic.  He then delves into traditional topics such as classes, objects and strings as well as development topics such as packaging and testing.</p>
<p>I like Marty Alchin&#8217;s style of writing and find it to be clear and concise.  Even if you&#8217;re reasonably knowledgeable about the advanced topics he covers such as metaclasses, descriptors, introspection and multiple inheritance, I think the book benefits from the fact that these topics are backed up with good examples of how they work, and just as importantly, how they might usefully be used in ways you might not have seen before.  In fact, Chapter 11 walks through the building of a real world Python library which can be found on PyPI (try pip install Sheets) using the principles outlined in the previous chapters.</p>
<p>The other aspect of the book I find very useful is the fact that it is based on Python 3, however all examples are annotated and compared with the &#8220;legacy&#8221; Python 2 equivalent where relevant.  I&#8217;ve gotten a lot more comfortable with Python 3 by reading this book and better understand the improvements in the language from Python 2 to Python 3.</p>
<p>This isn&#8217;t a book aimed at newcomers to Python, even if you have a lot of programming experience, as it expects a reasonable amount of basic Python proficiency.  It&#8217;s also a &#8220;thin&#8221; book in the sense that it gives each topic a light treatment rather than aiming to be a complete reference.  This may or may not suit your needs, however there&#8217;s plenty of reference material elsewhere both online (e.g. the official Python documentation) and in print.</p>
<p>By comparison, the other advanced Python book I&#8217;ve read (and reread!) is <a href="http://oreilly.com/catalog/9780596100469" onclick="pageTracker._trackPageview('/outgoing/oreilly.com/catalog/9780596100469?referer=');">Python In a Nutshell</a> by Alex Martelli.  It&#8217;s based on Python 2.5 and getting a bit out of date, but much of it is still very relevant for all Python 2.x versions.  (I think a Python 3 version might be in the works).  It&#8217;s a much heftier and more detailed book and acts as much a reference text as well as being a book you&#8217;d enjoy reading from cover to cover.</p>
<p>In summary, I&#8217;d recommend Pro Python to any intermediate level Python programmer who&#8217;d like to advance their Python skills with a clear and concise text.</p>
<p><em>N.B. I am in no way associated with Pro Python, Apress or Marty Alchin &#8230; except of course for owning the book!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2011/03/14/pro-python-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cracks on the surface</title>
		<link>http://safehammad.com/2011/01/07/cracks-on-the-surface/</link>
		<comments>http://safehammad.com/2011/01/07/cracks-on-the-surface/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 13:00:16 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[neurons]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=293</guid>
		<description><![CDATA[The recent freeze and thaw of the canal beside where I live has produced a beautiful natural phenomenon.  Cracks in the surface ice reminiscent of neurons with pronounced dendrites have appeared in random locations.  Stars in the night sky also spring to mind:]]></description>
			<content:encoded><![CDATA[<p>The recent freeze and thaw of the canal beside where I live has produced a beautiful natural phenomenon.  Cracks in the surface ice reminiscent of <a href="http://en.wikipedia.org/wiki/Neuron" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Neuron?referer=');">neurons</a> with pronounced <a href="http://en.wikipedia.org/wiki/Dendrite" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Dendrite?referer=');">dendrites</a> have appeared in random locations.  Stars in the night sky also spring to mind:</p>
<div id="attachment_287" class="wp-caption aligncenter" style="width: 399px"><a href="http://safehammad.com/wp-uploads/2011/01/brain-med.jpg"><img class="size-full wp-image-287 " title="Back Camera" src="http://safehammad.com/wp-uploads/2011/01/brain-med.jpg" alt="" width="389" height="290" /></a><p class="wp-caption-text">Neurons</p></div>
<div id="attachment_289" class="wp-caption aligncenter" style="width: 399px"><a href="http://safehammad.com/wp-uploads/2011/01/neuron-med.jpg"><img class="size-full wp-image-289 " title="Back Camera" src="http://safehammad.com/wp-uploads/2011/01/neuron-med.jpg" alt="" width="389" height="290" /></a><p class="wp-caption-text">Dendrites</p></div>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2011/01/07/cracks-on-the-surface/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Circles of Satisfaction</title>
		<link>http://safehammad.com/2010/12/04/the-circles-of-satisfaction/</link>
		<comments>http://safehammad.com/2010/12/04/the-circles-of-satisfaction/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 19:35:05 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[jobs]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=259</guid>
		<description><![CDATA[What motivates us to get a job?  The instinctive answer for many might be: &#8220;To earn money!&#8221;  And what motivates us to stay in that job?  A member of the developed world might then pause for thought and mutter enlightened words such as &#8220;fulfilment&#8221; and &#8220;sense of worth&#8221;. I&#8217;ve been thinking for some time about [...]]]></description>
			<content:encoded><![CDATA[<p>What motivates us to get a job?  The instinctive answer for many might be: &#8220;To earn money!&#8221;  And what motivates us to stay in that job?  A member of the developed world might then pause for thought and mutter enlightened words such as &#8220;fulfilment&#8221; and &#8220;sense of worth&#8221;.</p>
<p>I&#8217;ve been thinking for some time about the factors that contribute to job satisfaction.  More specifically, I&#8217;m interested in why people stay in their jobs and at what point they decide to move on.  There are seemingly countless factors to consider, including money earned, working hours, length and ease of commute, boss, colleagues, being challenged etc. etc.  Each of these factors contributes variably to whether you stay or go.</p>
<p>In an attempt to better understand these factors and their influence on decision making, I&#8217;ve found that they can generally be placed into one of three categories:</p>
<div>
<ol>
<li><strong>Remuneration</strong>.  Earning enough money to pay the bills and earning what you feel you are worth, whether it be with salary, commissions or payment in kind, for example, lavish trips or a generous expense account.</li>
<li><strong>Enjoyment</strong>.  Getting a kick out of doing what you do, for example, by being challenged either mentally or physically.  Getting to help others.  Enjoying the company and camaraderie of colleagues.  Getting on with your boss.</li>
<li><strong>Convenience</strong>.  Sensible commute.  Sensible working hours that don&#8217;t interfere with your non-work pursuits or family life.</li>
</ol>
</div>
<div id="_mcePaste">Now we have our categories, let&#8217;s see how they influence us.  Enter The Circles of Satisfaction:</div>
<div>
<div id="attachment_277" class="wp-caption aligncenter" style="width: 410px"><a href="http://safehammad.com/wp-uploads/2010/12/job-satisfaction-med.png"><img class="size-full wp-image-277" title="Job Satisfaction" src="http://safehammad.com/wp-uploads/2010/12/job-satisfaction-med.png" alt="" width="400" height="382" /></a><p class="wp-caption-text">The Circles of Satisfaction. How satisfied are you in your job?</p></div>
<p>The formula is simple.  Add up the number of circles that apply to you:</p>
</div>
<div>
<ul>
<li>If you score 3 out of 3, you&#8217;re very satisfied in your job and very lucky.</li>
<li>If you score 2 out of 3, you&#8217;re generally satisfied in your job and happy to stick with it.</li>
<li>If you score 1 out of 3, you&#8217;re probably looking for a job elsewhere.</li>
</ul>
<p>Of course, if you score 0, you&#8217;re in real trouble!</p>
</div>
<p>If you&#8217;re an employer, try applying this formula to each of your staff.  You might be in for a surprise.</p>
<p>Now try this formula on yourself.  Are you in the right job?</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2010/12/04/the-circles-of-satisfaction/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hessian RPC Services.  What&#8217;s not to like?</title>
		<link>http://safehammad.com/2010/10/16/hessian-rpc-services-whats-not-to-like/</link>
		<comments>http://safehammad.com/2010/10/16/hessian-rpc-services-whats-not-to-like/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 20:16:54 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hessian]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rpc]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=224</guid>
		<description><![CDATA[Over the last few days I&#8217;ve been playing with Hessian, &#8220;a compact binary protocol for connecting web services&#8221;. In my previous company we used Hessian extensively for communicating between a Java thick client and a Java Apache Tomcat HTTP server with good success. These days we talk of JSON and REST and peer our noses [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days I&#8217;ve been playing with <a href="http://hessian.caucho.com/" onclick="pageTracker._trackPageview('/outgoing/hessian.caucho.com/?referer=');">Hessian</a>, &#8220;a compact binary protocol for connecting web services&#8221;.  In my previous company we used Hessian extensively for communicating between a Java thick client and a Java Apache Tomcat HTTP server with good success.  These days we talk of <a href="http://en.wikipedia.org/wiki/JSON" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/JSON?referer=');">JSON</a> and <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Representational_State_Transfer?referer=');">REST</a> and peer our noses down at thick clients so Hessian might seem irrelevant, however around the time we were implementing our client-server communications (2004 / 2005), we were bathing in the waters of <a href="http://en.wikipedia.org/wiki/SOAP" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/SOAP?referer=');">SOAP</a>, <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Web_Services_Description_Language?referer=');">WSDL</a> and so-called heavyweight web services.  The beauty of Hessian was our ability to take our Plain Old Java Objects which we had already implemented on our thick client and send them down the pipe unchanged to our server.  Hessian took care of the marshalling and unmarshalling of data.  In fact, because we took advantage of Hessian integration with the <a href="http://en.wikipedia.org/wiki/Spring_Framework" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Spring_Framework?referer=');">Spring Framework</a>, a declarative application framework which encourages defining objects and their relationships and dependencies in configuration files, all it took was a bit of code and a bit of configuration to get everything working.</p>
<p>So does it now make more sense to use JSON / REST?  One of the advantages of JSON / REST includes the inherent decoupling of client and server.  The client fires a JSON string to the server at the correct URL using an HTTP POST and the server parses what it needs from that string and happily replies.  This process is platform agnostic as HTTP and JSON libraries are available for many programming languages and platforms, not least including Javascript in the web browser.  This model is widely used by service providers such as Google and Amazon whereby they can provide and update REST interfaces to their services without having to deliver and maintain multiple API client libraries.  A drawback of this model is the need to hand code the marshalling and unmarshalling of JSON data by both client and server, though this can also be seen as an advantage as it decouples an application&#8217;s internal representation of data from the wire format.</p>
<p><a href="http://safehammad.com/wp-uploads/2010/10/json-rest3.png"><img class="aligncenter size-full wp-image-257" title="JSON, REST &amp; HTTP" src="http://safehammad.com/wp-uploads/2010/10/json-rest3.png" alt="" width="562" height="338" /></a>Hessian compares well with the JSON / REST model.  Hessian is also designed around HTTP POST whereby a client connects to a URL on the server and sends data, however Hessian goes one step further and encodes an <a href="http://en.wikipedia.org/wiki/Remote_procedure_call" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Remote_procedure_call?referer=');">RPC</a> call i.e. a function name and arguments.  In fact the Hessian library makes this process transparent by proxying the server i.e. it provides an object on which the client makes function calls without knowing that the call will be sent to a server.  Note that there is no &#8220;contract&#8221; or abstract interface which you are forced to code to &#8211; client and server ensure they&#8217;re sending and receiving the correct function arguments by &#8220;unwritten agreement&#8221; much like the JSON / REST model.  Unlike JSON, Hessian is a binary protocol meaning that the data exchanged between client and server is very compact.  It also encodes type information, in fact, entire object structures are maintained when unmarshalled on either client or server.  Hessian is also cross platform and libraries exist for many programming languages including Javascript.</p>
<p style="text-align: center;"><a href="http://safehammad.com/wp-uploads/2010/10/hessian1.png"><img class="size-full wp-image-254  aligncenter" title="Hessian RPC" src="http://safehammad.com/wp-uploads/2010/10/hessian1.png" alt="" width="561" height="348" /></a></p>
<p style="text-align: left;">So what&#8217;s not to like?  Well binary communication and the concept of RPC function calls in general seems to have gained a bad reputation, possibly due to the extra complexity and library support needed over simple JSON / REST and possibly because of the increased coupling an RPC call implies.  Experience at my previous company taught us that the communication can be little brittle if the definitions of objects sent over the wire are not kept in step on both client and server.  If an object sent from the client to the server has an extra unknown field, there will be an error when the Hessian library on the server tries to unmarshall that data to create an object.  (The reverse, however, is not true &#8211; any fields missing from data over the wire will simply end up unset on the unmarshalled object).</p>
<p style="text-align: left;"><a href="http://safehammad.com/wp-uploads/2010/10/hessian-mismatch1.png"><img class="aligncenter size-full wp-image-256" title="Hessian Field Mismatch" src="http://safehammad.com/wp-uploads/2010/10/hessian-mismatch1.png" alt="" width="528" height="281" /></a>Passing JSON over HTTP is much more forgiving in that the client or server will blissfully ignore any field it doesn&#8217;t know how to handle, though of course if a field that is expected is not found, the server must know handle that.  Ordinarily, keeping the client and server in step shouldn&#8217;t be a problem, however we had many clients in the field with different versions of our software all connecting to the same server.</p>
<p>It has only recently occurred to me that the brittleness described above is peculiar to <a href="http://en.wikipedia.org/wiki/Statically_typed#Static_typing" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Statically_typed_Static_typing?referer=');">statically typed languages</a> such as Java where an Exception is thrown at any attempt to apply a value to a field where that field not been defined in an object&#8217;s class.  The same is not true of <a href="http://en.wikipedia.org/wiki/Dynamically_typed#Dynamic_typing" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Dynamically_typed_Dynamic_typing?referer=');">dynamically typed languages</a> such as Python which is forgiving when applying values to arbitrary fields on an object.  For many years, <a href="http://hessian.caucho.com/#Python" onclick="pageTracker._trackPageview('/outgoing/hessian.caucho.com/_Python?referer=');">hessianlib.py</a> has been the standard Python implementation of Hessian.  It has been little unmaintained over that time and includes a Hessian client implementation but no Hessian server implementation.  The code is also a little impenetrable.  Happily, earlier this year a fork of hessianlib.py called <a href="http://pypi.python.org/pypi/mustaine/0.1.3" onclick="pageTracker._trackPageview('/outgoing/pypi.python.org/pypi/mustaine/0.1.3?referer=');">Mustaine</a> has appeared.  It doesn&#8217;t (yet) contain a server implementation, but the code is more penetrable so I submitted a <a href="http://github.com/safehammad/mustaine/" onclick="pageTracker._trackPageview('/outgoing/github.com/safehammad/mustaine/?referer=');">patch</a> with an implementation of a Hessian <a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Web_Server_Gateway_Interface?referer=');">WSGI</a> server.</p>
<p>Let&#8217;s see some code based on the proposed <em>mustaine.server</em> module. (<strong>Please note that Mustaine server support is in flux so this example is subject to change). </strong>An object can be served via WSGI by wrapping it with <em>mustaine.server.WsgiApp</em>.  An object&#8217;s methods are only exposed if decorated with the <em>mustaine.server.exposed</em> decorator.  For example:</p>
<pre class="brush: python;">
from mustaine.server import exposed

class Calculator(object):
    @exposed
    def add(self, a, b):
        return a + b

    @exposed
    def subtract(self, a, b):
        return a - b
</pre>
<p>The following code will serve a <em>Calculator()</em> object on port 8080 using the Python reference WSGI server:</p>
<pre class="brush: python;">
from wsgiref import simple_server
from mustaine.server import WsgiApp
s = simple_server.make_server('', 8080, WsgiApp(Calculator()))
s.serve_forever()
</pre>
<p>This object can now be accessed over the network using the Hessian client:</p>
<pre class="brush: python; light: true;">
&gt;&gt;&gt; from mustaine.client import HessianProxy
&gt;&gt;&gt; h = HessianProxy('http://localhost:8080/')
&gt;&gt;&gt; h.add(2, 3)
5
</pre>
<p>As a result of providing server support to Mustaine, I&#8217;ve started developing <a href="http://safehammad.com/software/django-hessian/">django-hessian</a>, a library which serves Hessian objects in <a href="http://www.djangoproject.com/" onclick="pageTracker._trackPageview('/outgoing/www.djangoproject.com/?referer=');">Django</a>.  Objects can be served using <em>djangohessian.Dispatcher</em> at a given URL with an entry in <em>urls.py</em>.  The <em>Calculator()</em> object described above can be served at the URL http://localhost:8000/rpc/calculator/ in the Django development server as follows:</p>
<pre class="brush: python;">
# mysite/urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^rpc/', include('mysite.myapp.urls')),
)
</pre>
<pre class="brush: python;">
# mysite/myapp/urls.py:

from django.conf.urls.defaults import *
from djangohessian import Dispatcher
from server import Calculator

urlpatterns = patterns('',
    url(r'^calculator/', Dispatcher(Calculator())),
)
</pre>
<p>Full source can be found at <a href="http://bitbucket.com/safehammad/django-hessian/" onclick="pageTracker._trackPageview('/outgoing/bitbucket.com/safehammad/django-hessian/?referer=');">http://bitbucket.com/safehammad/django-hessian/</a>.</p>
<p>I can&#8217;t help wondering whether the Hessian protocol is getting attention it deserves, particularly in environments where both client and server are delivered and maintained by a single provider.  Have you implemented JSON / REST systems which would have benefited from using Hessian?  Do you have good arguments as to why the use of Hessian is to be discouraged?</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2010/10/16/hessian-rpc-services-whats-not-to-like/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyWeek 11 &#8211; And the winner is &#8230;</title>
		<link>http://safehammad.com/2010/09/13/pyweek-and-the-winner-is/</link>
		<comments>http://safehammad.com/2010/09/13/pyweek-and-the-winner-is/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 16:27:19 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyweek]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=171</guid>
		<description><![CDATA[PyWeek 11 has come to an end .  The judging is over and the winners have been announced.  The deserving winners are Universe Factory 11 as an individual entry with the game Mortimer the Lepidopterist and Super Effective 11 as a team entry with the game Trident Escape. I made several interesting observations during the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pyweek.org/11" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/11?referer=');">PyWeek 11</a> has come to an end .  The judging is over and the winners have been announced.  The deserving winners are <a href="http://www.pyweek.org/e/unifac11/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/unifac11/?referer=');">Universe Factory 11</a> as an individual entry with the game Mortimer the Lepidopterist and <a href="http://www.pyweek.org/e/cubone_cigar/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/cubone_cigar/?referer=');">Super Effective 11</a> as a team entry with the game Trident Escape.</p>
<div class="wp-caption alignright" style="width: 298px"><a href="http://www.pyweek.org/e/unifac11/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/unifac11/?referer=');"><img title="Mortimer the Lepidopterist" src="http://media.pyweek.org/dl/11/unifac11/screenshot-final.png" alt="" width="288" height="144" /></a><p class="wp-caption-text">Mortimer the Lepidopterist</p></div>
<p style="text-align: center;">
<div class="wp-caption alignright" style="width: 327px"><a href="http://www.pyweek.org/e/cubone_cigar/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/cubone_cigar/?referer=');"><img title="Trident Escape: The Dungeon of Destiny" src="http://media.pyweek.org/dl/11/cubone_cigar/fancy.png" alt="Trident Escape: The Dungeon of Destiny" width="317" height="253" /></a><p class="wp-caption-text">Trident Escape: The Dungeon of Destiny</p></div>
<p>I made several interesting observations during the course of the contest.</p>
<p>Firstly, I&#8217;m no gamer, however that was clearly irrelevant to me as I thoroughly enjoyed the competition, the pressure of having to deliver a piece of software to a deadline (but not losing my job if I didn&#8217;t) and generally having free reign to hack with Python to produce a creative end product.  Not only that, but I was doing it in the knowledge that at least 39 teams of people would be playing with my creation.</p>
<p>Secondly, in telling my non-geek friends that I was entering this competition, I received all sorts of interest and support in what I was programming to a level I&#8217;d not experienced before.  It was both humbling and refreshing to be able to talk to my non-geek friends about what I was programming without a familiar glazed look descending on their faces.</p>
<p>Thirdly, I really enjoyed playing the other teams&#8217; games and learnt a lot from doing so.  It was interesting to see the sheer variety of games and the creative thought that went into them.  It was also interesting to look at the code behind the games.  For me this was a real win and an affirmation that you learn most about coding from reading others&#8217; code.</p>
<p>As mentioned previously, my entry was <a href="http://www.pyweek.org/e/Superfly-FS/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/Superfly-FS/?referer=');">Voices Under Water</a> and was written using the excellent <a href="http://www.pyglet.org/" onclick="pageTracker._trackPageview('/outgoing/www.pyglet.org/?referer=');">pyglet</a> and <a href="http://cocos2d.org/" onclick="pageTracker._trackPageview('/outgoing/cocos2d.org/?referer=');">cocos2d</a> libraries.  The game is based around a dolphin who has to catch life rings being thrown by a ship&#8217;s captain to save his crew from drowning.  It&#8217;s probably not the most exciting story, but I found myself writing the game then shoehorning the story onto it, and that was the best I could come up with!  Coming up with the name of the game was much easier.  My other half&#8217;s niece and her boyfriend are part of a band formerly called <a href="http://www.myspace.com/thebacchaemusic" onclick="pageTracker._trackPageview('/outgoing/www.myspace.com/thebacchaemusic?referer=');">The Bacchae</a> and more recently called Black Moth.  They kindly gave me permission to use one of their tracks which is fittingly called Voices Under Water as the backing music for the game.</p>
<p>Many thanks to the organisers and to the other teams for an enjoyable competition!</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2010/09/13/pyweek-and-the-winner-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyWeek 11</title>
		<link>http://safehammad.com/2010/08/27/pyweek/</link>
		<comments>http://safehammad.com/2010/08/27/pyweek/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 23:59:39 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[annie]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyweek]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=160</guid>
		<description><![CDATA[I&#8217;m currently involved in PyWeek, a game writing competition where entrants are given exactly one week to write a game from scratch in Python.  To be honest I&#8217;m not much of a gamer, but I couldn&#8217;t resist the creative challenge of writing a playable game in one week and I&#8217;m loving every minute of it.  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently involved in <a href="http://www.pyweek.org" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org?referer=');">PyWeek</a>, a game writing competition where entrants are given exactly one week to write a game from scratch in Python.  To be honest I&#8217;m not much of a gamer, but I couldn&#8217;t resist the creative challenge of writing a playable game in one week and I&#8217;m loving every minute of it.  As the front page of http://www.pyweek.org states:</p>
<p>The PyWeek challenge:</p>
<ol>
<li>Invites entrants to write a game in one week from scratch   either as an individual or in a team,</li>
<li>Is intended to be challenging and fun,</li>
<li>Will hopefully increase the public body of game tools, code and     expertise,</li>
<li>Will let a lot of people actually finish a game, and</li>
<li>May inspire new projects (with ready made teams!)</li>
</ol>
<p>This is the eleventh iteration of PyWeek and the first one I&#8217;ve entered.  The theme for this iteration is the word &#8216;caught&#8217;.  My entry is called <a href="http://www.pyweek.org/e/Superfly-FS/" onclick="pageTracker._trackPageview('/outgoing/www.pyweek.org/e/Superfly-FS/?referer=');"><em>Superfly Funky Stuff</em></a> though the game itself is really called <em>Voices Under Water</em>.  I&#8217;ll write more about what I&#8217;m coding in due course, but here&#8217;s a sneak preview:</p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 490px"><a href="http://safehammad.com/wp-uploads/2010/08/pyweek-11-screenshot.png"><img class="size-full wp-image-161 " title="pyweek-11-screenshot" src="http://safehammad.com/wp-uploads/2010/08/pyweek-11-screenshot.png" alt="" width="480" height="360" /></a><p class="wp-caption-text">Voices Under Water</p></div>
<p>And here&#8217;s a picture of my other half, Annie, recording splashing sounds in the bath for some DIY sound effects!</p>
<p style="text-align: center;"><a href="http://safehammad.com/wp-uploads/2010/08/recording-water-small.jpg"><img class="aligncenter size-full wp-image-166" title="recording-water-small" src="http://safehammad.com/wp-uploads/2010/08/recording-water-small.jpg" alt="" width="295" height="394" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2010/08/27/pyweek/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why should kids be interested in programming?</title>
		<link>http://safehammad.com/2010/08/13/how-do-you-get-kids-interested-in-programming/</link>
		<comments>http://safehammad.com/2010/08/13/how-do-you-get-kids-interested-in-programming/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 17:30:59 +0000</pubDate>
		<dc:creator>safe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python3]]></category>

		<guid isPermaLink="false">http://safehammad.com/?p=126</guid>
		<description><![CDATA[My 10 year old nephew, Bob, loves computer games. In fact, I think it would be fair to say that most self respecting 10 year olds love computer games and wonder what else a computer is for apart from computer games, Facebook, Bebo, and the occasional use of that legacy communications medium called email. There [...]]]></description>
			<content:encoded><![CDATA[<p>My 10 year old nephew, Bob, loves computer games.  In fact, I think it would be fair to say that most self respecting 10 year olds love computer games and wonder what else a computer is for apart from computer games, Facebook, Bebo, and the occasional use of that legacy communications medium called email.</p>
<p style="text-align: center;">
<div id="attachment_137" class="wp-caption aligncenter" style="width: 176px"><a href="http://safehammad.com/wp-uploads/2010/08/bob.jpg"><img class="size-full wp-image-137 " title="Bob" src="http://safehammad.com/wp-uploads/2010/08/bob.jpg" alt="" width="166" height="210" /></a><p class="wp-caption-text">My nephew, Bob!</p></div>
<p>There was a brief period in the 1980&#8242;s as the home PC revolution was picking up speed when we thought we would all have to learn how to program a computer.  Computers were taking over the workplace and without this skill we would all be unemployable.  That brief period ended with the rise of the office suite and the advent of email.  For many jobs we&#8217;re now expected to have familiarity with word processors, spreadsheets, email and web browsing.  You only really have to know how to program if you&#8217;re a programmer, whether hobbyist or professional, but that goes without saying.  One could argue that the evolution of our technological society where programming is mainly restricted to dedicated programmers is a natural <a href="http://en.wikipedia.org/wiki/Division_of_labour" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Division_of_labour?referer=');">division of labour</a>.  Why should a secretary or an advertiser or a salesperson need to program?   <em>Why would a 10 year old need to program?</em></p>
<p>Bob can often be found discussing the merits of the computer games he plays and how they might be altered or improved.  For example, earlier this week he described how he&#8217;d like to play a game which was a first person shooter where the enemy stood still and only fired back several seconds after being discovered.  The game description was accompanied with much hand waving and shooting noises.  There were further descriptions of the types of guns that should be available and when they should be made available to the player.</p>
<p>Bob&#8217;s vision of a new computer game was born from a creative process.  What Bob needs now is a medium of creative expression to bring that vision to life.  In the same way a musical instrument can be used to create an infinite variety of music, or a word processor can be used to create an infinite variety of novels, it is through programming that you can create an infinite variety of games, and programming is the medium of creative expression.</p>
<p><a href="http://yeoldeclue.com/cgi-bin/blog/blog.cgi" onclick="pageTracker._trackPageview('/outgoing/yeoldeclue.com/cgi-bin/blog/blog.cgi?referer=');">Michael Sparks</a> asked the question: <em><a href="http://yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=addreply&amp;nodeid=1277659707" onclick="pageTracker._trackPageview('/outgoing/yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=addreply_amp_nodeid=1277659707&amp;referer=');">If you were 7 again, what would you expect to find in a book on beginning programming?</a></em> Apart from the usual conditionals and loops (I can hear the writer of the fictional <em>Functional Programming for 7 Year Olds</em> groaning) it would make sense to fulfil our junior members of society&#8217;s primal need to play, adapt and create games.</p>
<p>Armed with the knowledge that learning to program was the path to learning to create computer games, Bob was all too happy to sit down with me and walk through some basic Python programming.  We started with a simple quiz game.  The first decision was to <a href="http://wiki.python.org/moin/Python2orPython3" onclick="pageTracker._trackPageview('/outgoing/wiki.python.org/moin/Python2orPython3?referer=');">whether to choose Python 2 or Python 3</a>.  I figured that extensive library support wasn&#8217;t necessary for writing a quiz so I plumped for Python 3.  With Python 3, you also get to avoid being asked sticky questions such as:</p>
<p><em>Why is it called raw_input() and not input()?</em></p>
<p>&#8230;  and &#8230;</p>
<p><em>Why does raw_input() have brackets and print doesn&#8217;t?</em></p>
<p>The quiz went down very well and we got to touch on several Python constructs.  Here&#8217;s a cut down version of what we wrote together:</p>
<pre class="brush: python;">
score = 0

fvcolour = input('What is my favourite colour? ')
if fvcolour == 'red' or fvcolour == 'blue':
    print('Correct!')
    score = score + 1
else:
    print('Incorrect!')

sport = input('What is my favourite sport to watch? ')
if sport == 'football' or sport == 'Football':
    print('Correct!')
    score = score + 1
else:
    print('Incorrect!')

print('You scored', score, 'out of 2')
</pre>
<p>Bob was very excited by this.  He was particularly excited about the fact that he could get the computer to ask any question and respond to any answer in any way he wanted it to.  After helping him install Python 3 on his own computer and showing him how to use IDLE, he sat about creating more intriguing and inventive quizzes.</p>
<p>I was conscious of the fact that I only see Bob once in a while so I set about looking for an online tutorial he could follow.  I was also conscious of the fact that he really wanted to write games, specifically first person shooters with advanced sound and graphics!  A few weeks ago I attended the informative and entertaining tutorial <a href="http://www.slideshare.net/r1chardj0n3s/intro-to-game-programming" onclick="pageTracker._trackPageview('/outgoing/www.slideshare.net/r1chardj0n3s/intro-to-game-programming?referer=');">Introduction To Game Programming</a> given by <a href="http://www.mechanicalcat.net/richard/log" onclick="pageTracker._trackPageview('/outgoing/www.mechanicalcat.net/richard/log?referer=');">Richard Jones</a> at <a href="http://www.europython.eu/" onclick="pageTracker._trackPageview('/outgoing/www.europython.eu/?referer=');">Europython</a>.  Richard pointed us to <a href="http://inventwithpython.com/" onclick="pageTracker._trackPageview('/outgoing/inventwithpython.com/?referer=');">Invent With Python</a>, an online (and dead tree) book &#8220;written to be understandable by kids as young as 10 to 12 years old&#8221; teaching them how to program games using <a href="http://www.pygame.org/" onclick="pageTracker._trackPageview('/outgoing/www.pygame.org/?referer=');">PyGame</a>.  And it has been updated to Python 3.  Perfect.   Bob is busy working his way through the book and I can&#8217;t wait to play Bob&#8217;s first person shooter!</p>
<p>How would you introduce your 10 year old nephew / niece / daughter / son to programming?</p>
]]></content:encoded>
			<wfw:commentRss>http://safehammad.com/2010/08/13/how-do-you-get-kids-interested-in-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

