<?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>Heap Heap Array!</title>
	<atom:link href="http://siwoti.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://siwoti.com/blog</link>
	<description>Putting the &#039;dys&#039; in &#039;functional programming&#039;.</description>
	<lastBuildDate>Fri, 03 Sep 2010 03:05:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>The Language Wars Rage On</title>
		<link>http://siwoti.com/blog/2010/09/the-language-wars-rage-on/</link>
		<comments>http://siwoti.com/blog/2010/09/the-language-wars-rage-on/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 03:05:51 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=116</guid>
		<description><![CDATA[Should a VB6 shop start using VB.NET, or should they switch to C#? In addition to my business, I work for a county-level government agency in Florida. Our legacy system is a 1.2-million-line steaming pile of VB6. While it works (for limited definitions of &#8220;works&#8221;), there&#8217;s no way we&#8217;re going to be able to maintain [...]]]></description>
			<content:encoded><![CDATA[<p>Should a VB6 shop start using VB.NET, or should they switch to C#?</p>
<p>In addition to my business, I work for a county-level government agency in Florida. Our legacy system is a 1.2-million-line steaming pile of VB6. While it works (for limited definitions of &#8220;works&#8221;), there&#8217;s no way we&#8217;re going to be able to maintain it forever, and we&#8217;re certainly not going to write new projects in VB6.</p>
<p>Since we&#8217;re a Microsoft shop, we&#8217;re going to the .NET platform. The choice, however, is whether to use the familiar syntax and stick with VB.NET, or to harness the additional power of C#. I favor the latter approach, and I&#8217;m pleased that the Powers That Be agree.</p>
<p>The world of .NET development is dramatically different from VB6. Techniques that work in VB6 no longer work in .NET; techniques that work in .NET fail miserably in VB6, and even some things that work in both environments are sufficiently different to be difficult to understand.</p>
<p>Using similar syntax to express dissimilar ideas is a recipe for confusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2010/09/the-language-wars-rage-on/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Respect the Pomodoro</title>
		<link>http://siwoti.com/blog/2010/01/respect-the-pomodoro/</link>
		<comments>http://siwoti.com/blog/2010/01/respect-the-pomodoro/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 21:42:00 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[Professional Development]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=96</guid>
		<description><![CDATA[I&#8217;ll be the first to admit that my greatest weakness is time management. I&#8217;m a procrastinator extraordinaire. (If you doubt me, simply check the time between posts on this very blog.) I find it difficult to get started on a huge project if I know the project is going to be huge up front. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be the first to admit that my greatest weakness is time management. I&#8217;m a procrastinator extraordinaire. (If you doubt me, simply check the time between posts on this very blog.)</p>
<p>I find it difficult to get started on a huge project if I know the project is going to be huge up front. It&#8217;s even harder at the tail end of a project, when all of the fun stuff is done and all that&#8217;s left is the annoying little tweaks and bug fixes needed to make a program &#8216;production ready&#8217;. Project Waldo<a href="#foot_1" name="foot_src_1"><sup>1</sup></a> is in that very phase right now. When the fun stuff is done, my velocity drops to near zero.</p>
<p>The biggest problem seems to be a lack of internal feedback on time use. If I spend seven hours coding and one hour conferring with colleagues, that&#8217;s a productive day. If I spend one hour coding and seven hours conferring with colleagues, that&#8217;s an unproductive day. If I spend eight hours reading programming books, that&#8217;s a supremely unproductive day (except for the professional development idea). But I tend to gravitate toward lack of productivity, because, frankly, it&#8217;s more fun than keeping my nose to the grindstone, and I tend not to notice that I&#8217;m not being productive.</p>
<p>That&#8217;s where <a href="http://www.pomodorotechnique.com/" onclick="pageTracker._trackPageview('/outgoing/www.pomodorotechnique.com/?referer=');">the Pomodoro Technique</a> comes in.</p>
<p>For those of you who haven&#8217;t heard of it: the Pomodoro Technique is a time management system, based around indivisible units of time (&#8220;pomodoro&#8221;<a href="#foot_2" name="foot_src_2"><sup>2</sup></a>). A standard pomodoro is 25 minutes, followed by a 5 minute break.</p>
<p>The advantages are many. First, and foremost, there is immediate feedback if my work begins to slow down again. If the end of the day arrives and I&#8217;ve only completed three pomodoro, I know that either I&#8217;m spending too much time goofing off or I&#8217;m being far too often interrupted. Second, the system reminds me to take frequent breaks. When I do get in the zone, I tend to not leave my chair for hours at a stretch (no pun intended). The bell gets me out of the zone and onto my feet.  Finally, the recording system doubles as a to-do list; as I think of things I need to do, I write them down, and I can go back and prioritize later. Without a system, everything tends to either be &#8216;priority 1&#8242; or completely forgotten.</p>
<p>It also works because it appeals to my sense of completionism. If I see a goal on my list, I want to complete it. The Pomodoro Technique literature suggests tasks be broken down into approximately 3-hour increments (5 to 7 pomodoro). I can see my progress toward those goals; I can&#8217;t really see the progress toward the end. At any given time, I know what I&#8217;ve done and what is left to do.</p>
<p>I know that the Pomodoro Technique seems to have been further refined and polished among the developer community. I&#8217;m not really using those refinements yet; I&#8217;m &#8220;playing by the book&#8221;. The system as written works for me, and while I may be able to adjust it later to better fit my needs, I&#8217;ll try it as it is for a while.</p>
<p><span class="yafootnote_head">FOOTNOTES</span><br /><span class="yafootnote_body"><a name="foot_1">1.</a>&nbsp;It&#8217;s a mapping application. I&#8217;m a GIS developer, even though it&#8217;s not really my passion. But I can still make corny puns.&nbsp;<a href="#foot_src_1">&uarr;</a></span><br /><span class="yafootnote_body"><a name="foot_2">2.</a>&nbsp;The plural of &#8220;pomodoro&#8221; is an open question. Proper Italian is either &#8220;pomidoro&#8221; (from &#8220;pomo d&#8217;oro&#8221;) or &#8220;pomodori&#8221;. &#8220;Pomodoroes&#8221; would probably fit in English, but doesn&#8217;t ring well. According to <a href="http://twitter.com/paulirwin/status/7949311406" onclick="pageTracker._trackPageview('/outgoing/twitter.com/paulirwin/status/7949311406?referer=');">a colleague</a>, the plural of &#8220;pomodoro&#8221; is &#8220;pomodoro&#8221; (or maybe it&#8217;s &#8220;sharpei&#8221;, I&#8217;m not sure).&nbsp;<a href="#foot_src_2">&uarr;</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2010/01/respect-the-pomodoro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 14</title>
		<link>http://siwoti.com/blog/2009/12/project-euler-problem-14/</link>
		<comments>http://siwoti.com/blog/2009/12/project-euler-problem-14/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 05:24:47 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=74</guid>
		<description><![CDATA[For the last 36 hours, off and on, I&#8217;ve been working on solutions to Project Euler problems, just to learn some F#. I started at the beginning and have been working my way up, as the difficulty increases. So far, I&#8217;ve solved problems 1-10, 14, 47, and 243. Problem 9 doesn&#8217;t really count as I [...]]]></description>
			<content:encoded><![CDATA[<p>For the last 36 hours, off and on, I&#8217;ve been working on solutions to <a href="http://projecteuler.net/" onclick="pageTracker._trackPageview('/outgoing/projecteuler.net/?referer=');">Project Euler</a> problems, just to learn some F#. I started at the beginning and have been working my way up, as the difficulty increases.</p>
<p>So far, I&#8217;ve solved problems 1-10, 14, 47, and 243. Problem 9 doesn&#8217;t really count as I basically borrowed the code verbatim from <a href="http://diditwith.net/2009/03/09/YAPESProblemNine.aspx" onclick="pageTracker._trackPageview('/outgoing/diditwith.net/2009/03/09/YAPESProblemNine.aspx?referer=');">another site</a>, and problem 5 almost doesn&#8217;t as I solved it with pencil and paper.</p>
<p>I may cover a few of the others later, but for now I&#8217;ll focus on 14.</p>
<p><span id="more-74"></span></p>
<p><a href="http://projecteuler.net/index.php?section=problems&#038;id=14" onclick="pageTracker._trackPageview('/outgoing/projecteuler.net/index.php?section=problems_038_id=14&amp;referer=');">Problem 14</a> was a bit trickier than it looked. I knew from the start that I&#8217;d have to resort to some sort of memoization to get runtime down to a reasonable level. As noted on the Project Euler site:</p>
<blockquote><p>
Each problem has been designed according to a &#8220;one-minute rule&#8221;, which means that although it may take several hours to design a successful algorithm with more difficult problems, an efficient implementation will allow a solution to be obtained on a modestly powered computer in less than one minute.
</p></blockquote>
<p>A brute-force solution without memoization took way too long on the virtual machine I use to run Visual Studio 2010. (I don&#8217;t know how long, because I killed it after about ten minutes.) So, I borrowed some code from <cite>Programming F#</cite> (page 199):</p>
<pre class="brush: fsharp; title: ; notranslate">
open System.Collections.Generic

let memoize (f : 'a -&gt; 'b) =
    let dict = new Dictionary&lt;'a, 'b&gt;()

    let memoizedFunc (input : 'a) =
        match dict.TryGetValue(input) with
        | true, x -&gt; x
        | false, _ -&gt;
            let answer = f input
            dict.Add(input, answer)
            answer

    memoizedFunc
</pre>
<p>The project statement uses a starting point of 13, and gives a sequence length of 10; I realized that if the sequence ever reached 13, for instance, it would always be at 1 ten iterations later. My first attempt at a solution copied around the actual sequence of numbers for each starting point. Ideally, if I always tacked the new number on as the head, the tail would eventually be a list that had already been generated, and wouldn&#8217;t need to be recreated or even copied, as the new list could just point to the old one.</p>
<p>While this wasn&#8217;t a horrible idea, it seemed a lot slower than I&#8217;d like. So, I switched to a simple tally of sequence length. Still slow.</p>
<p>After I let the program run all the way through, I realized my problem: the debugging output. What started as a ten-minute process shortened itself to about ten seconds when I removed the printfn from the inner function. I probably could have kept the sequence after all.</p>
<pre class="brush: fsharp; title: ; notranslate">
let rec collatz =
    // The only reason to create an inner function here
    // is to memoize it. You have to call the outer
    // function recursively or the memoize function
    // won't catch it.
    let collatz_ (x : int64) =
        if x = 1L then 0
        elif x % 2L = 0L then
            1 + collatz (x / 2L)
        else
            1 + collatz (3L * x + 1L)

    memoize collatz_

// Candidates
[ 1L..999999L ]
    // Calculate path length for each, decorate
    |&gt; List.map (fun x -&gt; (collatz x, x))
    // Sort by path length...
    |&gt; List.sortBy fst
    // ... long paths first
    |&gt; List.rev
    // Give me just the longest path
    |&gt; List.head
    // Give me just the starting point
    |&gt; snd;;
</pre>
<p>PS: <a href="http://en.wikipedia.org/wiki/Collatz_conjecture" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Collatz_conjecture?referer=');">if you&#8217;re asking why it&#8217;s called &#8220;collatz&#8221;?</a></p>
<p>So, what did I learn?</p>
<p>I learned that console output is <em>slow</em>. I also learned that decorating an input list with tuples (a la the &#8220;Schwartzian Transform&#8221;) is a useful technique in F#. Function pipelining is incredibly handy. And I&#8217;m addicted to Project Euler.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2009/12/project-euler-problem-14/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rough Edges</title>
		<link>http://siwoti.com/blog/2009/11/rough-edges/</link>
		<comments>http://siwoti.com/blog/2009/11/rough-edges/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 14:40:46 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[F#]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=50</guid>
		<description><![CDATA[My copy of Programming F# arrived a few days ago, and I&#8217;ve been reading it in my spare time. In doing so, I&#8217;ve noticed a few oddities in the language. That isn&#8217;t to say that it isn&#8217;t a great language; it&#8217;s just clear that the integration between ML and the .NET framework is not entirely [...]]]></description>
			<content:encoded><![CDATA[<p>My copy of <a href="http://oreilly.com/catalog/9780596153656" onclick="pageTracker._trackPageview('/outgoing/oreilly.com/catalog/9780596153656?referer=');"><cite>Programming F#</cite></a> arrived a few days ago, and I&#8217;ve been reading it in my spare time. In doing so, I&#8217;ve noticed a few oddities in the language. That isn&#8217;t to say that it isn&#8217;t a great language; it&#8217;s just clear that the integration between ML and the .NET framework is not entirely seamless.</p>
<p><span id="more-50"></span></p>
<h4>Explicit Interface Implementation</h4>
<p>Why are all interfaces implemented explicitly, making it necessary to cast an object reference to an interface type before using any of the members of that interface?  I thought requiring that sort of redundant bullcrap was phased out with COM. The compiler knows what interfaces the class implements; shouldn&#8217;t it be able to determine, at least in the simple case, whether you&#8217;re calling something on an interface?</p>
<p>I mean, the compiler should be able to figure this out:</p>
<pre class="brush: fsharp; title: ; notranslate">
// Borrowed with modification from &quot;Programming F#&quot;
type IDoStuff =
    abstract DoStuff : unit -&gt; unit

type Foo() =
    interface IDoStuff with
        override this.DoStuff() = printfn &quot;Doing stuff...&quot;

let x = new Foo()

// This fails with a compiler error
x.DoStuff()

// This works.
(x :&gt; IDoStuff).DoStuff()

// This works too.
let y = x :&gt; IDoStuff
y.DoStuff()
</pre>
<p>Don&#8217;t get me wrong; I understand the utility of explicit interface implementation, at least when member names collide. But is it really necessary to require <em>all</em> interface members be explicit?</p>
<p>Note that this only applies to classes implemented in F#. Classes implemented in C# have the option of implementing interfaces implicitly, and F# can use those interfaces without casting. In VB.NET, interfaces are implemented explicitly, but generally with a method with the same name:</p>
<pre class="brush: vb; title: ; notranslate">
Public Interface IDoStuff
    Sub DoStuff()
    Sub DoMoreStuff()
End Interface

Public Class Class1
    Implements IDoStuff

    Public Sub DoStuff() Implements IDoStuff.DoStuff
        Console.WriteLine(&quot;Doing Stuff&quot;)
    End Sub

    Public Sub AnotherMethod() Implements IDoStuff.DoMoreStuff
        Console.WriteLine(&quot;Doing More Stuff&quot;)
    End Sub
End Class
</pre>
<p>Calling it from F# works much the same way:</p>
<pre class="brush: fsharp; title: ; notranslate">
let x = new ClassLibrary1.Class1()

// This works, since the method has the same name in the interface and class.
x.DoStuff()

// You can't call the interface method...
x.DoMoreStuff() // (fails with a compile error)

// ... but you can call the implementing method directly.
x.AnotherMethod()

// Or you can use the upcast operator.
(x :&gt; ClassLibrary1.IDoStuff).DoMoreStuff()
</pre>
<h4>Mutually Exclusive Exception-Handling Keywords</h4>
<p>Why can&#8217;t <code>catch</code> and <code>finally</code> be combined? The only other language I&#8217;m aware of that doesn&#8217;t allow combining of these forms is Python, and that&#8217;s only versions prior to 2.5. Hell, even VB.NET can combine <code>catch</code> and <code>finally</code>.</p>
<h4>Extension Methods</h4>
<p>When you add an extension method in F#, it only works with other F# code. You can&#8217;t call an extension method defined in F# from C# or VB.NET code. Granted, given the hassles involved in setting up extension methods in C# or VB.NET, this isn&#8217;t surprising, and probably for the best; within F#, extension methods are easy, and forcing compatibility with other languages would make them unwieldy. But still, having the option would be nice.</p>
<p>Overall, I&#8217;m pleased with F#. As a standalone language, it&#8217;s fairly impressive. While the .NET integration is a bit rough around the edges, it&#8217;s tied in well enough to act as an effective Trojan horse, bringing functional programming to .NET-only shops. And that&#8217;s worth the hassle.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2009/11/rough-edges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fledgling Forays in F#</title>
		<link>http://siwoti.com/blog/2009/11/fledgling-forays-in-f/</link>
		<comments>http://siwoti.com/blog/2009/11/fledgling-forays-in-f/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 04:01:48 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Functional Programming]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=38</guid>
		<description><![CDATA[So, to start learning F#, I searched for existing F# code. One of the first snippets I found was the sieve of Eratosthenes in many languages, including F#. Except the listed F# &#8216;sieve&#8217; wasn&#8217;t; it did an exhaustive search from 2 to Math.Sqrt(int_of_float n) for every element n. I thought, &#8220;Even as a beginner, I [...]]]></description>
			<content:encoded><![CDATA[<p>So, to start learning F#, I searched for existing F# code. One of the first snippets I found was <a href="http://www.scriptol.com/programming/sieve.php" onclick="pageTracker._trackPageview('/outgoing/www.scriptol.com/programming/sieve.php?referer=');">the sieve of Eratosthenes in many languages</a>, including F#. Except the listed F# &#8216;sieve&#8217; wasn&#8217;t; it did an exhaustive search from 2 to <code>Math.Sqrt(int_of_float n)</code> for every element <code>n</code>.</p>
<p>I thought, &#8220;Even as a beginner, I can do better than that.&#8221; Here&#8217;s my first attempt:</p>
<p><span id="more-38"></span></p>
<pre class="brush: fsharp; title: ; notranslate">
let rec primes_match n =
    match n with
        | nn when nn &lt;= 1 -&gt; []
        | nn when nn &gt; 1 -&gt;
            let so_far = primes_match (n - 1)
            if (so_far |&gt; List.filter (fun d -&gt; nn % d = 0) |&gt; List.isEmpty)
            then nn :: so_far
            else so_far

let primes n = n |&gt; primes_match |&gt; List.rev
</pre>
<p>Then I realized &#8216;match&#8217; was a bit heavy for what I&#8217;m doing, and shifted to if/then/else:</p>
<pre class="brush: fsharp; title: ; notranslate">
let rec primes_match n =
    if n &lt;= 1 then []
    else
        let so_far = primes_match (n - 1)
        if (so_far |&gt; List.filter (fun d -&gt; n % d = 0) |&gt; List.isEmpty)
        then n :: so_far
        else so_far

let primes n = n |&gt; primes_match |&gt; List.rev
</pre>
<p>And finally, I learned about <code>List.exists</code>.</p>
<pre class="brush: fsharp; title: ; notranslate">
let rec primes_match n =
    if n &lt;= 1 then []
    else
        let so_far = primes_match (n - 1)
        if (so_far |&gt; List.exists (fun d -&gt; n % d = 0))
        then n :: so_far
        else so_far

let primes n = n |&gt; primes_match |&gt; List.rev
</pre>
<p>I was proud, but not satisfied. There are still two major problems with this code. First, it&#8217;s still not the sieve of Eratosthenes. It&#8217;s just a more-time-efficient version (I think, maybe) of the original algorithm. Second, it&#8217;s not tail-recursive, and stack depth grows with the input parameter, so it can only generate primes up to 32,750 or so.</p>
<p>So, I started from scratch. I managed to create a new sieve function that is, in fact, the sieve of Eratosthenes, and tail-recursive. As it turns out, Chris Smith has <a href="http://blogs.msdn.com/chrsmith/archive/2008/04/29/sieve-of-eratosthenes-in-f.aspx" onclick="pageTracker._trackPageview('/outgoing/blogs.msdn.com/chrsmith/archive/2008/04/29/sieve-of-eratosthenes-in-f.aspx?referer=');">a sieve implementation</a> as well, but I didn&#8217;t look at it before writing my own. Mine came out shorter, but probably less efficient.</p>
<pre class="brush: fsharp; title: ; notranslate">
let rec sieve_drain (sifted : int list) (unsifted : int list) =
    if List.isEmpty unsifted then sifted
    elif (sifted |&gt; List.exists (fun d -&gt; (List.head unsifted) % d = 0))
    then sieve_drain sifted (List.tail unsifted)
    else sieve_drain ((List.head unsifted) :: sifted) (List.tail unsifted)

let sieve n =
    sieve_drain [] (2::[3..2..n]) |&gt; List.rev
</pre>
<p>Any suggestions? Am I being too strict when it comes to functional style? Is there any way I can polish this?</p>
<p><b>Update:</b></p>
<p>I managed to find a cleaner way to do this:</p>
<pre class="brush: fsharp; title: ; notranslate">
let rec sieve_drain (sifted : int list) (unsifted : int list) =
    match unsifted with
    | [] -&gt; sifted
    | x :: xs -&gt;
        if not (sifted |&gt; List.exists (fun d -&gt; x % d = 0))
        then sieve_drain (x::sifted) xs
        else sieve_drain sifted xs

let sieve n =
    if n &lt; 2 then [] else sieve_drain [] (2::[3..2..n]) |&gt; List.rev
</pre>
<p>But it&#8217;s not very efficient. Chris Smith&#8217;s implementation (due to the use of shared state) takes about 2.5 seconds to run from 1 to 500,000. Mine takes about 55.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2009/11/fledgling-forays-in-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying To Think Functionally</title>
		<link>http://siwoti.com/blog/2009/11/trying-to-think-functionally/</link>
		<comments>http://siwoti.com/blog/2009/11/trying-to-think-functionally/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 00:14:21 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[Functional Programming]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=11</guid>
		<description><![CDATA[Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot. [Eric S. Raymond] I, for one, know that I&#8217;m only partially enlightened. When I [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.  [Eric S. Raymond]
</p></blockquote>
<p>I, for one, know that I&#8217;m only partially enlightened.</p>
<p>When I was taking &#8220;Programming Languages&#8221; (COP 4020), one of the languages covered, intended to represent the entirety of functional programming, was Common Lisp. We studied it for about two weeks. On the exam, a 5-point question asked us to write a function to determine whether a list was palindromic. I set off writing tons of code (on paper, even), checking for the equality of the first and last elements, then stripping them off and recursing on the rest.</p>
<p>As I handed in my exam, I commented on the difficulty of that question compared to the low point value. The professor looked at my test, then at me, and then she wrote on a scrap of paper so that the other students couldn&#8217;t see (yet):</p>
<p><code>(defun is-a-palindrome (lst) (equal lst (reverse lst)))</code></p>
<p><em>That&#8217;s</em> thinking functionally. I could hammer out the code, but I was writing C with a bunch of parentheses. I wasn&#8217;t really writing in Lisp.</p>
<p>When I started working here, I was writing a lot of Python. Python isn&#8217;t generally considered a functional language, but it has enough of the features (first class functions, lists, map/filter/reduce, etc) to give me a taste of power. Then I was forced into using VB.NET 2005, which felt like stepping back in time a decade. It had none of the Pythony goodness I was used to: no list comprehensions, no map/filter/reduce (with clunky forms added in VB 2008), and no lambda statements (halfassedly added in 2008 and properly added, supposedly, in 2010).</p>
<p>What skill I picked up from Python quickly began to fade.</p>
<p>My outlook was bleak, as well. I thought the .NET platform was headed for the same old languages and the same old paradigms, for the same old <a href="http://www.paulgraham.com/avg.html" onclick="pageTracker._trackPageview('/outgoing/www.paulgraham.com/avg.html?referer=');">Blub coders</a>. I was afraid that I&#8217;d end up a Blub coder&#8230; or worse, that I already was one.</p>
<p>Then I saw some of the nice features of C# in .NET 3.5 (and immediately started griping that VB didn&#8217;t have them), and what&#8217;s more, I found F#.</p>
<p>Let me say this up front: I like Lisp. Most of it makes very little sense to me, but I can feel the power behind it. Though I&#8217;ve wanted to learn a functional language for a while now, I know that my chances of ever getting a job writing it are slim, so I&#8217;ve focused on the standard OO and procedural languages. F# has the advantage of being backed by Microsoft; Visual Studio 2010 will have F# out of the box, and it&#8217;ll be right there on the desks of almost every .NET programmer, overcoming much of the inertia that leads people to use languages like VB.</p>
<p>So that&#8217;s why I&#8217;ve decided to throw myself into F#; it&#8217;s a paradigm I want to embrace, and a language that I may actually get paid to use someday. That&#8217;s worth reshaping my mind for.</p>
<p>And at the very least, I&#8217;ll end up writing better code in other languages.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2009/11/trying-to-think-functionally/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Welcome, All</title>
		<link>http://siwoti.com/blog/2009/11/welcome-all/</link>
		<comments>http://siwoti.com/blog/2009/11/welcome-all/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:43:58 +0000</pubDate>
		<dc:creator>Benjamin Geiger</dc:creator>
				<category><![CDATA[Metablogging]]></category>

		<guid isPermaLink="false">http://siwoti.com/blog/?p=8</guid>
		<description><![CDATA[I&#8217;m a GIS (ew), VB.NET (double ew) and C# developer by trade, a general-purpose code monkey at heart, and always trying to learn new things. But I don&#8217;t want to learn on my own. So, I&#8217;m inviting everyone to join me as I try to teach myself what&#8217;s truly important in code.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a GIS (ew), VB.NET (double ew) and C# developer by trade, a general-purpose code monkey at heart, and always trying to learn new things. But I don&#8217;t want to learn on my own. So, I&#8217;m inviting everyone to join me as I try to teach myself what&#8217;s truly important in code.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwoti.com/blog/2009/11/welcome-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

