<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.atalasoft.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rick Minerich's Development Wonderland : functional</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx</link><description>Tags: functional</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>F# Discoveries This Week 05/02/2010</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx</link><pubDate>Sun, 02 May 2010 21:43:06 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:20609</guid><dc:creator>RickM</dc:creator><slash:comments>1</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/20609.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=20609</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=20609</wfw:comment><description>&lt;p&gt;Back this week with another huge batch of F# links.&amp;#160; While there’s way too much great stuff to mention, my favorite this week is by a mysterious blogger known only as James.&amp;#160; His heat transfer model is short, sweet and very well explained.&lt;/p&gt;  &lt;p&gt;If you’re around Boston tomorrow (Monday) be sure to check our F# panel for .NET Rocks!&amp;#160; With over 100 people already signed up, it’s sure to be a great time.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://vs2010roadtripboston.eventbrite.com/"&gt;The .NET Rocks! Visual Studio Road Trip – F# Edition in Boston (5/3/2010)&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;Carl and Richard are loading up the DotNetMobile (a 30 foot RV) and driving to your town again to show off the latest and greatest in Visual Studio 2010 and .NET 4.0! This stop will include an intro to F# and a special topic panel discussion on F# featuring New England F# User leaders.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.drdobbs.com/go-parallel/article/showArticle.jhtml?articleID=224400710"&gt;Rob Knies’ F#: Putting the 'Fun' into 'Functional' (On Dr. Dobbs)&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&amp;quot;In the F# team,&amp;quot; says Syme, a principal researcher at Microsoft Research Cambridge, &amp;quot;We say, 'F is for Fun.' F# enables users to write simple code to solve complex problems. Programming with F# really does make many programming tasks simpler, and our users have consistently reported that they've found using the language enjoyable.&amp;quot;&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://thecodedecanter.wordpress.com/2010/04/30/modelling-the-2d-heat-equation-in-f-using-100-lines-of-code/"&gt;James’s Modelling heat transfer in F# using 100 lines of code&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;In this post I’m going to show how we can model the heat equation succinctly in F#. I’m going to consider the two-dimensional case and approximate the solution at discrete spatial mesh points and at discrete time periods.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://lorgonblog.spaces.live.com/Blog/cns!701679AD17B6D310!1910.entry"&gt;Brian McNamara’s Game programming in F# (with Silverlight and WPF)&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;I wanted to learn more about Silverlight, WPF, and Xaml (in the context of F#, of course), so I wrote a fun little game you can play in your browser (or on your desktop).&amp;#160; It’s a knock-off of a dozen other similar games, as you can probably tell from this screenshot&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://blog.martindoms.com/2010/04/28/implementing-the-mandelbrot-set-in-f/"&gt;Martin Doms’s Implementing the Mandelbrot set in F#&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;One of my favourite things to do when learning a new language (or graphics package for that matter) is to write an implementation of a Mandelbrot set viewer. So here’s my F# version, annotated to help out anyone who is trying to get to know this language.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://blogs.msdn.com/mulambda/archive/2010/05/01/value-restriction-in-f.aspx"&gt;Dmitry Lomov’s Finer Points of F# Value Restriction&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Type inference algorithms are a fascinating topic – there is an interesting and beautiful theory behind them. Today we will consider one interesting aspect of type inference in F# - it might give you a glimpse of what kind of challenges coming up with a good algorithm in this space presents, and hopefully explain away a stumbling block that F# developers occasionally encounter. &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://bitbucket.org/riles01/frank/wiki/Home"&gt;Frank is a functional reactive request/response engine for .NET applications (written in F#)&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Frank is inspired by the Ruby dynamic duo of Rack and Sinatra and aims to provide the simplicity of those frameworks but utilizing the powerful functional reactive paradigm for asynchronous processing.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://stevegilham.blogspot.com/2010/04/launching-f-web-application-inside.html"&gt;Steve Gilham’s Launching an F# web application inside VS2010 as if it were C#&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;This is a follow-up to my comments on VS launcher for F# web apps, where I can put an example of the changed markup to the F# class library project to make it act like a web project and launch a browser with your Default.aspx page when you hit F5.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.trelford.com/blog/post/UML-Sequence-Diagram-F-Script.aspx"&gt;Phillip Trelford’s UML Sequence Diagram: F# Script&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;Yesterday I fancied moving some hand drawn diagrams to mouse drawn form; but instead found myself battling against a somewhat stubborn and forgetful modelling tool. It left me wondering if there might be an easier way to do this; perhaps by separating the concern of model description from layout.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://bloggemdano.blogspot.com/2010/04/distributed-hash-table-dht-in-f.html"&gt;Daniel Mohl’s A Distributed Hash Table (DHT) in F#: Recursion and Pattern Matching&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The simplest implementation defined in the Chord Protocol requires that each node only know about its successor node.&amp;#160; The circle of nodes, joined by each successor node association, makes up the node cluster. In order for a node to become part of the node cluster, it must execute a join request to any arbitrary node in the cluster.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://bloggemdano.blogspot.com/2010/04/interacting-with-rabbitmq-via-f-and.html"&gt;Daniel Mohl’s Interacting with RabbitMQ via F# and Symbiote&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;Last week, I showed how easy it is to talk to CouchDB with F# and Symbiote.&amp;#160; In this post, I'll show how you can start interacting with RabbitMQ by adding an additional dozen or so lines of code.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.navision-blog.de/2010/04/24/solving-kata-yahtzee-with-fsharp-and-naturalspec/"&gt;Steffen Forkmann’s Solving KataYahtzee with F# and NaturalSpec&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Today I’m starting a new blog post series about solving code katas in F# and with the help of my NaturalSpec project. A code kata is a programming exercise which helps to improve your skills through practice and repetition.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://strangelights.com/blog/archive/2010/04/18/1659.aspx"&gt;Robert Pickering’s Strings and F# Immutable Lists&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The aim of the article is to show that this is not the case, or at least it’s not as black and white as you may think. Specifically we’re going to compare how.NET strings differ considerable in performance characteristics to F#’s immutable lists. &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://vimeo.com/skaggles/videos/sort:date"&gt;Andre Burdette’s F# Screencast Series&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;This is the first of future screencasts that I am doing regarding F# programming. In this screencast I show how to use values and functions in the F# language. Enjoy! &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://techneilogy.blogspot.com/2010/04/spell-binding-tale-of-three-recursions.html"&gt;Neil Carrier’s A Spell-Binding Tale of Three Recursions&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;Tail recursive functions often involve accumulators, continuations, and other values which are not really of concern to the ultimate users of those functions. These can often be curried away or otherwise hidden from the ultimate user. This post looks at three obvious techniques for doing so (there are some more that are less obvious), the differences between the three techniques, etc.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://techneilogy.blogspot.com/2010/04/driving-range-pooled-allocator.html"&gt;Neil Carrier’s Driving Range Pooled Allocator&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Large numbers of small allocations can be brutal on a memory management system, especially in terms of CPU time (and in terms of fragmentation on non-GC systems). This post presents an F# implementation of a pooling algorithm I’ve used for many years, and in various languages from C onwards, to solve this problem.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Julien Ortin’s Technical analysis indicators in F# – &lt;a href="http://lepensemoi.free.fr/index.php/2010/04/28/technical-analysis-indicators-in-f-misc"&gt;Misc&lt;/a&gt; and &lt;a href="http://lepensemoi.free.fr/index.php/2010/04/28/technical-analysis-indicators-in-f-volatility"&gt;Volatility&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;This is part of a series on technical analysis indicators in F#, based on the multi-language TA-Lib.&amp;#160; Quick disclaimer: some of these indicators are not verified.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://v2matveev.blogspot.com/2010/04/nature-of-value-restriction.html"&gt;Vladimir Matveev’s Nature of value restriction&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;Value restriction is an error that firstly makes a direct hit in the brain of non-prepared developer. It has no straight analogues in the majority of mainstream languages and thus very confusing.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://v2matveev.blogspot.com/2010/04/mailboxprocessors-practical-application.html"&gt;Vladimir Matveev’s MailboxProcessors: Practical Application&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;&lt;em&gt;Last time we have examined the API of MailboxProcessors. Now it is time to see, how this concept can be applied to solve real-world problems.&lt;/em&gt;&lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/"&gt;Doug Finke’s How to add an F# type to a PowerShell session&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;The PowerShell Add-Type cmdlet lets you define a .NET Framework class in your Windows PowerShell session. It supports the following languages CSharp, CSharpVersion3, VisualBasic, JScript. It does not support FSharp directly.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Mark Pearl’s F# Objects &lt;a href="http://geekswithblogs.net/MarkPearl/archive/2010/04/29/f-objects-ndash-integrating-with-the-other-.net-languages-ndash.aspx"&gt;Part 1&lt;/a&gt;, &lt;a href="http://geekswithblogs.net/MarkPearl/archive/2010/04/29/f-objects-ndash-integration-with-the-other-.net-languages-ndash.aspx"&gt;Part 2&lt;/a&gt; and &lt;a href="http://geekswithblogs.net/MarkPearl/archive/2010/05/01/f-objects-ndash-part-3-ndash-itrsquos-time-to-overloadhellip.aspx"&gt;Part 3&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;In the next few blog posts I am going to explore objects in F#. Up to now, my dabbling in F# has really been a few liners and while I haven’t reached the point where F# is my language of preference – I am already seeing the benefits of the language when solving certain types of programming problems. &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Mark Pearl’s International Radio Operators Alphabet in F# and Silverlight &lt;a href="http://geekswithblogs.net/MarkPearl/archive/2010/04/22/international-radio-operators-alphabet-in-f-amp-silverlight-ndash-part.aspx"&gt;Part 1&lt;/a&gt; and &lt;a href="http://geekswithblogs.net/MarkPearl/archive/2010/04/22/international-radio-operators-alphabet-in-f-amp-silverlight-ndash-part-again.aspx"&gt;Part 2&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;My approach was really simple. I would need a function that would convert a single character to a string – i.e. ‘A’ –&amp;gt; “Alpha” and then I would need a function that would take a string of characters, convert them into a sequence of characters, and then apply my converter to return a sequence of words… make sense?&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://mikehadlow.blogspot.com/2010/04/currying-vs-partial-function.html"&gt;Mike Hadlow’s Currying vs Partial Function Application&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;em&gt;There’s a lot of confusion over these two terms. By myself included. But I’m pretty happy now that I understand the difference and wanted to share my newfound knowledge with you, dear reader.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.bjoernrochel.de/2010/04/29/kata-fizzbuzz-in-f/"&gt;Bjorn Rochel’s Kata FizzBuzz in F#&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Last F# book club meeting in Munich was awesome (as usual). 2 weeks ago we decided to do a Code Kata on each subsequent meeting. This week was our first, with Kata FizzBuzz.&amp;#160; This is what we came up with.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://ednortonengineeringsociety.blogspot.com/2010/04/your-language-aint-worth-pair-o-dimes.html"&gt;Jim Lehmer’s Your language ain’t worth a pair o’ dimes&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;That's not to say the Real World Functional Programming book is a bad book. It has been an interesting read so far, for sure. I am just going to stop reading the C# parts, thereby allowing the new concepts and new language I am learning to be &amp;quot;pure&amp;quot; in my mind, which should actually help speed up my learning process. And my suggestion to you is if you pick up the book, do the same thing, too. Dump your baggage, start fresh!&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://richardminerich.com/2010/04/the-ted-neward-f-folding-challenge/"&gt;Rick Minerich’s The Ted Neward F# Folding Challenge&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Take a list of numbers and compress it in a particular simple way but without any mutable state.&amp;#160; What makes this problem interesting is that a tech interviewer mentioned that that he hadn’t seen a functional solution to this problem.&amp;#160; I also wanted to share this because I think it’s a great example of how to convert an imperative loop into a functional fold.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;;subject=F%23+Discoveries+This+Week+05%2f02%2f2010" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;;title=F%23+Discoveries+This+Week+05%2f02%2f2010" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;title=F%23+Discoveries+This+Week+05%2f02%2f2010" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;;title=F%23+Discoveries+This+Week+05%2f02%2f2010" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx&amp;amp;;title=F%23+Discoveries+This+Week+05%2f02%2f2010&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2010/05/02/f-discoveries-this-week-05-02-2010.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=20609" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/allocation/default.aspx">allocation</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/roundup/default.aspx">roundup</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/recursion/default.aspx">recursion</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/silverlight/default.aspx">silverlight</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Fold/default.aspx">Fold</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/DHT/default.aspx">DHT</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/value+restriction/default.aspx">value restriction</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/uml/default.aspx">uml</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/physics/default.aspx">physics</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/mandelbrot/default.aspx">mandelbrot</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Symbiote/default.aspx">Symbiote</category></item><item><title>Steepest Ascent Hill Climbing in C# and F#</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx</link><pubDate>Mon, 28 Dec 2009 19:21:09 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:19946</guid><dc:creator>RickM</dc:creator><slash:comments>7</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/19946.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=19946</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=19946</wfw:comment><description>&lt;p&gt;Recently I’ve been working with some local search techniques and wanted to share my Steepest Ascent Hill Climbing solution.&lt;/p&gt;  &lt;p&gt;The general idea of Steepest Ascent Hill Climbing is that in each iteration of the hill climbing process you apply a set of transforms to your input data and select the best result via a fitness function.&amp;#160; This result, or the transform which created it, is then the input for your next iteration.&amp;#160; The process stops when no transform in an iteration scored higher than the previous generation’s winner.&lt;/p&gt;  &lt;p&gt;In this way each iterative step brings you closer to a local maxima of your fitness function’s graph.&amp;#160; This is where the term “Hill Climbing” comes from.&amp;#160; It is considered a relatively simple AI technique but is also is broadly applicable, quite easy to reason about and can be tweaked for many different corner cases.&lt;/p&gt;  &lt;p&gt;For this particular example we will be assuming composable transforms.&amp;#160; For each iteration of our hill climbing we will apply our standard transform set to the winning transform of the last round and so produce a new set of transforms.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:61b69c2f-5c74-48d7-b088-840692159eb9" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt; T &lt;span style="color:#2b91af;"&gt;TransformComposer&lt;/span&gt;&amp;lt;T&amp;gt;(T lastT, T thisT);&lt;br&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt; S &lt;span style="color:#2b91af;"&gt;TransformApplier&lt;/span&gt;&amp;lt;S, T&amp;gt;(S set, T transform);&lt;br&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;FitnessFunction&lt;/span&gt;&amp;lt;S&amp;gt;(S set);&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; HillClimberResult(&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; score, T transform, S set)&lt;br&gt;     {&lt;br&gt;         Score = score;&lt;br&gt;         Transform = transform;&lt;br&gt;         Set = set;&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; Score { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; T Transform { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; S Set { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt; }&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HillClimber&lt;/span&gt;&amp;lt;S, T&amp;gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; HillClimber(&lt;br&gt;       &lt;span style="color:#2b91af;"&gt;TransformComposer&lt;/span&gt;&amp;lt;T&amp;gt; composer,&lt;br&gt;       &lt;span style="color:#2b91af;"&gt;TransformApplier&lt;/span&gt;&amp;lt;S, T&amp;gt; applier,&lt;br&gt;       &lt;span style="color:#2b91af;"&gt;FitnessFunction&lt;/span&gt;&amp;lt;S&amp;gt; fitness)&lt;br&gt;     {&lt;br&gt;         TransformComposer = composer;&lt;br&gt;         TransformApplier = applier;&lt;br&gt;         FitnessFunction = fitness;&lt;br&gt;         Transforms = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;T&amp;gt;();&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;T&amp;gt; Transforms { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TransformComposer&lt;/span&gt;&amp;lt;T&amp;gt; TransformComposer { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TransformApplier&lt;/span&gt;&amp;lt;S, T&amp;gt; TransformApplier { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;FitnessFunction&lt;/span&gt;&amp;lt;S&amp;gt; FitnessFunction { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt; FindMaxima(S inputSet, T initialTransform)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (inputSet == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;inputSet&amp;quot;&lt;/span&gt;);&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (initialTransform == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;initialTransform&amp;quot;&lt;/span&gt;);&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (Transforms.Count == 0)&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;No transforms were set.&amp;quot;&lt;/span&gt;);&lt;br&gt; &lt;br&gt;         &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt; best;&lt;br&gt;         &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt; iterBest = ApplyTransformAndScore(inputSet, initialTransform);&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff;"&gt;do&lt;/span&gt;&lt;br&gt;         {&lt;br&gt;             best = iterBest;&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (T transform &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Transforms)&lt;br&gt;             {&lt;br&gt;                 &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; nextTransform = TransformComposer(best.Transform, transform);&lt;br&gt;                 &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; result = ApplyTransformAndScore(inputSet, nextTransform);&lt;br&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (iterBest.Score &amp;lt; result.Score)&lt;br&gt;                     iterBest = result;&lt;br&gt;             }&lt;br&gt;         } &lt;span style="color:#0000ff;"&gt;while&lt;/span&gt; (iterBest.Score &amp;gt; best.Score);&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; best;&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt; ApplyTransformAndScore(S inputSet, T transform)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; transformedSet = TransformApplier(inputSet, transform);&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; score = FitnessFunction(transformedSet);&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;HillClimberResult&lt;/span&gt;&amp;lt;S, T&amp;gt;(score, transform, transformedSet);&lt;br&gt;     }&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I like the way this worked out in C# quite a lot.&amp;#160; However, take a moment to compare it to a F# version I quickly whipped up:&amp;#160; &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3992d10c-89ce-4bd8-b893-fbd120334f26" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; HillClimber(composer, applier, fitness, transforms) =&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; x.FindMaxima initialSet initialTransform =&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; maxOfScores one two = &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; fst one &amp;gt; fst two &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; one &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; two&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; findBestTransform set lastTransform =&lt;br&gt;           transforms&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; composer lastTransform transform)&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; applier set transform, transform)&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transformedSet, transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; (fitness transformedSet), transform)&lt;br&gt;             |&amp;gt; List.reduce maxOfScores&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;rec&lt;/span&gt; climb set lastScore lastTransform =&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; (thisScore, thisTransform) = findBestTransform set lastTransform&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; thisScore &amp;lt;= lastScore &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; (lastScore, lastTransform)&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; climb set thisScore thisTransform&lt;br&gt;         climb initialSet (fitness initialSet) initialTransform&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;It’s quite shocking how much less code is necessary.&amp;#160;&amp;#160; However, there is a small problem with this example.&amp;#160; As we are not using HillClimber from inside of its own library, all of its function inputs resolve to System.Object. The solution is to simply do a bit of annotating to ensure that compile time types are as generic as possible.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b4198e46-bee0-4fc4-8907-1b4ecf7ee54a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; TransformComposer&amp;lt;&amp;#39;t&amp;gt; = &amp;#39;t &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; &amp;#39;t &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; &amp;#39;t&lt;br&gt; &lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; TransformApplier&amp;lt;&amp;#39;s,&amp;#39;t&amp;gt; = &amp;#39;s &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; &amp;#39;t &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; &amp;#39;s&lt;br&gt; &lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; FitnessFunction&amp;lt;&amp;#39;s&amp;gt; = &amp;#39;s &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; float&lt;br&gt;   &lt;br&gt; &lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; HillClimber&amp;lt;&amp;#39;s,&amp;#39;t&amp;gt;(composer: TransformComposer&amp;lt;&amp;#39;t&amp;gt;, applier: TransformApplier&amp;lt;&amp;#39;s,&amp;#39;t&amp;gt;, fitness: FitnessFunction&amp;lt;&amp;#39;s&amp;gt;, transforms: list&amp;lt;&amp;#39;t&amp;gt;) =&lt;br&gt;     &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; x.FindMaxima initialSet initialTransform =&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; maxOfScores one two = &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; fst one &amp;gt; fst two &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; one &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; two&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; findBestTransform set lastTransform =&lt;br&gt;           transforms&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; composer lastTransform transform)&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; applier set transform, transform)&lt;br&gt;             |&amp;gt; List.map (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt;(transformedSet, transform) &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; (fitness transformedSet), transform)&lt;br&gt;             |&amp;gt; List.reduce maxOfScores&lt;br&gt;         &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;rec&lt;/span&gt; climb set lastScore lastTransform =&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; (thisScore, thisTransform) = findBestTransform set lastTransform&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; thisScore &amp;lt;= lastScore &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; (lastScore, lastTransform)&lt;br&gt;             &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt; climb set thisScore thisTransform&lt;br&gt;         climb initialSet (fitness initialSet) initialTransform&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Of course,&amp;#160; it would be great if the F# type system would reduce to generics instead of System.Object in this case.&amp;#160; I would think the ideal would be to always reduce to the most generic type possible.&amp;#160; I’ll have to give it a try tonight with the latest VS2010 beta and see if there is any improvement.&lt;/p&gt;  &lt;p&gt;Continuing on, let’s give this a go with something simple.&amp;#160; We know that the maximum value of |A| – A^2 is 0.5, –0.5.&amp;#160; Can we climb our way to one of these values? &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:909176b7-092c-4f6e-a15e-76b4846f1793" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;#load&lt;/span&gt; &lt;span style="color:#800000;"&gt;&amp;quot;HillClimber.fs&amp;quot;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff;"&gt;open&lt;/span&gt; HillClimber&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; composer last next = &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; (last x) + (next x)&lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; applier set transform = transform set;&lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; fitness x = abs( x ) - (x ** 2.0)&lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; transforms = [&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x + 1.0; &lt;br&gt;                   &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x - 1.0;&lt;br&gt;                   &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x + 0.1;&lt;br&gt;                   &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x - 0.1;&lt;br&gt;                   &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x + 0.01;&lt;br&gt;                   &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x - 0.01]&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; climber = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; HillClimber&amp;lt;float,float&lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt;float&amp;gt;(composer, applier, fitness, transforms)&lt;br&gt; &lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; initialValue = 0.0&lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; (score, transform) = climber.FindMaxima initialValue (&lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; x &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; x)&lt;br&gt; &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; result = transform initialValue&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;…Highlight, Alt-Enter…&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9958300b-3635-4e41-a08d-5815b603e9a8" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;val composer : (&amp;#39;a -&amp;gt; float) -&amp;gt; (&amp;#39;a -&amp;gt; float) -&amp;gt; &amp;#39;a -&amp;gt; float&lt;br&gt; val applier : &amp;#39;a -&amp;gt; (&amp;#39;a -&amp;gt; &amp;#39;b) -&amp;gt; &amp;#39;b&lt;br&gt; val fitness : float -&amp;gt; float&lt;br&gt; val transforms : (float -&amp;gt; float) list =&lt;br&gt;   [&amp;lt;fun:transforms@10&amp;gt;; &amp;lt;fun:transforms@11-1&amp;gt;; &amp;lt;fun:transforms@12-2&amp;gt;;&lt;br&gt;    &amp;lt;fun:transforms@13-3&amp;gt;; &amp;lt;fun:transforms@14-4&amp;gt;; &amp;lt;fun:transforms@15-5&amp;gt;]&lt;br&gt; val climber : HillClimber.HillClimber&amp;lt;float,(float -&amp;gt; float)&amp;gt;&lt;br&gt; val initialValue : float = 0.0&lt;br&gt; val transform : (float -&amp;gt; float)&lt;br&gt; val score : float = 0.25&lt;br&gt; val result : float = -0.5&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Looks good!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Well, it looks like that took a bit longer than I had anticipated.&amp;#160; I’ll be back with my weekly update tomorrow.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;;subject=Steepest+Ascent+Hill+Climbing+in+C%23+and+F%23" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;;title=Steepest+Ascent+Hill+Climbing+in+C%23+and+F%23" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;title=Steepest+Ascent+Hill+Climbing+in+C%23+and+F%23" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;;title=Steepest+Ascent+Hill+Climbing+in+C%23+and+F%23" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx&amp;amp;;title=Steepest+Ascent+Hill+Climbing+in+C%23+and+F%23&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/12/28/steepest-ascent-hill-climbing-in-c-and-f.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=19946" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/algorithms/default.aspx">algorithms</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional+programming/default.aspx">functional programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/function+composition/default.aspx">function composition</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional+architecture/default.aspx">functional architecture</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Hill+Climbing/default.aspx">Hill Climbing</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/higher-order+functions/default.aspx">higher-order functions</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/AI/default.aspx">AI</category></item><item><title>F# - Designing Functional Interfaces for Pipelining</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx</link><pubDate>Thu, 12 Nov 2009 18:58:09 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:19708</guid><dc:creator>RickM</dc:creator><slash:comments>5</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/19708.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=19708</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=19708</wfw:comment><description>&lt;p&gt;So you have an Object Oriented library but yet want to be able to use F#’s functional pipelining feature to design expressive data processing workflows.&amp;#160; How do you go about it?&lt;/p&gt;  &lt;p&gt;First, lets set a goal.&amp;#160; Some low hanging fruit so to speak.&amp;#160; Let’s pretend we have a set of images we want to load, resize, intensify and save as Png files for later use in an online image gallery. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Image Processing In C#&lt;/h3&gt;  &lt;p&gt;For reference, this would look something like the following using our &lt;a href="http://www.atalasoft.com/products/dotimage/"&gt;DotImage toolkit&lt;/a&gt; in C#:&lt;/p&gt;  &lt;div style="font-family:inconsolata;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; ProcessImage(&lt;span style="color:blue;"&gt;string&lt;/span&gt; fromfile, &lt;span style="color:blue;"&gt;string&lt;/span&gt; tofile)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#2b91af;"&gt;ImageCommand&lt;/span&gt;[] commands = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ImageCommand&lt;/span&gt;[] {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ChangePixelFormatCommand&lt;/span&gt;( &lt;span style="color:#2b91af;"&gt;PixelFormat&lt;/span&gt;.Pixel8bppIndexed ),&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ResampleCommand&lt;/span&gt;( &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Size&lt;/span&gt;( 800, 600) ),&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IntensifyCommand&lt;/span&gt;( 50.0 )&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#2b91af;"&gt;AtalaImage&lt;/span&gt; currentImage =&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;AtalaImage&lt;/span&gt;(fromfile);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue;"&gt;var&lt;/span&gt; command &lt;span style="color:blue;"&gt;in&lt;/span&gt; commands)&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; currentImage = command.Apply(currentImage).Image;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; currentImage.Save(tofile, &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PngEncoder&lt;/span&gt;(), &lt;span style="color:blue;"&gt;null&lt;/span&gt;);&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;It’s a testament to the skill of our &lt;a href="http://www.atalasoft.com/cs/blogs/stevehawley/default.aspx"&gt;Senior Architect&lt;/a&gt; that this task is as simple as it is in C#.&amp;#160; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; our image representation is IDisposable and for optimal performance should immediately be disposed when done being used.&amp;#160; I’ll be covering how to leverage F#’s type system to handle this in a later post.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Now, in F#&lt;/h3&gt;  &lt;p&gt;In comparison, this is how I envision this same process using F#’s functional pipelining style:&lt;/p&gt;  &lt;div style="font-family:inconsolata;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;let&lt;/span&gt; processImage infile outfile = &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; Image.fromFile infile&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.changePixelFormat Image.PixelFormat.Pixel8bppIndexed&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.resample 800 600&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.intensify 50.0&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.toPngFile outfile&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;These pipelined functions are so easy on the eyes.&amp;#160; It’s immediately obvious what’s going on here.&amp;#160; Unfortunately, it can be rather difficult to use pipelining with non function constructs.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Wrapping an Object Oriented Library for Pipelining&lt;/h3&gt;  &lt;p&gt;To bring this seamless integration with F#, we must first wrap these Object Oriented classes so that they can be used in a functional way.&amp;#160; This is a rather simple task:&lt;/p&gt;  &lt;div style="font-family:inconsolata;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; Atalasoft.FSharp&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; System.Drawing&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; Atalasoft.Imaging&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; Atalasoft.Imaging.Codec&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; Atalasoft.Imaging.ImageProcessing&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; Atalasoft.Imaging.ImageProcessing.Filters&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;module&lt;/span&gt; Image = &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;type&lt;/span&gt; image = Atalasoft.Imaging.AtalaImage&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;type&lt;/span&gt; PixelFormat = Atalasoft.Imaging.PixelFormat&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; fromFile (filename: string) = &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; image( filename )&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; toPngFile (filename: string) (img: image) =&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; img.Save( filename, &lt;span style="color:blue;"&gt;new&lt;/span&gt; PngEncoder(), &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&amp;#160; |&amp;gt; ignore&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; resample (width: int) (height: int) (img: image) =&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; newSize = &lt;span style="color:blue;"&gt;new&lt;/span&gt; Size( width, height ) &lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; cmd = &lt;span style="color:blue;"&gt;new&lt;/span&gt; ResampleCommand( newSize ) &lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Apply(img).Image&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; intensify (magnitude: double) (img: image) = &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; cmd = &lt;span style="color:blue;"&gt;new&lt;/span&gt; IntensifyCommand( magnitude ) &lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Apply(img).Image&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; changePixelFormat (pf: PixelFormat) (img: image) =&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;let&lt;/span&gt; changer = &lt;span style="color:blue;"&gt;new&lt;/span&gt; AtalaPixelFormatChanger() &lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; changer.ChangePixelFormat(img, pf, &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So, in this way, we can define modules which will hide our object oriented interfaces.&amp;#160; However, let’s take a deeper look.&amp;#160; There are a some important things to keep in mind when designing functions for pipelining.&amp;#160; &lt;/p&gt;  &lt;p&gt;First, observe that the &lt;a href="http://msdn.microsoft.com/en-us/library/dd233221%28VS.100%29.aspx"&gt;module&lt;/a&gt; definition encapsulates all of our pipelining functions and mandates how they will be accessed later.&amp;#160; It is good design practice to define all pipelining functions for the same type within one module.&amp;#160; This module should have the same name as the type but with the first letter capitalized.&lt;/p&gt;  &lt;p&gt;Second, notice that we use &lt;a href="http://msdn.microsoft.com/en-us/library/dd233246%28VS.100%29.aspx"&gt;type abbreviations&lt;/a&gt; to create local versions of the AtalaImage and PixelFormat types.&amp;#160; This makes our library code easier to read and allows us to use the F# lowercase type naming style.&amp;#160;&amp;#160; Even more importantly, by defining all exposed types in this way the consumer of this module will not need to open any namespaces from the assemblies we are wrapping.&lt;/p&gt;  &lt;p&gt;Third, see how image is the last parameter to each function?&amp;#160; To be able to pipeline into a function its final parameter must be of the to-be-pipelined type. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is not strictly true.&amp;#160; If you wish to pipeline into a function and then return a function with that value curried in, it can have additional parameters which will be filled in later. However, that’s a topic best left for another time.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Finally, note that the return type of each of the intermediate image processing functions is also image.&amp;#160; This ensures that the output can be pipelined directly into the next function.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Our F# Wrapper in Action&lt;/h3&gt;  &lt;p&gt;Let’s highlight the contents of this fsx file, hit alt-enter, and give it a whirl in the F# Interactive Window:&lt;/p&gt;  &lt;div style="font-family:inconsolata;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;#r&lt;/span&gt; &lt;span style="color:maroon;"&gt;&amp;quot;Atalasoft.dotImage&amp;quot;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;#r&lt;/span&gt; &lt;span style="color:maroon;"&gt;&amp;quot;Atalasoft.dotImage.Lib&amp;quot;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;#r&lt;/span&gt; &lt;span style="color:maroon;"&gt;&amp;quot;Atalasoft.Shared&amp;quot;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;#load&lt;/span&gt; &lt;span style="color:maroon;"&gt;&amp;quot;Image.fs&amp;quot;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;open&lt;/span&gt; Atalasoft.FSharp&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;let&lt;/span&gt; processImage infile outfile = &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; Image.fromFile infile&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.changePixelFormat Image.PixelFormat.Pixel32bppBgr&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.resample 400 300&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.intensify 70.0&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; |&amp;gt; Image.toPngFile outfile&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Finally, in F# Interactive we can simply type:&lt;/p&gt;  &lt;p&gt;&amp;#160; &amp;gt; processImage @&amp;quot;C:\temp\Water lilies.jpg&amp;quot; @&amp;quot;C:\temp\Water lilies.png&amp;quot;;;    &lt;br /&gt;&amp;#160; val it : unit = ()&lt;/p&gt;  &lt;p&gt;and we have our processed image: &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/Waterlilies_7444764C.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:block;float:none;margin-left:auto;border-top:0px;margin-right:auto;border-right:0px;" title="Water lilies" border="0" alt="Water lilies" src="http://www.atalasoft.com/cs/blogs/rickm/Waterlilies_thumb_381DCC06.png" width="404" height="304" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;Of course, this implementation leaves much to be desired.&amp;#160; It hides the vast majority of the available functionality in our underlying library.&amp;#160; Taken to it’s natural end it leaves us with the unfortunate task of wrapping our entire library one command at a time, which is hardly an appealing prospect.&lt;/p&gt;  &lt;p&gt;What if you wish to leverage existing objects without wrapping each individually?&amp;#160; Well, we will explore that next time.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;;subject=F%23+-+Designing+Functional+Interfaces+for+Pipelining" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;;title=F%23+-+Designing+Functional+Interfaces+for+Pipelining" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;title=F%23+-+Designing+Functional+Interfaces+for+Pipelining" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;;title=F%23+-+Designing+Functional+Interfaces+for+Pipelining" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx&amp;amp;;title=F%23+-+Designing+Functional+Interfaces+for+Pipelining&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/11/12/f-designing-functional-interfaces-for-pipelining.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=19708" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/IDisposable/default.aspx">IDisposable</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/image+processing/default.aspx">image processing</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/dotImage/default.aspx">dotImage</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional+architecture/default.aspx">functional architecture</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/pipelining/default.aspx">pipelining</category></item><item><title>Discoveries This Week 05/24/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx</link><pubDate>Mon, 25 May 2009 02:24:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:18545</guid><dc:creator>RickM</dc:creator><slash:comments>1</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/18545.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=18545</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=18545</wfw:comment><description>&lt;p&gt;An exciting week with the release of Visual Studio 2010 Beta 1 and F# 1.9.6.16.&amp;#160; This week we have John Backus’s classic FP manifesto,&amp;#160; Luke Hoban speaks on F# in VS2010 beta 1, Django for ASP.NET, and an article on breaking changes in the latest F# release.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;John Backus – &lt;a href="http://www.stanford.edu/class/cs242/readings/backus.pdf"&gt;Can Programming Be Liberated from the von Neumann Style?&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Functional programs deal with structured data, are often nonrepetitive and nonrecursive, are hierarchically constructed, do not name their arguments, and do not require the complex machinery of procedure declarations to become generally applicable.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The functional programming manifesto.&amp;#160; Well worth the time to read for anyone serious about functional programming.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Luke Hoban on Channel9 – &lt;a href="http://channel9.msdn.com/posts/Charles/Luke-Hoban-Latest-version-of-F-Released-Whats-the-story-Whats-next/"&gt;What’s the Story? What’s Next?&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Here, F# Program Manager Luke Hoban talks with me about F#, generally and what people have been doing with it, the current state of the technology, what F# enables&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The most interesting thing I gleamed from the talk is that F# Powerpack will not be included with Visual Studio 2010.&amp;#160; Luke hopes that this will allow faster development cycles.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Alex Pedenko’s Project, &lt;a href="http://www.ndjango.org/index.php?title=NDjango_Home"&gt;NDjango - Django templates in .NET&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The current version is being released as a beta. It has &lt;/em&gt;&lt;a href="http://www.ndjango.org/index.php?title=Supported_tags"&gt;&lt;em&gt;full&lt;/em&gt;&lt;/a&gt;&lt;em&gt; django tag support, and &lt;/em&gt;&lt;a href="http://www.ndjango.org/index.php?title=Supported_Filters"&gt;&lt;em&gt;most&lt;/em&gt;&lt;/a&gt;&lt;em&gt; of the default filters. &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I’ve heard many great things about Django from my web developer friends.&amp;#160; I’m sure many will be happy to see ASP.NET support.&amp;#160; It can be used stand-alone or in conjunction with the &lt;a href="http://www.bistroframework.org/index.php?title=Bistro_Framework_Home"&gt;Bistro Framework&lt;/a&gt;.&amp;#160; Best of all, NDjango is built on F# and Bistro has full F# support. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Abel Avram on InfoQ - &lt;a href="http://www.infoq.com/news/2009/05/FSharp-Breaking-Changes"&gt;Latest F# Breaks Binary Compatibility&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Microsoft has included F# in &lt;/em&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=75cbcbcd-b0e8-40ea-adae-85714e8984e3"&gt;&lt;em&gt;VS 2010 Beta 1&lt;/em&gt;&lt;/a&gt;&lt;em&gt; and has released a corresponding &lt;/em&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7bb32f32-9fac-4f34-ad56-b0bda130cf00&amp;amp;displaylang=en"&gt;&lt;em&gt;CTP update for VS 2008&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. The latest binaries, version 1.9.6.16, are not compatible with previous ones, v. 1.9.6.2, meaning all previous code needs to be recompiled.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Also important to note, the #light syntax is now on by default.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I understand it is exceedingly painful to sign up for an account to leave a comment.&amp;#160; That given, I am still trying to figure out a solution to my spam problem.&amp;#160; For now, if you would like to comment and don’t wish to set up an account, please &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/contact.aspx"&gt;email me&lt;/a&gt; your comment and I will manually post it.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;;subject=Discoveries+This+Week+05%2f24%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;;title=Discoveries+This+Week+05%2f24%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;title=Discoveries+This+Week+05%2f24%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;;title=Discoveries+This+Week+05%2f24%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx&amp;amp;;title=Discoveries+This+Week+05%2f24%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/05/24/discoveries-this-week-05-24-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=18545" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional+programming/default.aspx">functional programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/django/default.aspx">django</category></item><item><title>Discoveries This Week 03/20/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx</link><pubDate>Sun, 22 Mar 2009 20:09:43 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17764</guid><dc:creator>RickM</dc:creator><slash:comments>6</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17764.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17764</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17764</wfw:comment><description>&lt;p&gt;This week there seems to be quite a bit of video and audio content to share.&amp;#160; We have a dramatic depiction of the benefits of Units of Measure, Luke Hoban on F#’s feature, Ted Neward talks about F# under the hood and finally a discussion on operator type inference. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Video Blog – &lt;a&gt;Could F# have saved the Mars Climate Orbiter?&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;A fantastic example of how static dimensional analysis of scalar values could prevent an entire class of bugs.&amp;#160;&amp;#160; In the past, &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/03/avoiding-ambiguous-types-in-c.aspx"&gt;I’ve talked about what a huge fan I am of the Units of Measure package for F#&lt;/a&gt;.&amp;#160; I’m glad that others also see how revolutionary units of measure are.&amp;#160; &lt;/p&gt;  &lt;p&gt;Would you want to work in a building or live in a house in which the engineers who built it did not keep track of units?&amp;#160; I don’t think anyone would answer yes.&amp;#160; Similarly, we should not entrust our lives or livelihoods to software in which these very same things are not kept track of.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Podcast – &lt;a href="http://www.se-radio.net/podcast/2009-03/episode-129-f-luke-hoban"&gt;SER Episode 129 - F# with Luke Hoban&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In this podcast Luke Hoban, the F# program manager, discusses about various aspects of F#.&amp;#160; &lt;/p&gt;  &lt;p&gt;Some highlights:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Mutability comes along with .NET Framework support.&lt;/li&gt;    &lt;li&gt;Statically Typed means strong guarantees and so robust systems.&lt;/li&gt;    &lt;li&gt;FP design in the small for concurrency&lt;/li&gt;    &lt;li&gt;OO design in the large for scalability&lt;/li&gt;    &lt;li&gt;Explorative programming via interactive window&lt;/li&gt;    &lt;li&gt;Influenced heavily by Haskell&lt;/li&gt;    &lt;li&gt;FP as a technique, not a class of languages&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Video Blog – &lt;a href="http://www.bestechvideos.com/2009/03/18/dnrtv-show-136-ted-neward-introduces-f"&gt;dnrTV Show #136: Ted Neward Introduces F#&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.tedneward.com/"&gt;Ted Neward&lt;/a&gt; gives an in-depth presentation on both how F# works under the hood and the general benefits that stem from FP in general.&amp;#160; The examples used are simple but Ted covers them in a very exhaustive way.&lt;/p&gt;  &lt;p&gt;Beyond the language and concepts therein, he also has a number of insightful comments about teaching people to use F#.&amp;#160; In particular the idea that F# syntax will be easy to teach but functional programming technique will take years really struck home with me.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog – Kalani Thielen’s &lt;a href="http://blog.lab49.com/archives/2895"&gt;The F# overload-o-phone&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In his post Kalani points out a small but significant logical inconsistency in F#’s type inference system.&amp;#160; The issue seems to stem from the way type inference is handled for basic operators.&amp;#160; Instead of working generically, they each have default types.&lt;/p&gt;  &lt;p&gt;From his post:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; (+);;     &lt;br /&gt;val it : (int -&amp;gt; int -&amp;gt; int)      &lt;br /&gt;&amp;gt; 3.2 + 5.4;;      &lt;br /&gt;val it : float = 8.6      &lt;br /&gt;&amp;gt; let twice x = x + x;;      &lt;br /&gt;&amp;gt; twice 9.4;;      &lt;br /&gt;stdin(2,5): error FS0001: This expression has type      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; float but is here used with type int.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;To get around this, he then goes on to build a function which takes an operator and both arguments.&amp;#160; However, this workaround is completely unnecessary.&amp;#160; You need only to annotate the function’s input and it works without issue.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt; let twice (x: double) = x + x     &lt;br /&gt;val twice : double –&amp;gt; double      &lt;br /&gt;&amp;gt; twice 9.4;;      &lt;br /&gt;val it : double = 18.8&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now, it’s important to note that this version of the twice function won’t accept an integer.&amp;#160; &lt;a href="http://cs.hubfs.net/forums/thread/5970.aspx"&gt;In fact, it was a conscious design decision to disallow function overloading in F#&lt;/a&gt;.&amp;#160; In both F# and C# all kinds of overloading must be qualified by type.&amp;#160; That is, type methods support argument overloading but free floating functions do not.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;;subject=Discoveries+This+Week+03%2f20%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;;title=Discoveries+This+Week+03%2f20%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;title=Discoveries+This+Week+03%2f20%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;;title=Discoveries+This+Week+03%2f20%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx&amp;amp;;title=Discoveries+This+Week+03%2f20%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/22/discoveries-this-week-03-20-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17764" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/oo/default.aspx">oo</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/optimization/default.aspx">optimization</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/microsoft+research/default.aspx">microsoft research</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fp/default.aspx">fp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/units+of+measure/default.aspx">units of measure</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/type+inference/default.aspx">type inference</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/types/default.aspx">types</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/units/default.aspx">units</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/overloading/default.aspx">overloading</category></item><item><title>What Would You Want From a F# User Group?</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx</link><pubDate>Thu, 12 Mar 2009 13:39:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17655</guid><dc:creator>RickM</dc:creator><slash:comments>4</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17655.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17655</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17655</wfw:comment><description>&lt;p&gt;&lt;a href="http://www.scrumalliance.org/profiles/2363-michael-de-la-maza"&gt;Michael de la Maza&lt;/a&gt;, &lt;a href="http://talbottc.spaces.live.com/"&gt;Talbott Crowell&lt;/a&gt; and I are all very excited about finally getting our F# User Group off the ground.&amp;#160; However, as F# groups are currently few and far between, we are very interested in finding out what attendees would want from such a group. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Where and When?&lt;/h3&gt;  &lt;p&gt;In terms of broad time frame, we are looking at having our first meeting in April.&amp;#160; We currently have a few options open in terms of which day of the month.&amp;#160; If you are interested in attending, head on over to our &lt;a href="http://www.doodle.com/v4hxr9fnzsz865pr"&gt;doodle poll&lt;/a&gt; and tell us which days would be best for you. &lt;/p&gt;  &lt;p&gt;The group will be held at the &lt;a href="http://blogs.msdn.com/cbowen/archive/2009/02/16/learn-about-the-new-england-research-development-nerd-center.aspx"&gt;new Microsoft NERD center in Cambridge&lt;/a&gt;, Massachusetts.&amp;#160; A big thanks to &lt;a href="http://blogs.msdn.com/cbowen/"&gt;Chris Bowen&lt;/a&gt; for helping us find such an exciting place to hold our meetings.&amp;#160; I know that I’m not the only one hoping that some of the &lt;a href="http://microsoftcambridge.com/People/tabid/56/Default.aspx"&gt;Microsoft research NERDs&lt;/a&gt; will have time to come down to our meetings.&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Online Content?&lt;/h3&gt;  &lt;p&gt;We are planning on recording each meeting and putting the videos up online.&amp;#160; We don’t have the hosting solution for this firmly pinned down yet,&amp;#160; however there are a large number of different options available.&amp;#160; Our criteria are support for video of at least two hours in length and high resolution.&amp;#160; Ideally, we would like to use a Microsoft-based solution.    &lt;br /&gt;&lt;/p&gt;  &lt;h3&gt;Types of Meetings?&lt;/h3&gt;  &lt;p&gt;While most .NET user groups seem to be primarily presentation based, they are often much more broadly scoped and targeted at an audience with deeper topical knowledge.&amp;#160; For these reasons we are considering a number of different formats for the group.&amp;#160; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;F# Boot Camp -&lt;/strong&gt; The focus of this type of session would be getting developers who were new to F# and/or FP started. This might include a small presentation, some group activity work and, finally, an open discussion forum. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Presentations&lt;/strong&gt; - We are working on bringing in F# experts to present on related topics.&amp;#160; This will be via both physical presence and remote conferencing. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Competitions&lt;/strong&gt; - I love competitive coding and I think that there’s no better way to get people excited about a topic.&amp;#160; These competitions would likely be web-based and open to all F# users. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Our goal is provide interesting content for both those new to F# as well as those with some experience.&amp;#160; As F# is a fairly new language, it’s reasonable to assume that news attendees will have a low level of previous exposure to the language.&amp;#160; Due to this, our current thinking is that it would generally be best to start with the basics and work our way up to more advanced topics over time.&amp;#160; &lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;;subject=What+Would+You+Want+From+a+F%23+User+Group%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;;title=What+Would+You+Want+From+a+F%23+User+Group%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;title=What+Would+You+Want+From+a+F%23+User+Group%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;;title=What+Would+You+Want+From+a+F%23+User+Group%3f" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx&amp;amp;;title=What+Would+You+Want+From+a+F%23+User+Group%3f&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/12/what-would-you-want-from-a-f-user-group.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17655" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fp/default.aspx">fp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/groups/default.aspx">groups</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsug/default.aspx">fsug</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/nerd/default.aspx">nerd</category></item><item><title>Let’s Wax Functional 03/06/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx</link><pubDate>Sat, 07 Mar 2009 23:09:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17631</guid><dc:creator>RickM</dc:creator><slash:comments>2</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17631.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17631</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17631</wfw:comment><description>&lt;p&gt;This week we have MapReduce, WebTools and yet another F# to C# language comparison.&amp;nbsp; I spent yesterday at a &lt;a href="http://www.scrumalliance.org/events/74-scrum-and-team-foundation-seminar"&gt;seminar led by Michael de la Maza&lt;/a&gt;.&amp;nbsp; He, &lt;a href="http://talbottc.spaces.live.com/"&gt;Talbot Crowell&lt;/a&gt; and I will soon be starting a F# user’s group in Boston, Massachusetts.&amp;nbsp; I’m interested in any comments you might have.&amp;nbsp; Please feel free to send me an email if you would like to discuss speaking at it or content you would like to see covered.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Blog - &lt;a href="http://weblogs.asp.net/podwysocki/archive/2009/03/03/exploring-mapreduce-with-f.aspx"&gt;Matthew Podwysocki’s Exploring MapReduce with F#&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Google’s &lt;a href="http://en.wikipedia.org/wiki/MapReduce"&gt;MapReduce&lt;/a&gt; software framework has revolutionized the way software engineers think about processing large data sets.&amp;nbsp; Since it’s introduction at least 15 variants have been developed.&amp;nbsp; Thorough as always, Matthew explores what MapReduce is, how it relates to functional programming and, finally, shows his own light-weight MapReduce implementation.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Software – Thomas Petricek’s &lt;a href="http://www.codeplex.com/fswebtools"&gt;FSharp.WebTools&lt;/a&gt;&lt;/h3&gt;  &lt;blockquote&gt;   &lt;p&gt;The F# Web Tools augment the F# distribution with tools to author homogeneous client/server/database web applications in one type-checked project. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;It does this by generating Javascript from F#.&amp;nbsp; The big advantage here is that you can effectively have statically checked Javascript and so &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/10/15/anders-hejlsberg-on-the-future-of-programming-languages.aspx"&gt;avoid a whole class of bugs that come along with dynamically typed programming&lt;/a&gt;.&amp;nbsp; While many are &lt;a href="http://clivetong.spaces.live.com/blog/cns%213F21DF299C355E7F%21220.entry"&gt;excited about this prospect&lt;/a&gt;, at least one person seems to have had &lt;a href="http://cid-05f59721c89c5188.profile.live.com/"&gt;trouble getting it to work&lt;/a&gt;.&amp;nbsp; Currently, only the source tree is available and it must be manually compiled.&amp;nbsp; I know I’m not the only one hoping for a tested release in the near future.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Blog – &lt;a href="http://blogs.msdn.com/mpeck/archive/2009/03/03/Solving-Problems-in-CSharp-and-FSharp-Part-1.aspx"&gt;Martin Peck’s Solving Problems in C# and F# – Part 1&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In this post Martin compares solutions to Project Euler problems 10 and 12 in both C# and F#.&amp;nbsp; In competition with his friend Giles Knap, he wrote his answers in C# while Giles wrote in F#.&amp;nbsp; Afterward, each set of answers is discussed independently.&amp;nbsp; He concludes that the languages were equally readable but the F# implementations were slower.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I wish Giles had written a rebuttal post as Martin seems to be a die hard C# fan.&amp;nbsp; I don’t agree that they were equally readable.&amp;nbsp; The F# problems lacked much of the syntactic cruft and whitespace found in the C# examples.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Also, as single core results are fast becoming meaningless, it would be very if they would agree to use asynchronous workflows in F# and compare that with the .NET Parallel Extensions in C#.&amp;nbsp; By constraining the answers to be single thread only, it seems like they avoided much of F#’s inherent benefit in multicore processing.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I also can’t help wondering how each of their prime generating examples would compare with the &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/20/functional-discoveries-in-the-microsoft-sociocosm-02-20-2009.aspx"&gt;memoizing example I mentioned two weeks ago&lt;/a&gt;.&amp;nbsp; I’d be shocked to see a similar C# implementation in anywhere near as little space.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;;subject=Let%e2%80%99s+Wax+Functional+03%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;;title=Let%e2%80%99s+Wax+Functional+03%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;title=Let%e2%80%99s+Wax+Functional+03%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;;title=Let%e2%80%99s+Wax+Functional+03%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx&amp;amp;;title=Let%e2%80%99s+Wax+Functional+03%2f06%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/03/07/let-s-wax-functional-03-06-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17631" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/google/default.aspx">google</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/javascript/default.aspx">javascript</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/roundup/default.aspx">roundup</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/web/default.aspx">web</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/csharp/default.aspx">csharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/webtools/default.aspx">webtools</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/mapreduce/default.aspx">mapreduce</category></item><item><title>Why OO may not suck, or, Take a ride on the Falsus Omnibus</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx</link><pubDate>Wed, 11 Feb 2009 11:00:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17448</guid><dc:creator>RickM</dc:creator><slash:comments>10</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17448.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17448</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17448</wfw:comment><description>&lt;p&gt;This post is in response to Joe Armstrong’s &lt;a href="http://www.sics.se/~joe/bluetail/vol1/v1_oo.html"&gt;Why OO Sucks&lt;/a&gt;.&amp;#160; While I feel that Joe’s post reads more like an sermon than a stream of rational thought, it does bring up a number of misconceptions I feel many people in the functional programming world share and which need to be discussed openly if it and the object oriented world are to come to terms and work together. &lt;/p&gt;  &lt;p&gt;The main issue here is that, in the minds of many functional programming advocates, the concept of an object is inseparable from the amalgamation of 30 years of different, and sometimes contradictory, object oriented programming ideologies.&amp;#160; &lt;/p&gt;  &lt;p&gt;Perhaps they don’t understand that when binding these ideas together for the sake of argument they are simply constructing a straw man.&amp;#160; Similarly, to say that we must either have all of the history of object oriented design or pure functional programming, is a false dichotomy.&amp;#160; We can have either, neither, both separately, or any number of combinations of ideas from both groups.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now, lets address each of Joe’s objections from a somewhat more moderate perspective.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In Response to “Objection 1 – Data Structure and functions should not be bound together.”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I disagree with Joe’s logic here.&amp;#160; It does not follow that because functions and data structures are “different animals” that they should “not be kept in the same cage”.&amp;#160; Wouldn’t having functions be first class citizens be locking them in the same cage with data structures as well?&amp;#160; The fact that they do share some fundamental similarity is manifest in that most functional programming languages do not treat function and data structure in a fundamentally different way.&amp;#160; &lt;/p&gt;  &lt;p&gt;Also, I have seen no compelling reason as to why it is wrong to couple transformations with the data structure that they are able to be applied to.&amp;#160; When transformations often have to be tailored specifically for a particular data structure, why would we not keep them strongly associated with said data structure.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In Response to “&lt;/strong&gt;&lt;strong&gt;Objection 2 – Everything has to be an object.”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As I discussed in my introduction, this is simply not true in all languages which support objects.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In Response to “&lt;/strong&gt;&lt;strong&gt;Objection 3 – In an OOPL data type definition are spread out all over the place.”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;First of all, it should be immediately obvious to anyone who works on even medium sized projects that having many types defined in the same file is a very bad thing.&amp;#160; The core of the issue is that it makes group collaboration quite difficult.&lt;/p&gt;  &lt;p&gt;Secondly, any system that has ubiquitous data structures can’t be very large otherwise the namespace would become quite cluttered.&amp;#160; In large systems this cannot be mitigated by simply saying “more functions, fewer data structures”.&lt;/p&gt;  &lt;p&gt;Finally, to state that any object which operates on another must inherit from it is a completely incorrect statement.&amp;#160; In the modern object oriented world it is common to have objects which exist solely to build, process or interface with other objects.&amp;#160; Also, as I mentioned above, it’s entirely possible to have stateless objects which are simply data structures which are bundled with a collection of predefined transformations.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In Response to “&lt;/strong&gt;&lt;strong&gt;Objection 4 – Objects have private state.”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;First of all, state is not the root of all evil.&amp;#160; While it may be harmful to concurrency and static analysis, there are many stateful algorithms which perform much better than their stateless counterparts.&lt;/p&gt;  &lt;p&gt;Secondly, it’s entirely possible to have immutable objects.&amp;#160; Perhaps in these objects some state is hidden for the sake of representing ideas in a simple manner, perhaps not. &lt;/p&gt;  &lt;p&gt;Finally, as to information hiding in general, in large systems it’s very easy to be overwhelmed by the quantity of information.&amp;#160; If you can say via testing “I can trust this structure over here” it means it’s entirely possible to ignore that and focus work on another piece of the system.&amp;#160; It’s also important to note that functional programming languages often have information hiding systems of their own.&amp;#160; In the most base case, calling other precompiled functions amounts to information hiding and comes along with all of the negative things stated in this section.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In Response to “&lt;/strong&gt;&lt;strong&gt;Conclusion – Why OO was popular.”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It seems to me here that if you removed all instances of “It was thought” this would be a somewhat correct summarization.&amp;#160; &lt;/p&gt;  &lt;p&gt;In reality, the industry has been using object oriented programming for many more reasons than what has been listed here.&amp;#160; A particularly strong reason is that it supplies an organizational framework for data structures and functions which simply does not have an equivalent in the pure functional programming world. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;I must apologize to Joe here.&amp;#160; I don’t intend to pick on him in particular.&amp;#160; However, I had never previously seen a post in which the the most common misconceptions around object oriented programming were so plainly stated.&lt;/p&gt;  &lt;p&gt;To say that the concept of an object and that the collections of ideologies used commonly to construct programs using objects are somehow inseparable is completely false.&amp;#160; To further state that the only reasonable choice is to instead move to pure functional programming bears no additional truth.&amp;#160; Yet they are both pieces of constantly perpetuated misinformation.&amp;#160; &lt;/p&gt;  &lt;p&gt;The fundamental idea that data and function can be bound for the sake of organization still holds and does not inherently violate any of the tenants of functional programming.&amp;#160; In terms of the organizational structure of our programs we have gained much from objects.&amp;#160; Why then should we abandon them without sufficient reason?&amp;#160; It seems to me that it would be a mistake to dismiss all of what we have gained for baseless ideological reasons alone.&amp;#160; &lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;;subject=Why+OO+may+not+suck%2c+or%2c+Take+a+ride+on+the+Falsus+Omnibus" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;;title=Why+OO+may+not+suck%2c+or%2c+Take+a+ride+on+the+Falsus+Omnibus" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;title=Why+OO+may+not+suck%2c+or%2c+Take+a+ride+on+the+Falsus+Omnibus" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;;title=Why+OO+may+not+suck%2c+or%2c+Take+a+ride+on+the+Falsus+Omnibus" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx&amp;amp;;title=Why+OO+may+not+suck%2c+or%2c+Take+a+ride+on+the+Falsus+Omnibus&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/11/why-oo-is-not-so-bad-but-could-be-better.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17448" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/object+oriented/default.aspx">object oriented</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/oo/default.aspx">oo</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Blogs/default.aspx">Blogs</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/languages/default.aspx">languages</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fp/default.aspx">fp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/pure/default.aspx">pure</category></item><item><title>Discoveries This Week 02/06/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx</link><pubDate>Fri, 06 Feb 2009 16:24:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17428</guid><dc:creator>RickM</dc:creator><slash:comments>1</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17428.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17428</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17428</wfw:comment><description>&lt;p&gt;Some interesting gems this week.&amp;nbsp; Revit, Closures and MathTools won the day.&amp;nbsp; However, I do hope you'll take a look at the IL post as well. &lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;Blog – &lt;a href="http://thebuildingcoder.typepad.com/blog/2009/01/use-f-directly-in-revit.html"&gt;Jeremy Tammik’s Use F# Directly in Revit&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In Jeremy’s post he discusses what is initially necessary to get F# and Revit working together.&amp;nbsp; He also provides a sample of a Revit addin written in F#.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=8479974"&gt;Revit&lt;/a&gt; is Autodesk’s architecture and design studio.&amp;nbsp; It allows physical engineers to coordinate and play with, design and visualize data while integrating directly with AutoCad.&amp;nbsp; It also provides &lt;a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=2484975"&gt;a .NET 2.0 API&lt;/a&gt;.&amp;nbsp; Given F#’s support for units as well as it’s concise and mathy style, it makes sense that it would be an ideal language for engineers.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Site - &lt;a href="http://en.wikibooks.org/wiki/F_Sharp_Programming"&gt;WikiBooks FSharp Programming&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Before I stumbled upon this site, I had never head of of WikiBooks.&amp;nbsp; That’s why I was incredibly surprised to find that it has the best online general F# reference around.&amp;nbsp; It has extensive sections on functional, immutable and imperative programming with rich examples and references to the math behind the ideas presented.&amp;nbsp; It’s a great site to have at hand for both those learning about the language and those experienced but still needing to occasionally look something small up.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;StackOverflow -&amp;nbsp; &lt;a href="http://stackoverflow.com/questions/12924/f-closure"&gt;A practical example of a closure in F#&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Learning how to program functionally is much more than just learning some&amp;nbsp; new ideas and a new syntax.&amp;nbsp; It comes along with a ton of new jargon, some of which can be quite foreign sounding.&amp;nbsp; I find that it often turns out that the jargon actually represents a very simple idea and that becomes immediately obvious when discussed with a simple example. &lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Software – &lt;a href="http://www.codeplex.com/fsmathtools"&gt;FSharp.MathTools&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;As you might have suspected by its name, MathTools is an extensive set of mathematics libraries for F#.&amp;nbsp; It provides, among other things, statistical functions, fast fourier transforms, optimization algorithms, &lt;a href="http://www.mathworks.com/"&gt;Matlab&lt;/a&gt; compatibility and extended mathematical notation.&amp;nbsp; With a little development this combined with &lt;a href="http://www.codeplex.com/vslab"&gt;VSLab&lt;/a&gt; could provide a viable alternative to tools like Matlab while still allowing for collaboration with colleagues.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Article – &lt;a href="http://www.codeproject.com/KB/msil/ilassembly.aspx"&gt;Introduction to IL Assembly Language&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;It’s the responsibility of any serious programmer to know how how his or her tools work all the way down the chain.&amp;nbsp; In this relatively short article (given the topic) everything you would need to write a .NET compiler is distilled.&amp;nbsp; It’s the best reference of it’s kind I’ve seen. &lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;;subject=Discoveries+This+Week+02%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;;title=Discoveries+This+Week+02%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;title=Discoveries+This+Week+02%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;;title=Discoveries+This+Week+02%2f06%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx&amp;amp;;title=Discoveries+This+Week+02%2f06%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/02/06/discoveries-this-week-02-06-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17428" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/IL/default.aspx">IL</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/optimization/default.aspx">optimization</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/VSLab/default.aspx">VSLab</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/roundup/default.aspx">roundup</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/algorithms/default.aspx">algorithms</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/AutoCad/default.aspx">AutoCad</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/jargon/default.aspx">jargon</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Revit/default.aspx">Revit</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/closure/default.aspx">closure</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/math/default.aspx">math</category></item><item><title>Discoveries This Week 01/30/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx</link><pubDate>Fri, 30 Jan 2009 19:46:55 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17374</guid><dc:creator>RickM</dc:creator><slash:comments>2</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17374.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17374</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17374</wfw:comment><description>&lt;p&gt;The beauty of clean syntax and deep abstraction is an often overlooked feature of functional programming.&amp;#160; As they say, people come to functional programming for the concurrency but stay for the beautiful code (actually, I just made that up).&amp;#160; Also included: POPL 2009, S#arp and functional unit testing.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog - &lt;a href="http://codebetter.com/blogs/matthew.podwysocki/archive/2009/01/29/functional-programming-unit-testing-part-7.aspx"&gt;Matthew Podwysocki’s Series on Functional Unit Testing&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In this eight part series Matthew covers unit testing in Haskell from the basics setting up HUnit to the details of writing purely functional tests.&lt;/p&gt;  &lt;p&gt;This series is the only place where I’ve seen functional programming unit testing talked about with any significant depth.&amp;#160; While in writing this series Matthew used Haskell, it and F# share much in common and it’s obvious that he worked hard to make his posts apply to both.&amp;#160; I consider it a must read for anyone thinking about taking functional software engineering seriously.&amp;#160; &lt;/p&gt;  &lt;p&gt;Although he has finished the series, I hope that in the future he takes some time to focus on unit testing in F# specifically.&amp;#160; I’ve yet to see topics such as mocking or ensuring referential transparency by test covered.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Transcription - &lt;a href="http://plgrand.blogspot.com/2009/01/summary-of-panel-discussion.html"&gt;POPL 2009 Grand Challenges Panel Summary&lt;/a&gt;&amp;#160;&lt;/h3&gt;  &lt;p&gt;This panel was lead by such research giants as &lt;a href="http://research.microsoft.com/en-us/people/simonpj/default.aspx"&gt;Simon Peyton Jones&lt;/a&gt;, &lt;a href="http://pauillac.inria.fr/~xleroy/"&gt;Xaveir Leroy&lt;/a&gt;, &lt;a href="http://www.cs.utexas.edu/users/mckinley/"&gt;Kathryn McKinley&lt;/a&gt;, &lt;a href="http://www.eecs.harvard.edu/~greg/"&gt;Greg Morrisett&lt;/a&gt; and &lt;a href="http://www.csail.mit.edu/people/_Arvind/"&gt;Arvind&lt;/a&gt;.&amp;#160; In it they discuss where programming language development is heading and the factors driving us there.&amp;#160; Well worth the read for anyone interested in programming language evolution.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog - &lt;a href="http://www.markhneedham.com/blog/2009/01/19/f-vs-c-vs-java-functional-collection-parameters/"&gt;Mark Needham’s F# vs C# vs Java: Collection Parameters&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In this post Mark compares list operations in F#, C# and Java.&amp;#160; It’s striking to see how far we have come in terms of clean, concise syntax.&amp;#160; Actually, it seems kind of reminiscent of &lt;a href="http://images.google.com/images?q=evolution+of+man"&gt;evolution of man posters&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog - &lt;a href="http://themechanicalbride.blogspot.com/2009/01/f-sharpest-of-sharps.html"&gt;Jafar Husain’s F#: Real Sharp&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;When working in F# over a long period it’s easy to forget that one of the best things about it is how it’s concise syntax and deep abstractions make your code so much easier to understand and beautiful to look at.&amp;#160; In his post Jafar reminds us of this by contrasting C# with F# samples. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Software – &lt;a href="http://devlicio.us/blogs/billy_mccafferty/archive/2009/01/19/s-arp-architecture-beta-1-0-now-available.aspx"&gt;S#arp Architecture Beta 1.0 Available&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;S#arp Architecture promises to make building web applications much easier by making much of the glue we currently use in ASP.NET web applications obsolete.&amp;#160; &lt;/p&gt;  &lt;p&gt;I am a big fan of inversion of control and it is something that comes very natural in functional programming languages.&amp;#160; I hope to see some examples with S#arp Architecture and F# internals at some point in the near future.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;;subject=Discoveries+This+Week+01%2f30%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f30%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;title=Discoveries+This+Week+01%2f30%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f30%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f30%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/30/discoveries-this-week-01-30-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17374" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/programming/default.aspx">programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/research/default.aspx">research</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/syntax/default.aspx">syntax</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/unit+testing/default.aspx">unit testing</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/beautiful+code/default.aspx">beautiful code</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/S_2300_arp/default.aspx">S#arp</category></item><item><title>F# and Haskell, Estranged Cousins</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx</link><pubDate>Thu, 29 Jan 2009 20:24:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17352</guid><dc:creator>RickM</dc:creator><slash:comments>11</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17352.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17352</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17352</wfw:comment><description>&lt;p&gt;In this post I compare and contrast Haskell and F#.&amp;nbsp; It may come as no surprise that with so much shared history they share so much in common.&amp;nbsp; However, it’s interesting to consider how the perspectives of the languages’ developers play a large role in determining the differences between the languages.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;A Shared History&lt;/h3&gt;  &lt;p&gt;As far as the family tree of functional programming is concerned, F# and Haskell are not too distant cousins. &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/haskellandfsharphistory_3E27F754.png"&gt;&lt;img src="http://www.atalasoft.com/cs/blogs/rickm/haskellandfsharphistory_thumb_67329650.png" title="haskellandfsharphistory" style="border:0px none;display:block;float:none;margin-left:auto;margin-right:auto;" alt="haskellandfsharphistory" border="0" width="468" height="118"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;They both share a very similar syntax as well as a large number of features.&amp;nbsp; A great example of this is &lt;a href="http://www.codecommit.com/blog/scala/what-is-hindley-milner-and-why-is-it-cool"&gt;Hindley–Milner&lt;/a&gt; type inference.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;ML was the first widely used language to leverage Hindley–Milner for static inferred typing, a feature to which it owes much of it’s success.&amp;nbsp; However, almost all functional programming languages now also have this feature.&amp;nbsp; The FP community has always been fast to adopt obviously useful features.&amp;nbsp; Some other things that fit into this category are garbage collection (Lisp) and lazy evaluation (Lazy ML). &lt;/p&gt;  &lt;p&gt;The most obvious difference between Haskell and F# is somewhat easy to infer from this graph: object oriented constructs.&amp;nbsp; That is to say, OCaml pioneered the use of object oriented data structures in functional programming and F# is it’s direct descendant.&amp;nbsp; This has made OCaml (and in turn F#) somewhat of a black sheep in the theoretical functional programming world.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;The reason many functional programming theorists dislike objects is because they want a language based on math.&amp;nbsp; Unlike the majority of the ideas in functional programming, objects don’t have roots in either &lt;a href="http://en.wikipedia.org/wiki/Lambda_calculus"&gt;lambda calculus&lt;/a&gt; or &lt;a href="http://www.haskell.org/haskellwiki/Category_theory"&gt;category theory&lt;/a&gt;.&amp;nbsp; However, this has not stopped OCaml from being successful.&amp;nbsp; In fact, quite the opposite.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;The use of objects mitigates one of the largest roadblocks in the path to functional programming adoption by engineers:&amp;nbsp; the difficulty inherent in organizing large functional programs.&amp;nbsp; The OCaml language engineers also showed that leveraging the object oriented paradigm did not hamper their ability to use static analysis techniques.&amp;nbsp; &lt;a href="http://www.podval.org/%7Esds/ocaml-sucks.html"&gt;Because of this OCaml approaches the speed of C&lt;/a&gt;.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;While it is not pure, OCaml is almost an ideal compromise between theory and engineering.&amp;nbsp;&amp;nbsp; Indeed, nothing approaches it in terms of a functional language which fits into the paradigms of the Microsoft .NET framework.&amp;nbsp; It’s easy to see why Microsoft chose to extend OCaml when building a functional language to bring to it’s software engineering masses. &lt;/p&gt;  &lt;p&gt;On the other hand, Haskell is almost the ideal language for academic exploration of functional programming.&amp;nbsp; The fact that it’s strictly limiting in terms of side effecting and adherence to abstract mathematical concepts means no side effecting surprises.&amp;nbsp; Also, the fact that it’s a committee language means that if a researcher can get enough support for an idea, they can almost be sure it will be included in the next iteration of the language.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Haskell as a Committee Language&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Repeat the mantra after me:&amp;nbsp; Haskell is Lazy; Haskell is Pure; Haskell has Type Classes; Haskell is a Committee Language. &lt;/p&gt;  &lt;p&gt;Of all of these, the most defining characteristic of Haskell is that it is a committee language.&amp;nbsp; It’s an amalgamation of many different goals with no clear vision.&amp;nbsp; This is at the same time Haskell’s greatest strength and greatest weakness.&amp;nbsp; While it is the most widely used pure functional programming language, the quirks of committee design are obvious.&lt;/p&gt;  &lt;p&gt;Some I ran into within two hours of starting with Haskell:&lt;/p&gt;  &lt;p&gt;The first was integer rollover.&amp;nbsp; Haskell has two integer datatypes: &lt;b&gt;&lt;a href="http://www.zvon.org/other/haskell/Outputprelude/Integer_d.html"&gt;integer&lt;/a&gt;&lt;/b&gt; and &lt;b&gt;&lt;a href="http://www.zvon.org/other/haskell/Outputprelude/Int_d.html"&gt;int&lt;/a&gt;&lt;/b&gt;.&amp;nbsp; Integer is infinitely sized but can be quite slow to use and due to that, it’s rather infrequently used.&amp;nbsp; On the other hand int is fast but, just like in C, &lt;a href="http://praisecurseandrecurse.blogspot.com/2006/12/division-bell-tolls-for-me-part-three.html"&gt;can roll over&lt;/a&gt;. There is no way to check the &lt;a href="http://www.faqs.org/docs/jargon/O/overflow-bit.html"&gt;overflow bit&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;So, ints can roll over, I can accept that.&amp;nbsp; What it implies to me is that speed is more important to Haskell than robustness.&amp;nbsp; However, this brings me to my second point:&amp;nbsp; Many basic list operations will &lt;a href="http://www.haskell.org/haskellwiki/Non-empty_list"&gt;throw errors on an empty list&lt;/a&gt;.&amp;nbsp; This seems entirely inconsistent to me.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;I understand that if they didn’t, a logic error would be much more likely to cause an infinite loop in a &lt;a href="http://learnyouahaskell.com/recursion"&gt;tail recursive function&lt;/a&gt;.&amp;nbsp; However, this seems completely at odds with the “speed first” definition of an int.&amp;nbsp; It also means that almost everyone ends up wrapping the default list operations with the &lt;a href="http://www.haskell.org/all_about_monads/html/maybemonad.html"&gt;Maybe monad&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The third issue was that operations with the &lt;a href="http://www.zvon.org/other/haskell/Outputprelude/Float_d.html"&gt;float&lt;/a&gt; data type are slow.&amp;nbsp; &lt;a href="http://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fwww.realworldhaskell.org%2F&amp;amp;ei=eOeBSeGQBJa5twfj_9k6&amp;amp;usg=AFQjCNG4E9hbaNy1O3FUOSuWiNjhl-vz8w&amp;amp;sig2=y3z5R23zGJXvuRxNMNV-Nw"&gt;Real World Haskell&lt;/a&gt; suggests always using a &lt;a href="http://www.zvon.org/other/haskell/Outputprelude/Double_d.html"&gt;double&lt;/a&gt; due to the fact that a great deal of focus has gone into optimizing double arithmetic but very little into floats.&amp;nbsp; This demonstrates another thing that comes about with committee languages: often things as important as optimization of basic data types can fall through the cracks because everyone involved wants to work on more exciting things.&lt;/p&gt;  &lt;p&gt;Please don’t misunderstand me here, I really like Haskell.&amp;nbsp; I’m hard on it because I can see that it has a great deal of unrealized potential.&amp;nbsp; If Haskell is to be a language used for real software engineering, the committee needs to sit down and think hard about an overarching vision for the project.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;What is the goal here?&lt;/h3&gt;  &lt;p&gt;The biggest difference between the world of theorists and the world of engineers is that each group has an entirely different set of concerns.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Theorists want to implement ideas fast so that they can crank out papers fast.&lt;/b&gt;&amp;nbsp; A large part of this is having a language that is very close to math so that implementing ideas directly from the chalkboard is trivial.&amp;nbsp; As the theory world changes so fast, they don’t often care much about organization or maintainability.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;As the committee responsible for Haskell is mainly made up of theorists, it’s easy to see why the language has taken the direction it has.&amp;nbsp; It’s a language that is very close to math.&amp;nbsp; As the lifecycle of most academic code is very short, small implementation details which might cause a reduction in robustness are less important. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Engineers want to minimize time spent maintaining code.&lt;/b&gt;&amp;nbsp; Part of this is having a language that emphasizes safety in that it facilitates catching as many bugs as possible, as early in the process as possible.&amp;nbsp; Another important part of this is code organization as every moment that is spent trying to find a bug is a moment spent not fixing it.&amp;nbsp; As the cost of &lt;a href="http://users.jyu.fi/%7Ekoskinen/smcosts.htm"&gt;maintaining software generally dwarfs the initial development cost&lt;/a&gt;, development speed must take a back seat to testing and organization. &lt;/p&gt;  &lt;p&gt;The syntax heavy C# is a great example of this.&amp;nbsp; It’s slow to write in but provides many constructs for the organization and testing of code.&amp;nbsp; On top of this a great number of &lt;a href="http://www.dofactory.com/Patterns/Patterns.aspx"&gt;design patterns&lt;/a&gt; exist to further categorize substructures in a computer program.&amp;nbsp; C# is slow to write, but it’s relatively safe and mountains of patterns and best practices have been made to guide it’s developers.&lt;/p&gt;  &lt;p&gt;However, we in the software engineering world are in the midst of a crisis.&amp;nbsp; It turns out that traditional imperative &lt;a href="http://www.paulgraham.com/hundred.html"&gt;object oriented programs do not lend themselves to heavy parallelization&lt;/a&gt;.&amp;nbsp; Yet, parallelize we must.&amp;nbsp; We are looking at exponential growth in the number of cores contained in each processor. Because of this we engineers find ourselves at a bit of an impasse.&amp;nbsp; Those that are looking ahead know…&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Engineers will soon want very badly to minimize time spent maintaining parallelized code.&amp;nbsp; &lt;/b&gt;We need our programs to be easy to organize, manage and test.&amp;nbsp; Yet, as we will soon need to deal with massively parallelized systems, we find many of our ideas about what makes code robust and maintainable are broken.&amp;nbsp; At the same time, to move to a purely functional language means leaving behind years of thought on how computer programs ought to be constructed, tested and maintained.&amp;nbsp; Having any pattern, even if it’s wasteful or has many corner cases, is much better than having none.&amp;nbsp; This is why a hybrid language is so important.&lt;/p&gt;  &lt;p&gt;OCaml and F# provide engineers with the set and forget concurrency that comes along with the functional tradition.&amp;nbsp; At the same time these languages have all of the organizational constructs of object oriented programming as well.&amp;nbsp; This means that we can continue to use the same types of large scale organizational structures in our programs and also gain the safe parallelism that implicit immutability provides.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;And so we see that it’s important to consider a language in terms of how it’s creators envisioned it’s use.&amp;nbsp; Haskell has been developed mainly with research in mind and so is a fantastic research language.&amp;nbsp; F# has been developed mainly with engineering in mind and so is much better suited for engineering.&lt;/p&gt;  &lt;p&gt;In understanding this it’s also easy to see that comparing Haskell to F# is &lt;a href="http://www.i-edainc.com/old/Groups/PhysicsVsEngineering.htm"&gt;like comparing the tools of a physicist to those of an engineer&lt;/a&gt;.&amp;nbsp; They may have much in common superficially, but they are designed with much different ends in mind. &lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h3&gt;Links&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fresearch.microsoft.com%2Fen-us%2Fum%2Fpeople%2Fsimonpj%2Fpapers%2Fhistory-of-haskell%2Fhistory.pdf&amp;amp;ei=vQ6CSfb9C9e4twfE8-kc&amp;amp;usg=AFQjCNHoTqbyAouWy1O1UWUheO8cOaSn2w&amp;amp;sig2=BgVs-3nnFSOI3sEveJTN0g"&gt;A History of Haskell: Being Lazy with Class&lt;/a&gt;    &lt;br&gt;&lt;a href="http://www.soton.ac.uk/%7Efangohr/software/ocamltutorial/"&gt;Tutorial: OCaml for Scientific Computation&lt;/a&gt; (Contains some history)&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;;subject=F%23+and+Haskell%2c+Estranged+Cousins" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;;title=F%23+and+Haskell%2c+Estranged+Cousins" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;title=F%23+and+Haskell%2c+Estranged+Cousins" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;;title=F%23+and+Haskell%2c+Estranged+Cousins" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx&amp;amp;;title=F%23+and+Haskell%2c+Estranged+Cousins&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/29/f-and-haskell-estranged-cousins.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17352" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/programming/default.aspx">programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/concurrency/default.aspx">concurrency</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/object+oriented/default.aspx">object oriented</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/optimization/default.aspx">optimization</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/garbage+collection/default.aspx">garbage collection</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/languages/default.aspx">languages</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/haskell/default.aspx">haskell</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/rants/default.aspx">rants</category></item><item><title>Discoveries This Week 01/16/2009</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx</link><pubDate>Fri, 16 Jan 2009 16:17:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17229</guid><dc:creator>RickM</dc:creator><slash:comments>3</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17229.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17229</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17229</wfw:comment><description>&lt;p&gt;This week’s theme is functional programming.&amp;#160; Included are discussions on Software Transactional Memory, Functional Architecture and the impact of the CLR on functional Programming in .NET.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog: &lt;a href="http://www.brandonwerner.com/2009/01/01/software-transactional-memory-debunked/"&gt;Brandon Werner’s Software Transactional Memory: Debunked!&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;In starting with a title that is decidedly sensationalistic, Brandon effectively trashes STM over its expensive overhead based on a &lt;a href="http://portal.acm.org/citation.cfm?doid=1400214.1400228"&gt;paper published by ACM&lt;/a&gt;.&amp;#160; His position, and that of the researchers, is that most programmers see assignment as inexpensive and so would not understand that they need to optimize for atomic transactions when using STM.&amp;#160; &lt;/p&gt;  &lt;p&gt;Brian Hurt responded at length in his blog post &lt;a href="http://enfranchisedmind.com/blog/2009/01/02/the-problem-with-stm-your-languages-still-suck/"&gt;The Problem with STM: your languages still suck&lt;/a&gt;.&amp;#160; Brian’s view is that the fundamental issue here is that most programming languages encourage heavy use of mutable variables and so many expensive assignments and reads are happening when STM is used.&amp;#160; If instead one is using a functional programming language which discourages variable mutations, the high cost of STM is much less of an issue.&amp;#160; Brian then further flushes out his ideas in a &lt;a href="http://enfranchisedmind.com/blog/2009/01/10/responses-to-the-problem-with-stm/"&gt;follow up blog&lt;/a&gt; in which he responds to responses to his first.&lt;/p&gt;  &lt;p&gt;While I don’t agree that ACM’s analysis “puts a deep nail in the coffin of STM”, I also don’t think it’s reasonable to expect most programmers will be jumping on the functional programming bandwagon in the near future.&amp;#160; The main issue is that it’s just too different from what they are used to.&amp;#160; &lt;/p&gt;  &lt;p&gt;For now FP will remain the domain of the motivated and pragmatic programmer.&amp;#160; It will be necessary to slowly ease the majority into this new, different world via things like functional C# extensions.&amp;#160; I do think that some kind of STM with training wheels for mainstream programmers would be a good way to promote this over the long term.&amp;#160; However, it would be extremely important that the inherent overhead is explicitly stated.&lt;/p&gt;  &lt;p&gt;Finally, I wanted to note that &lt;a href="http://blogs.msdn.com/stmteam/archive/2009/01/02/transactional-memory-in-a-real-world.aspx"&gt;Sasha Dadiomov of the Microsoft STM team has an interesting piece on the difficulties involved in debugging STM&lt;/a&gt;.&amp;#160; It’s an informative glimpse of how Microsoft’s implementation of STM is shaping up.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog: &lt;a href="http://blogs.msdn.com/chrsmith/archive/2008/12/30/speech-recognition-is-gun-and-easy.aspx"&gt;Chris Smith’s Speech Recognition is gun [sic] and easy!&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;It’s possible he meant fun and easy but I can’t be sure.&amp;#160; &lt;/p&gt;  &lt;p&gt;A quick but fun piece on leveraging System.Speech.Dll inside of F#.&amp;#160; The result is a 10 line program that takes your speech as input and prints it to the console.&amp;#160; Very simple yet quite cool.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Blog: &lt;a href="http://weblogs.asp.net/podwysocki/archive/2009/01/13/how-would-the-clr-be-different.aspx"&gt;Matthew Podwysocki’s How would the CLR Be Different?&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;In this post Matthew discusses how the CLR might be better implemented to serve the needs of functional programming languages.&amp;#160; I especially like the idea of including some new functionality for type manipulation and construction.&lt;/p&gt;  &lt;p&gt;However, I would like to see specific examples of exactly what Matthew would like changed under the hood.&amp;#160; He mentions a lot of general goals with reasoning to back them up but not how they might be implemented.&amp;#160; I also feel that it would be inappropriate to implement some of these ideas at the CLR level instead of the language or API level.&lt;/p&gt;  &lt;p&gt;For example, non-null references.&amp;#160; I’m all for Spec# style pre and post conditions but why is it necessary that this be implemented at the CLR level?&amp;#160; This belongs in the language instead.&amp;#160; Also, the issue with immutability in .NET mostly has to do with Microsoft’s .NET API design.&amp;#160; The stack based nature of IL is completely compatible with the idea.&lt;/p&gt;  &lt;p&gt;The CLR should be designed with the most general case in mind and not with the slant towards any particular language.&amp;#160; If the CLR is to be viable long term, flexibility must be emphasized over specific optimizations.&amp;#160; &lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;Paper: &lt;a href="http://funct.org/wiki/#Building%20a%20Wiki%20in%20Haskell.html"&gt;Sebastiaan Visser’s Building a Wiki in Haskell&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;A study on implementing a Wiki in Haskell which is a purely functional programming language.&amp;#160; This paper is a must read for both those interested in functional project architecture and those who question the viability of using FP for large applications.&amp;#160; The complete source of the project is available for your viewing pleasure.&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;;subject=Discoveries+This+Week+01%2f16%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f16%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;title=Discoveries+This+Week+01%2f16%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f16%2f2009" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx&amp;amp;;title=Discoveries+This+Week+01%2f16%2f2009&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/16/discoveries-this-week-01-16-2009.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17229" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/concurrency/default.aspx">concurrency</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/memory/default.aspx">memory</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/languages/default.aspx">languages</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/roundup/default.aspx">roundup</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/haskell/default.aspx">haskell</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/algorithms/default.aspx">algorithms</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/design/default.aspx">design</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/software+transactional+memory/default.aspx">software transactional memory</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/stm/default.aspx">stm</category></item><item><title>Discoveries This Week 01/09/2008</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/09/discoveries-this-week-01-09-2008.aspx</link><pubDate>Fri, 09 Jan 2009 16:37:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:17126</guid><dc:creator>RickM</dc:creator><slash:comments>3</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/17126.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=17126</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=17126</wfw:comment><description>It’s been a very exciting week. I actually had more things to post than time would allow me to write about. I’ll have to save them for next time. Blog: Daniel Spiewak’s What is Hindley-Milner? (and why is it cool?) Hindley-Milner is the algorithm all...(&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2009/01/09/discoveries-this-week-01-09-2008.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=17126" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/clojure/default.aspx">clojure</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/programming/default.aspx">programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/object+oriented/default.aspx">object oriented</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/code/default.aspx">code</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/reflection/default.aspx">reflection</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/languages/default.aspx">languages</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/roundup/default.aspx">roundup</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/haskell/default.aspx">haskell</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/algorithms/default.aspx">algorithms</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/decorators/default.aspx">decorators</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/continuous+integration/default.aspx">continuous integration</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/attributes/default.aspx">attributes</category></item><item><title>F# at Code Camp 10 In Waltham, MA</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx</link><pubDate>Fri, 19 Sep 2008 20:02:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:15719</guid><dc:creator>RickM</dc:creator><slash:comments>1</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/15719.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15719</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15719</wfw:comment><description>I'll be at &lt;a href="http://blogs.msdn.com/cbowen/archive/2008/09/15/code-camp-10-the-schedule.aspx"&gt;New England Code Camp 10&lt;/a&gt;
tomorrow giving another talk about functional programming and
concurrency in F#.&amp;nbsp; It will be fairly similar to my previous talks in
terms of ideas and content, however, I have put a lot of work into
making the functional programming ideas easier to understand. The code
samples have also been updated and are now 100% compatible with the F#
CTP Release. &lt;br&gt;
&lt;p&gt;&lt;strike&gt;Our internet connection is going down soon for
testing. I'll be updating this post later on tonight with more
information. I'll be posting my slides and updated code examples.&lt;/strike&gt;&lt;/p&gt;&lt;p&gt;I did manage to get my slides and new code samples uploaded on Friday but I didn't have time to change my blog text. You can find them &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/attachment/15719.ashx"&gt;here&lt;/a&gt;. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The sites of interest for my presentation:&lt;a href="http://msdn.microsoft.com/en-us/fsharp/default.aspx"&gt;&lt;br&gt;Microsoft's F# Developer's Center&lt;/a&gt;&lt;a href="http://research.microsoft.com/fsharp/fsharp.aspx"&gt; &lt;/a&gt;( Download F# here. )&lt;br&gt;&lt;a href="http://research.microsoft.com/fsharp/fsharp.aspx"&gt;F#'s Microsoft Research Site&lt;/a&gt; &lt;br&gt;&lt;a href="http://cs.hubfs.net/"&gt;hubFS: THE place for F#&lt;/a&gt; ( The forums here are a great resource. )&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Here are some additional links you might find interesting:&lt;a href="http://blogs.msdn.com/dsyme/"&gt;&lt;br&gt;Don Syme's Blog&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.strangelights.com/blog/"&gt;Robert Pickering's Blog&lt;/a&gt;&lt;br&gt; &lt;a href="http://podwysocki.codebetter.com/"&gt;Matthew Podwysocki's Blog&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/25/10-hours-in-fsharp-exploring-concurrency-through-an-ant-colony-simulation.aspx"&gt;My F# Ant Colony Work&lt;/a&gt;&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;;subject=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx&amp;amp;;title=F%23+at+Code+Camp+10+In+Waltham%2c+MA&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/19/f-at-code-camp-10-in-waltham-ma.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15719" width="1" height="1"&gt;</description><enclosure url="http://www.atalasoft.com/cs/blogs/rickm/attachment/15719.ashx" length="319226" type="application/zip" /><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/programming/default.aspx">programming</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/lamba/default.aspx">lamba</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/concurrency/default.aspx">concurrency</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/code/default.aspx">code</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Code+Camp/default.aspx">Code Camp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/talks/default.aspx">talks</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/microsoft+research/default.aspx">microsoft research</category></item><item><title>How to set up your own free VSLab-based Matlab/Mathematica replacement</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx</link><pubDate>Mon, 08 Sep 2008 14:48:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:15531</guid><dc:creator>RickM</dc:creator><slash:comments>1</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/15531.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15531</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15531</wfw:comment><description>&lt;p&gt;VSLab has &lt;a href="http://www.codeplex.com/vslab/Release/ProjectReleases.aspx?ReleaseId=15329"&gt;just been updated&lt;/a&gt; with full support for &lt;a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx"&gt;Visual Studio 2008 Shell&lt;/a&gt; and the F# CTP release. It has been a &lt;a href="http://cvslab.di.unipi.it/vslab/blog/post/2008/09/07/September-CTP-and-VSLab-again.aspx"&gt;rough couple of weeks&lt;/a&gt; for the VSLab team as F# CTP &lt;a href="http://cvslab.di.unipi.it/vslab/blog/post/2008/09/06/F-September-CTP-and-VSLab.aspx"&gt;changed a number of things&lt;/a&gt; and they have been working hard to put together a compatible release. In this article I talk about a bit about what exactly VSLab is and walk you through creating a free VSLab installation.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;What is VSLab? &lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;VSLab is a Matlab-like interactive environment which is implemented on top of Visual Studio 2008 and F#. It is designed to speed the development of scientific applications and make visualizing data quick and easy. One of the great benefits, besides being free, is that VSLab allows you to compile your applications into binaries which can be easily redistributed. Also, because the code is being run on the CLR it is, in most cases, much faster than the notoriously slow Matlab and Mathematica. &lt;br&gt;&lt;/p&gt;&lt;p&gt;The &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;amp;displaylang=en&amp;amp;tm"&gt;F# CTP&lt;/a&gt; was updated a few days ago in order to fix a &lt;a href="http://blogs.msdn.com/dsyme/archive/2008/08/29/detailed-release-notes-for-the-f-september-2008-ctp-release.aspx"&gt;number of bugs&lt;/a&gt;. Even if you aren't interested in VSLab, now would be a great time to update your CTP installation. &lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;VSLab Quick Installation Instructions &lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;With these two releases it's very easy to create your own free Matlab-Like Visual Studio environment. It's important that these steps are performed in order as each step depends on the previous step. Installing Managed DirectX is not strictly necessary but you will not be able to use the VSLab visualizations without it.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Prerequisites&lt;/b&gt;&lt;br&gt;If you already have a version of Visual Studio 2008 installed, it must be updated to SP1 before you can continue. &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E%20&amp;amp;displaylang=en"&gt;The SP1 update package is available here&lt;/a&gt;.&lt;br&gt;&lt;/p&gt;&lt;p&gt;All previous versions of F# and VSLab must be uninstalled before starting this process. Also, these steps must be followed in the order they appear here.&lt;/p&gt;&lt;p&gt;&lt;b&gt;1) &lt;/b&gt;&lt;b&gt;Install Visual Studio 2008 Shell.&lt;br&gt;&lt;/b&gt;1a) &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=2e9a8c35-eb3d-43eb-9122-a5ec195cd7bb&amp;amp;displaylang=en"&gt;Download Visual Studio 2008 Shell (integrated mode).&lt;/a&gt;&lt;br&gt;1b) Run the installer to Extract VS 2008 Shell Package to a temporary directory.&lt;br&gt;1c) Inside that directory, run &lt;i&gt;vside.enu.exe&lt;/i&gt; to launch the actual VS2 2008 Shell installer.&lt;/p&gt;&lt;p&gt;&lt;b&gt;2) Install F# CTP&lt;/b&gt;&lt;br&gt;2a) &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;amp;displaylang=en&amp;amp;tm"&gt;Download F# September 2008 Release Installer&lt;/a&gt; (InstallFSharp.msi)&lt;br&gt;2b) Run the F# September CTP Installer, the default settings work great. &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;3) Install VSLab&lt;/b&gt;&lt;br&gt;3a) &lt;a href="http://www.codeplex.com/vslab/Release/ProjectReleases.aspx?ReleaseId=15329"&gt;Download VSLab&lt;br&gt;&lt;/a&gt;3b) Run the VSLab Installer, the default settings work great here too.&lt;/p&gt;&lt;p&gt;&lt;b&gt;4) Install Managed Direct X&lt;/b&gt;&lt;br&gt;4a) &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=c1367bc3-4676-481a-bfaa-5c15d1d7199d&amp;amp;displaylang=en"&gt;Download the latest DirectX End-User Runtimes (August 2008)&lt;/a&gt;&lt;br&gt;4b) Run the installer to extract the DirectX End-User Runtimes to a temporary directory.&lt;br&gt;4c) Inside that directory, Run DXSETUP.exe to update your DirectX drivers.&lt;br&gt;&lt;/p&gt;&lt;p&gt;You now have a complete VSLab installation.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Quick Start Information&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1) First off, launch Visual Studio 2008 to get started. &lt;br&gt;2) Go to File-&amp;gt;New-&amp;gt;Project&lt;br&gt;3) Select Project Type: Visual F# and the VSLab Template&lt;br&gt;4) Hit Shift+Alt+V To activate the VSLab Interface&lt;br&gt;5) Right Click on your project and Click Add-&amp;gt;New Item&lt;br&gt;6) On the left select the VSLab Category and Select the a the Viewer3D template.&lt;/p&gt;&lt;p&gt;Select all of the code before the calls to Close() and hit Alt-Enter to execute.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.atalasoft.com/cs/blogs/rickm/attachment/15531.ashx"&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The real version is even animated.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Congratulations, you are now all set up to play with VSLab and F#. &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Keys: &lt;/b&gt;&lt;br&gt;Shift+Alt+V: Starts The VSLab Interface&lt;br&gt;Alt-Enter: Send selected code to the F# interactive tool window&lt;a href="http://cvslab.di.unipi.it/vslab/blog/page/Visual-Tutorial.aspx"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;References: &lt;/b&gt;&lt;a href="http://cvslab.di.unipi.it/vslab/blog/page/Visual-Tutorial.aspx"&gt;&lt;br&gt;The VSLab Tutorial&lt;/a&gt; is a great resource but has not yet been updated for the new VSLab release. Note that the key bindings have changed as mentioned above and keep an eye on the &lt;a href="http://cvslab.di.unipi.it/vslab/blog/"&gt;VSLab Blog&lt;/a&gt; for updates.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;edit: fixed a link and added a picture from VSLab. &lt;br&gt;&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;;subject=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx&amp;amp;;title=How+to+set+up+your+own+free+VSLab-based+Matlab%2fMathematica+replacement&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/09/08/how-to-quickly-set-up-your-own-vslab-based-free-matlab-mathematica-replacement.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15531" width="1" height="1"&gt;</description><enclosure url="http://www.atalasoft.com/cs/blogs/rickm/attachment/15531.ashx" length="26076" type="image/png" /><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/functional/default.aspx">functional</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Debugger/default.aspx">Debugger</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/microsoft+research/default.aspx">microsoft research</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Visual+Studio+Shell/default.aspx">Visual Studio Shell</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/VSLab/default.aspx">VSLab</category></item></channel></rss>