MBrace, CloudFlows and FSharp.Data – data analysis made easy


In case you've not seen it before, MBrace is a simple programming model for scalable cloud data scripting and programming with .NET. It's written in F#, but has growing support for C# and VB .NET. Over the past year or so, I worked closely with the MBrace team to help get it working smoothly on … Continue reading MBrace, CloudFlows and FSharp.Data – data analysis made easy

F# Azure Storage Type Provider v1.0 released!


So, last week I finally released the F# Azure Storage Type Provider as v1! I learned a hell of a lot about writing Type Providers in F# as a result over the last few months... Anyway - v1.0 deals with Blobs and Tables; I'm hoping to integrate Queues and possibly Files in the future (the … Continue reading F# Azure Storage Type Provider v1.0 released!

Debunking the LINQ “magic” myth again


I’ve blogged before about how LINQ-to-Objects, at it’s most basic, is just about building on top of enumerating, one at a time, over collections via MoveNext(). It wraps it up in a beautiful API, but it’s still generally crawling through collections. I wanted to give an example of this in more depth and how the … Continue reading Debunking the LINQ “magic” myth again

Interesting use of declarative coding


Having been using LINQ since it first came out, I feel that I’m only now starting to really appreciate some of the applications for declarative coding. When I first heard about it, I was pretty sceptical about it, but I’m actually becoming a pretty big fan of it now. Here’s an example that I thought about a few days ago. Someone asked me to write some code that would print out the first five answers of the first five times’ tables e.g. 1 x 1 = 1, 1 x 2 = 2, 1 x 3 = 3, 1 x 4 = 4, 1 x 5 = 5 2 x 1 = 2, 2 x 2 = 4, 2 x 3 = 6, 2 x 4 = 8, 2 x 5 = 10 etc. etc. I actually initially thought “let’s do this with LINQ” but on the spur of the moment went back to my imperative coding roots and fumbled around with a couple of nested for loops… it probably ended up looking something like this: (Imagine that limit is a const int of 5) for (int outer = 1; outer <= limit; outer++) { for (int inner = 1; inner Console.WriteLine (text)) : () => Console.Write (text) }; foreach (var number in numbers) number.Print (); I’m not sure whether I like this or not – in some ways it’s quite elegant, but the amount of code has risen again, plus I’m not sure whether the practice creating anonymous methods as a result of a conditional, as a property of an anonymous type is really that great an idea vis a vis readability or not 🙂

Using LINQ queries instead of “for” loops


LINQ can easily replace for each loops, but when it comes to replacing old-style for loops, it’s a bit trickier – what exactly are you enumerating over? Nothing but a fictional set of integers. Luckily the System.Linq.Enumerable namespace comes with a handy static method for just such these occasions. Consider the following code: - var list = new List (); for (int i = 0; i < 10; i++) list.Add (i * i); You can actually easily rewrite this as a LINQ query like so: - var list = from i in System.Linq.Enumerable.Range (0, 9) select i * i; The Range () method generates an IEnumerable collection of sequential numbers as per the parameters passed in from which you can select data over. I think it’s very nice 🙂