<?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>Open eyes Working brain &#187; tools</title>
	<atom:link href="http://federico.galassi.net/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://federico.galassi.net</link>
	<description>dedicated, in respect and admiration, to the spirit that lives in the computer</description>
	<lastBuildDate>Wed, 25 May 2011 18:08:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Die Semicolon Die!</title>
		<link>http://federico.galassi.net/2011/05/25/die-semicolon-die/</link>
		<comments>http://federico.galassi.net/2011/05/25/die-semicolon-die/#comments</comments>
		<pubDate>Wed, 25 May 2011 17:05:54 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[asi]]></category>
		<category><![CDATA[automatic semicolon insertion]]></category>
		<category><![CDATA[douglas crockford]]></category>
		<category><![CDATA[end of line]]></category>
		<category><![CDATA[jshint]]></category>
		<category><![CDATA[jslint]]></category>
		<category><![CDATA[pitfall]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=362</guid>
		<description><![CDATA[I&#8217;ve always put javascript&#8217;s automatic semicolon insertion (ASI for short) under the bad parts of the language. That is based on Douglas Crockford&#8217;s explanation of how the feature is tricky and easily leads to mistakes, with the canonical example being: // good, returns the object return { ... } // wrong! returns undefined return { [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://federico.galassi.net/wp-content/uploads/2010/12/semicolon2.jpeg"><img class="alignright size-full wp-image-368" style="position: relative; z-index: 99;" title="no_semicolon" src="http://federico.galassi.net/wp-content/uploads/2010/12/semicolon2.jpeg" alt="" width="200" height="167" /></a>I&#8217;ve always put <a href="http://en.wikipedia.org/wiki/JavaScript_syntax#Whitespace_and_semicolons">javascript&#8217;s automatic semicolon insertion</a> (ASI for short) under the bad parts of the language. That is based on <a href="http://googlecode.blogspot.com/2009/03/doug-crockford-javascript-good-parts.html">Douglas Crockford&#8217;s explanation</a> of how the feature is tricky and easily leads to mistakes, with the canonical example being:</p>
<pre class="brush: js">// good, returns the object
return { ... }

// wrong! returns undefined
return
    {
        ...
    }</pre>
<p>Fair enough. Lately i&#8217;ve been doing more and more ruby. Ruby is a language universally praised for its elegant, easy to read syntax. One of the strong points of the syntax is its terseness, that is, you can <a href="http://martinfowler.com/bliki/SyntacticNoise.html">omit a lot of punctuation</a>. Semicolons as well. Wait a moment&#8230;</p>
<pre class="brush: ruby">def test
    return
        {
            ...
        }
end

test # returns nil !!</pre>
<p>Same thing! Having the meaning of a program change due to an end-of-line is not a good thing in ruby as well, but it&#8217;s widely accepted because of the benefits. This must be true for javascript as well, so first point:</p>
<p><strong>&#8220;Removing semicolons and other punctuation clutter is not just a liability. It actually makes your code look better.&#8221;</strong></p>
<p>So both the languages have to decide when a statement implicitly terminates. But is ruby implementation really the same as javascript? It turns out it&#8217;s not, ruby takes a quite safer approach. A statement in ruby is finished on an end-of-line if it&#8217;s syntactically valid by itself, it spans multiple lines if it&#8217;s not:</p>
<pre class="brush: ruby"># this works, the trailing dot means the statement is not finished
object.
    method1.
    method2.
    method3

# syntax error, first line is a valid statement by itself, second line calls method1 on nothing
object
    .method1
    .method2
    .method3</pre>
<p>It&#8217;s safe because how a line is parsed depends on the line itself, not by other lines that could be written &#8220;by others&#8221;. The bad part is how it makes method chaining on multiple lines look ugly. This is why ruby 1.9 introduced the exception &#8220;the statement continues if the first character of next line is a dot&#8221;.</p>
<p>Javascript takes a step further to solve this bad part. A controversial step. A statement is finished on an end-of-line if the first character of the next line cannot be correctly parsed as if it was part of the line. Otherwise, the statement goes on. This removes the clutter and gives nice chaining:</p>
<pre class="brush: js">// just works
object
    .method1()
    .method2()
    .method3()</pre>
<p>Unfortunately, you now have a nasty problem. 2 lines which are supposed to be 2 different statements, but with the first character of the second line being a valid continuation of the first, will be treated as one statement with unpredictable results. This practically happens only when a line starts with either ( [ + - /</p>
<pre class="brush: js">// function call instead of grouping
var a = b + c
(d + e).print()
// is really
var a = b + c(d + e).print()

// array index instead of array literal
var a = ["a", "b", "c"]
[0, 1].forEach( &#8230; )
// is really
var a = ["a", "b", "c"][0, 1].forEach( &#8230; )

// binary math operator instead of unary
var a = b + c
-1 == string.indexOf(query) || die()
// is really
var a = b + c &#8211; 1 == string.indexOf(query) || die()

// division instead of regular expression
var i=0
/[a-z]/g.exec(s)
// is really
var i=0 /[a-z]/g.exec(s)</pre>
<p>Well, this sucks, so what should you do? I could say that i remember being caught by this problem just once in many years of javascript. The return problem or starting a line the nasty way is something <em>extremely rare</em>. But even if you don't want to afford the risk, why avoid ASI without even knowing about it? Without even thinking about a reasonable fix, given the nicer syntax? And this leads me to the second point:</p>
<p><strong>"To write semicolon-free code and avoid getting bitten, you just need to remember 2 rules</strong></p>
<p><strong> 1) Don't put an end-of-line between return, break, continue, throw, postfix ++, postfix -- and their operand<br />
2) Avoid starting a line with ( [ +  - / but if you have to, prepend it with a semicolon"</strong></p>
<pre class="brush: js">// everything's fine
return { ... }
continue label
break label
throw error
counter++
counter--

var a = b + c
;(d + e).print()

var a = ["a", "b", "c"]
;[0, 1].forEach( ... )

var a = b + c
;-1 == string.indexOf(query) || die()

var i=0
;/[a-z]/g.exec(s)</pre>
<p>Is it that taxing to remember? Automatic semicolon insertion is of course controversial, but using it is not a complete failure. It's a matter of taste, a trade-off between cleaner nicer code and some tough albeit avoidable pitfall.</p>
<p>While i'm at it, let's debunk some well known myths that always show up</p>
<ul>
<li><strong>"I could know ASI but others don't and they will mess things out"</strong><br />
Well this may be true. It depends on where you work, the skill of your peers, etc.. To me, a javascript programmer is just supposed to know this stuff as he knows of prototype and first class functions. If they don't, supposing they got the opposable thumbs, as they can be told to put semicolons everywhere, they can be told to remember the above 2 simple rules.</li>
<li><strong>"It's not gonna work the same way on every browser"</strong><br />
It's in the specs since more than a decade. I think browser bugs are a thing of the past and even proponents of this theory look unable to find <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=238945">something newer than 5 years ago</a>, so.</li>
<li><strong>"It breaks the tools. You cannot minify code anymore, etc..."</strong><br />
Let's be clear about this. It's officially part of the language. A tool unable to cope with ASI is a broken tool, period. Anyway, i have never had a problem with <a href="http://code.google.com/closure/compiler/">google closure compiler</a>.<strong> </strong></li>
<li><strong>"Jslint doesn't work with it"</strong><br />
<a href="http://www.jslint.com/">Jslint</a> enforces the vision of Douglas and it's pretty strict about it. This is fair, yet for those having another vision nothing is wrong with using <a href="http://jshint.com/">Jshint</a> which has an option to accept ASI. <strong> </strong></li>
</ul>
<p>Let's close with two very nice articles that explain the details and of course you can always read the ecmascript specs:</p>
<p><a href="http://inimino.org/~inimino/blog/javascript_semicolons">The most well-written comprehensive article</a></p>
<p><a href="http://lucumr.pocoo.org/2011/2/6/automatic-semicolon-insertion/">Very good explanation of the pitfalls</a></p>
<p><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">The plain specs </a></p>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2011/05/25/die-semicolon-die/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Please Don&#8217;t Touch the Slow Parts</title>
		<link>http://federico.galassi.net/2010/05/08/please-dont-touch-the-slow-parts/</link>
		<comments>http://federico.galassi.net/2010/05/08/please-dont-touch-the-slow-parts/#comments</comments>
		<pubDate>Sat, 08 May 2010 09:58:09 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[better software]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[faster web]]></category>
		<category><![CDATA[fullo]]></category>
		<category><![CDATA[high performance web sites]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[slow parts]]></category>
		<category><![CDATA[steve souders]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=321</guid>
		<description><![CDATA[I spoke at Better Software 2010, together with Fullo, about speeding up web applications. The talk draws heavily from Steve&#8217;s work, but it&#8217;s a little bit different from current literature because it tries to organize best practices not as flat list but under macro-areas emerged as &#8220;slow parts&#8221;. Also, i concluded with my obsession that [...]]]></description>
			<content:encoded><![CDATA[<p>I spoke at <a href="http://www.bettersoftware.it">Better Software</a> 2010, together with <a href="http://www.ideato.it">Fullo</a>, about speeding up web applications. The talk draws heavily from <a href="http://www.stevesouders.com/">Steve&#8217;s work</a>, but it&#8217;s a little bit different from current literature because it tries to organize best practices not as flat list but under macro-areas emerged as &#8220;slow parts&#8221;. Also, i concluded with <a href="http://federico.galassi.net/2009/11/15/javascript-performance-make-the-browser-happy-and-you-sad/">my obsession</a> that complexity inherently introduced by performance optimizations should not be dealt with by programmers directly, but by means of automation and abstraction.</p>
<p>Here it is.</p>
<p><strong>update</strong>: now i am linking to the extended version which i gave at phpday 2010</p>
<div style="width:425px" id="__ss_4110316"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/fgalassi/please-dont-touch-the-slow-parts-v2" title="Please Don&#39;t Touch the Slow Parts V2">Please Don&#39;t Touch the Slow Parts V2</a></strong><object id="__sse4110316" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=pleasedonttouch2-100515130606-phpapp01&#038;stripped_title=please-dont-touch-the-slow-parts-v2" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse4110316" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=pleasedonttouch2-100515130606-phpapp01&#038;stripped_title=please-dont-touch-the-slow-parts-v2" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/fgalassi">Federico Galassi</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2010/05/08/please-dont-touch-the-slow-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I did It: Touch Typist in five months</title>
		<link>http://federico.galassi.net/2010/01/27/how-i-did-it-touch-typist-in-five-months/</link>
		<comments>http://federico.galassi.net/2010/01/27/how-i-did-it-touch-typist-in-five-months/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 17:22:52 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[deep]]></category>
		<category><![CDATA[kaizen]]></category>
		<category><![CDATA[kata]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[practice]]></category>
		<category><![CDATA[touch]]></category>
		<category><![CDATA[type]]></category>
		<category><![CDATA[typeracer]]></category>
		<category><![CDATA[typing]]></category>
		<category><![CDATA[typingweb]]></category>
		<category><![CDATA[typist]]></category>
		<category><![CDATA[wpm]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=242</guid>
		<description><![CDATA[Until, from the midst of this darkness, a sudden light broke in upon me, a light so brilliant and wonderous, and yet so simple. Deep practice, eradicate errors and deep practice again. I alone succeeded in discovering the secret of bestowing skill. Nay, even more, I myself became capable of bestowing mastery upon apprentice matter. [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><img class="alignright size-full wp-image-243" title="it-could-work" src="http://federico.galassi.net/wp-content/uploads/2010/01/it-could-work.jpg" alt="it-could-work" width="200" height="157" />Until, from the midst of this darkness, a sudden light broke in upon me, a light so brilliant and wonderous, and yet so simple. Deep practice, eradicate errors and deep practice again. I alone succeeded in discovering the secret of bestowing skill. Nay, even more, I myself became capable of bestowing mastery upon apprentice matter.</p>
<p><strong>It could work.</strong></p></blockquote>
<p>At the end of august 2009, while i was reading about <a href="http://steve-yegge.blogspot.com/2008/09/programmings-dirtiest-little-secret.html">the importance for a programmer to touch type</a>, i found out many programmers could type at 80 <a href="http://en.wikipedia.org/wiki/Words_per_minute">wpm</a> and above. I tried myself and consistently scored 60 wpm or below. I have been spending many hours a day at the keyboard since at least 1996. How could it be i am not as fast? I already knew about the importance of practice, but i did practice for years, didn&#8217;t I? Well, uhm, no.</p>
<p>Think of the career of a professional <a href="http://en.wikipedia.org/wiki/Soccer_player">football (soccer) player</a>. How does he get there, does he play all the time for years? Actually, he spends most of the week <a href="http://www.soccer-training-info.com/sample_workout_routine.asp">training</a>: stretching, pushups, sprints, weights, long runs, ball work, etc&#8230; Only a small percentage of time is indeed to play short games and the main game on sunday. That&#8217;s because play alone can only push your performance to the upper end of the range set by current skill. It&#8217;s not going to push you to the next level, to the next order of magnitude, and it doesn&#8217;t keep you from developing bad habits. And that&#8217;s where i got, very fast at typing in my very flawed 7-fingers posture. Not able to improve any further, not even in more than 10 years.</p>
<p>I really <a href="http://en.wikipedia.org/wiki/Kaizen">wanted to get better</a>, so the questions were How? and How long will it take? I didn&#8217;t know the answer to the latter but the former was by then clear in my mind. Find a keyboard dojo, do keyboard <a href="http://federico.galassi.net/2009/09/02/code-katas-programmers-deep-practice/">katas</a> and take the needed time. After trying a lot of viable solutions i found my dojo at <a href="http://www.typingweb.com/">www.typingweb.com</a>. To add some salt to the challenge i switched keyboard layout from italian to U.S., which is quite better for programming, and i started practicing daily with their courses, routinely taking tests to record my progress. Two <a href="www.pomodorotechnique.com/">pomodoros</a> a day for the first two months, then one, then again two when i was reaching the end. Always striving to get 97% or above accuracy at the higher possible speed for every single lesson.</p>
<p>Now, five months and about 120 pomodoros of deep practice later, i am writing this to shout to the world that IT COULD WORK. Next i&#8217;ll be moving to <a href="http://federico.galassi.net/2009/07/31/vim-or-the-inevitable-value-of-complexity/">vim</a> katas, while still having some fun at <a href="http://www.typeracer.com">www.typeracer.com</a>, because you never really stop to practice right?!</p>
<p style="text-align: right;">Yours sincerely,<br />
ten fingers typist<br />
american layout<br />
80 wpm average<br />
up to 100 wpm under a good moon<br />
Federico.</p>
<p style="text-align: right;"><img class="aligncenter size-full wp-image-252" title="typing_sep09" src="http://federico.galassi.net/wp-content/uploads/2010/01/typing_sep092.png" alt="typing_sep09" width="573" height="282" /></p>
<p style="text-align: right;"><img class="aligncenter size-full wp-image-251" title="typing_nov09-gen10" src="http://federico.galassi.net/wp-content/uploads/2010/01/typing_nov09-gen10.png" alt="typing_nov09-gen10" width="573" height="284" /></p>
<p style="text-align: right;">
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2010/01/27/how-i-did-it-touch-typist-in-five-months/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Performance: Make the Browser Happy (and You Sad)</title>
		<link>http://federico.galassi.net/2009/11/15/javascript-performance-make-the-browser-happy-and-you-sad/</link>
		<comments>http://federico.galassi.net/2009/11/15/javascript-performance-make-the-browser-happy-and-you-sad/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 20:40:11 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[simplicity]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[aptimize]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[compilers]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[mark]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[twain]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=193</guid>
		<description><![CDATA[The browser is emerging as the best platform for applications, so a large community is growing to address its final weakness: speed. Google, Yahoo and various independent programmers are all pushing a bunch of clever techniques to boost performance and please end users. That&#8217;s nice, yet as Mark Twain once said, half of the results of good [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-203" title="BENDER" src="http://federico.galassi.net/wp-content/uploads/2009/11/BENDER1.jpeg" alt="BENDER" width="232" height="184" />The browser is emerging as the <a href="http://en.wikipedia.org/wiki/HTML5">best platform</a> for applications, so a large community is growing to address its final weakness: speed. <a href="http://code.google.com/speed/">Google</a>, <a href="http://developer.yahoo.com/performance/">Yahoo</a> and <a href="http://javascriptrocks.com/performance/">various independent programmers</a> are all pushing a bunch of clever techniques to boost performance and please end users. That&#8217;s nice, yet as Mark Twain once said, <em>half of the results of good intentions are evil</em> and i see potential danger in many of the suggestions made. Here a representative short list of them:</p>
<ul>
<li>Avoid for-in and forEach in favor of optimized while loops</li>
<li>Before making modifications to a DOM node remove it and then re-insert it</li>
<li>To insert multiple DOM nodes, first insert them into a Document Fragment and then add it to the DOM</li>
<li>Join all scripts into a single file</li>
<li>Load javascript files on demand</li>
</ul>
<p>Let&#8217;s make it clear for once, execution speed is not a human problem, that&#8217;s what computers are for, they execute our commands fast. The human problem is programming speed and writing down clear, readable, maintainable commands aka programs. forEach loops make sense to me, they say &#8220;i want to do something on each item&#8221;, optimized while loops make sense to computers. If i want to add DOM nodes or modify one, i don&#8217;t care of removing it or document fragments, browsers care. To me it&#8217;s just noise. Almost all of the problems addressed by those techniques stem from lack of smartness in the browser, and that&#8217;s where fixes belong to, on the machine side. The fact that there are <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">inept browser makers</a> is no excuse. Fixes still belong to the machine, they&#8217;re repeatable and can be made automatic. We have a long history of programs automatically converting human friendly code to machine friendly code. They&#8217;re called <a href="http://en.wikipedia.org/wiki/Compiler">compilers</a> and the output either machine code or optimized javascript doesn&#8217;t matter.</p>
<p>So, learn about javascript performance since knowledge is always the way, but don&#8217;t turn yourself into a machine, you&#8217;d be an awful one. Use the tools and wait for browsers to catch up.</p>
<ul>
<li><a href="http://www.aptimize.com/">Aptimize</a></li>
<li><a href="http://code.google.com/closure/compiler/">Closure Compiler</a></li>
<li><a href="http://developer.yahoo.com/yui/3/yui/#use">YUI 3 use</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2009/11/15/javascript-performance-make-the-browser-happy-and-you-sad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code Katas: Programmer&#8217;s Deep Practice</title>
		<link>http://federico.galassi.net/2009/09/02/code-katas-programmers-deep-practice/</link>
		<comments>http://federico.galassi.net/2009/09/02/code-katas-programmers-deep-practice/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:27:46 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[deep]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[kaizen]]></category>
		<category><![CDATA[kata]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[practice]]></category>
		<category><![CDATA[talent]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=148</guid>
		<description><![CDATA[I&#8217;ve recently blogged about talent and how it&#8217;s grown through disciplined, committed, error focused practice at the edge of your ability, known as deep practice. I guess now it makes sense to approach it from the perspective of programming: What&#8217;s programmer&#8217;s deep practice? Unsurprisingly, inspiration can be found in the great japanese culture, people who [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-149" style="margin: 2px;" title="karate_champ" src="http://federico.galassi.net/wp-content/uploads/2009/09/karate_champ.png" alt="karate_champ" width="180" height="206" />I&#8217;ve recently <a href="http://federico.galassi.net/2009/08/28/teach-yourself-anything-in-10000-hours/">blogged about talent and how it&#8217;s grown</a> through disciplined, committed, error focused practice at the edge of your ability, known as deep practice. I guess now it makes sense to approach it from the perspective of programming: What&#8217;s programmer&#8217;s deep practice? Unsurprisingly, inspiration can be found in the great japanese culture, people who highly value <a href="http://en.wikipedia.org/wiki/Bushid%C5%8D">discipline</a> and <a href="http://en.wikipedia.org/wiki/Kaizen">self improvement</a>. Specifically i&#8217;m talking of martial arts. If you were to learn, say, karate you would go to a <a href="http://en.wikipedia.org/wiki/Dojo">dojo</a> and perform <a href="http://en.wikipedia.org/wiki/Kata">katas</a>. If you happen to be a programmer, you can go to a coding dojo and practice code katas.</p>
<p><a href="http://en.wikipedia.org/wiki/Kata_%28programming%29">Code katas</a>, a term first coined by Pragmatic Programmer <a href="http://en.wikipedia.org/wiki/Dave_Thomas_%28programmer%29">Dave Thomas</a>, are small programming exercises geared to hone a specific programming skill. Traditionally, they tend to be <a href="http://en.wikipedia.org/wiki/Algorithm">algorithmic</a> like parsing or visiting graphs but could as well aim to improve understanding of particular <a href="http://en.wikipedia.org/wiki/Programming_paradigm">programming paradigms</a>, like functional or object oriented, or a specific language. Also, <a href="http://matteo.vaccari.name/blog/archives/177">as remarkably pointed out by Matteo</a>, katas can be crafted to master a certain technology like web or database. While, as you may guess, Coding Dojos are sites, groups or communities which propose and maintain collections of katas hopefully with solutions and reviews.</p>
<p>So, how do you practice? I suggest you solve a kata, review your work, compare it to other solutions, share your code with others and discuss it. Then solve it again trying to take a different path, balance pros and cons, then solve it again and again, until you <em>feel you internalized the essence of the problem</em>. Finally, you can move to another kata. If it feels like a lot of work, then you got it right. No question mastership requires time and effort but, then again, masters are those destined for greatness.</p>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://www.katacasts.com/">Katacasts</a></li>
<li><a href="http://codekata.pragprog.com/2007/01/code_kata_backg.html">21 Code Katas by Dave Thomas</a></li>
<li><a href="http://www.rubyquiz.com/">Lots of Code Quizzes with Ruby Solutions</a></li>
<li><a href="http://matteo.vaccari.name/blog/archives/177">Matteo Vaccari&#8217;s Technological Katas</a></li>
<li><a href="http://codingdojo.org/cgi-bin/wiki.pl?KataCatalogue">Coding Dojo Code Katas</a></li>
<li><a href="http://charlesmaxwood.com/8-lessons-from-corey-haines-performance-kata/">Corey Haines Video Solution in Ruby of String Template</a></li>
<li><a href="http://butunclebob.com/ArticleS.UncleBob">Uncle Bob</a> Code Katas (search &#8220;kata&#8221;, ie bowling kata)</li>
<li><a href="http://rubyconf2008.confreaks.com/ruby-kata-and-sparring.html">Micah Martin on Code Katas and Video Solution in Ruby of Langton&#8217;s Ant</a></li>
<li><a href="http://sparring.rubyforge.org/battleship/">Micah Martin&#8217;s BattleShip Tournament</a></li>
<li><a href="http://code.google.com/codejam/">Google Code Jam</a></li>
<li><a href="http://www.codinghorror.com/blog/archives/001138.html">Jeff Atwood on Code Katas</a></li>
<li><a href="http://steve.yegge.googlepages.com/practicing-programming">Steve Yegge on Code Katas<br />
</a></li>
<li><a href="http://norvig.com/21-days.html">Peter Norvig on Deep Practice</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2009/09/02/code-katas-programmers-deep-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Teach Yourself Anything in 10000 hours</title>
		<link>http://federico.galassi.net/2009/08/28/teach-yourself-anything-in-10000-hours/</link>
		<comments>http://federico.galassi.net/2009/08/28/teach-yourself-anything-in-10000-hours/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 14:42:39 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[psychology]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[genius]]></category>
		<category><![CDATA[kaizen]]></category>
		<category><![CDATA[myelin]]></category>
		<category><![CDATA[practice]]></category>
		<category><![CDATA[skill]]></category>
		<category><![CDATA[talent]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=137</guid>
		<description><![CDATA[During my holidays, on a beautiful spot by the river, i had the opportunity to finish The Talent Code. This nice book brings empirical evidence and scientific foundations to something i have felt for quite some time: Talent isn&#8217;t born, it&#8217;s grown. Actually this has been something known to humanity for at least a century [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-139" title="talent_small" src="http://federico.galassi.net/wp-content/uploads/2009/08/talent_small.jpg" alt="talent_small" width="200" height="267" />During my holidays, on a beautiful spot by the river, i had the opportunity to finish <a href="http://thetalentcode.com/">The Talent Code</a>. This nice book brings empirical evidence and <a href="http://en.wikipedia.org/wiki/Myelin#Function_of_myelin_layer">scientific foundations</a> to something i have felt for quite some time:<br />
Talent isn&#8217;t born, it&#8217;s grown.</p>
<p>Actually this has been something known to humanity for at least a century and it&#8217;s best explained by this quote from <a href="http://en.wikipedia.org/wiki/Thomas_Edison">Thomas Edison</a>:</p>
<blockquote><p>Genius is 1% inspiration and 99% perspiration</p></blockquote>
<p>The point is that becoming great at something is largely a matter of the amount and quality of practice one does. While God given talent can only boost this process, but it&#8217;s by no means the most influential factor.</p>
<p>About the amount of practice, there&#8217;s the old <a href="http://norvig.com/21-days.html">&#8220;Ten Years Rule&#8221;</a> and <a href="http://www.amazon.com/Cambridge-Expertise-Performance-Handbooks-Psychology/dp/0521600812">a more refined study by Anders Ericsson</a> who sets in 10000 hours of committed practice the time taken to achieve expert level. From the <a href="http://www.pomodorotechnique.com">Pomodoro Technique</a>, we know one can do about 5 hours/day of efficient work (10 pomodoros). That means 5 years and a half, 5 hours every day of hard work could be a good guess to the question &#8220;How long does it take?&#8221;.</p>
<p>About the quality of practice, the book calls the good one &#8220;deep practice&#8221;</p>
<blockquote><p>working on technique, seeking constant critical feedback and focusing ruthlessly on shoring up weaknesses</p></blockquote>
<p>So deep practice has a pretty simple recipe:</p>
<ul>
<li>practice just beyond your current ability</li>
<li>focus on errors</li>
<li>fix them</li>
<li>repeat</li>
</ul>
<p>Basically, it&#8217;s tenacious, steady continuous improvement, so it&#8217;s not surprising <a href="http://en.wikipedia.org/wiki/Kaizen">Kaizen</a> is mentioned in the book.</p>
<p>In the end, we are left with two news: one bad, one awesome. The bad one is if you fail to reach master level in a discipline you care of, there&#8217;s no one to blame but yourself. Sadly, you got to <a href="http://federico.galassi.net/2009/06/12/on-the-paradox-of-choice-and-customer-happiness/">take responsibility even for that</a>. But the awesome news is you can really become what you want be. Just keep working.</p>
<p>Let&#8217;s close with this sweet advice from great italian poet <a href="http://en.wikipedia.org/wiki/Giovanni_Papini">Giovanni Papini</a></p>
<blockquote><p>Chiunque, purché sappia                  chiaramente cosa vuol divenire e non perda un solo secondo della                  sua vita, può issarsi al livello di coloro che dettano                  le leggi alle cose e che creano vite più degne. (Da &#8220;Diventar Genio&#8221; &#8211; 1912)</p></blockquote>
<p>and my rough translation</p>
<blockquote><p>Anyone, as long as he clearly knows what he wants to become and doesn&#8217;t waste a single second of his life, can raise himself to the level of those who lay down the law of things and create more worthy lives (From &#8220;Becoming Genius&#8221; &#8211; 1912)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2009/08/28/teach-yourself-anything-in-10000-hours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim or the Inevitable Value of Complexity</title>
		<link>http://federico.galassi.net/2009/07/31/vim-or-the-inevitable-value-of-complexity/</link>
		<comments>http://federico.galassi.net/2009/07/31/vim-or-the-inevitable-value-of-complexity/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 21:59:12 +0000</pubDate>
		<dc:creator>federico</dc:creator>
				<category><![CDATA[simplicity]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[complexity]]></category>
		<category><![CDATA[craftsman]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://federico.galassi.net/?p=125</guid>
		<description><![CDATA[It&#8217;s becoming clear to me that a programmer is probably closer to a craftsman than a scientist. The craftsman greatest strength is mastership of his tools. So just as the carpenter masters the plane to shape wood, the programmer must master a text editor to shape programs. I&#8217;ve spent enough time wandering aimlessly around a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vim.org/"><img class="alignright size-full wp-image-129" title="vim" src="http://federico.galassi.net/wp-content/uploads/2009/07/vim.png" alt="vim" width="135" height="155" /></a>It&#8217;s becoming clear to me that a programmer is probably closer to a <a href="http://manifesto.softwarecraftsmanship.org/">craftsman</a> than a scientist. The craftsman greatest strength is mastership of his tools. So just as the carpenter masters the plane to shape wood, the programmer must master a text editor to shape programs. I&#8217;ve spent enough time wandering aimlessly around a lot of editors and IDE&#8217;s. It&#8217;s time for me to settle down, make a competent choice and <a href="http://norvig.com/21-days.html">take the years</a> needed to become proficient in it. I wanted something possibly simple, light and which would <a href="http://blog.alagad.com/2007/06/15/changing-the-font-size-in-eclipse/">leave <strong>me</strong> in control</a>. That means an editor over an IDE, but which one? I did some deep research and after an endless stream of positive reviews backed by <a href="http://www.gabrielelana.it/">Gabriele</a> &#8220;warm&#8221; suggestion, i bought <a href="http://www.amazon.com/Learning-Vim-Editors-Arnold-Robbins/dp/059652983X/">&#8220;Learning the Vi and Vim Editors 7th edition&#8221;</a>. <a href="http://www.vim.org/">Vim</a> is 1991 software based on a 1970s one, and it&#8217;s great. Btw my second best was <a href="http://www.gnu.org/software/emacs/emacs.html">emacs</a>, another 1970s software. This must say something about advances in <span style="text-decoration: line-through;">text editing</span> software industry. Anyway, now that i&#8217;ve finished the book and daily using Vim, i realize its very existance is relevant to the <a href="http://federico.galassi.net/category/simplicity/">&#8220;simplicity in software&#8221;</a> debate.</p>
<p>Is Vim amazing software? Yes. Is Vim simple? No. This could imply that simplicity is a highly overrated software value, but i think it&#8217;s not. It just implies that, as any other thing under the sun, simplicity is a relative value. Relative to what? I guess to user&#8217;s knowledge of the domain. Let me explain.</p>
<p>Simple software is one that provides a few objects and a few rules to compose those objects coherently into newer more complex abstractions. This makes an optimal hotbed to learn. Few objects are easy to understand and remember. Few corner case free rules give confidence while exploring the unknown. It&#8217;s important that the learner is not exposed to further possibly useful complexity which is not ready for yet. Only some to ignite inspiration, but greater power cannot come a priori, but as a consequence of greater understanding of the domain. This way user and software evolve together.</p>
<p>&#8220;Good&#8221; Complex software, which still tries to minimize basic objects and rules and completely avoid corner cases, may ship equipped with many levels of abstraction relevant to the domain. That&#8217;s for the sake of efficiency, so that the skilled user will be able to manage complex scenarios by quickly referring those abstractions. Give something too simple to the master and he will end up bored and unproductive. Give something too complex to the apprentice and he will run away confused.</p>
<p>Vim is extremely good and complex software which comes with a <a href="http://vimdoc.sourceforge.net/htmldoc/usr_toc.html">plethora of short keyboard commands</a> to make any conceivable manoeuvre on text at top speed. Optimized for being efficient with keyboard, which already happens to be the most efficient input device, usually much better than mouse. That&#8217;s heaven for <a href="http://en.wikipedia.org/wiki/Touch_typing">touch typists</a> as i am. The nice thing about efficiency is that it can be easily quantified by time. Same goal, the faster the better.</p>
<p>Let&#8217;s close with a fulgid example of vim capabilities with a common editing pattern: swapping two words.<br />
An usual hybrid keyboard/mouse approach on windows:</p>
<ul>
<li>Select the first word (click/drag the mouse or double click)</li>
<li>Cut (ctrl+x or right click and use menu)</li>
<li>Move the cursor after the next word (move the mouse and click)</li>
<li>Paste (ctrl+v or right click and use menu)</li>
</ul>
<p>I guess it takes 3-4 seconds to complete correctly</p>
<p>Vim keyboard based approach:</p>
<ul>
<li>type dwwP</li>
</ul>
<p>An average good typist can do 50 <a href="http://en.wikipedia.org/wiki/Words_per_minute">wpm</a> which means it takes about 1 second to type 4 characters. That&#8217;s efficient.</p>
]]></content:encoded>
			<wfw:commentRss>http://federico.galassi.net/2009/07/31/vim-or-the-inevitable-value-of-complexity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

