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
Using Aggregate in LINQ
The System.Linq namespace has a load of useful extension methods like Where, Select etc. etc. that allow us to chain up bits of code that operate over sequences of data, allowing us to apply functional-style programming to our data. There is one method which is often overlooked yet it is probably the one that lends … Continue reading Using Aggregate in LINQ
LINQ in C#2
Introduction Continuing my series of posts on LINQ, I wanted to give a simple example as to how one can get the same sort of functionality in terms of query composition and lazy evaluation by using the yield keyword and without using any of C#3’s features. Bear in mind that LINQ was introduced as part … Continue reading LINQ in C#2
Psychic LINQ
A relatively short post on cargo cult programming, particularly related to LINQ. LINQ is a fantastic technology. The idea of making a platform-agnostic query language is a fantastic idea. You can write the same query, in C#, over an in-memory list or a database and from the client point of view treat it in the … Continue reading Psychic LINQ
Let there be LINQ
Just a quick post regarding use of the let keyword in LINQ, which I find to be somewhat under-used by many people. Whilst one benefit of it can be readability (i.e. aliasing sections of complex queries to aid understanding of the query), the other benefit can be performance. There is indeed a cost associated with … Continue reading Let there be LINQ
Trying out RavenDB
I came across this the other day and decided to give it a whirl. My initial experiences have been generally quite positive. I’m sure that the official site can explain it much better than I can but essentially RavenDB is different from a regular relational database in that there are no “tables” as such. Instead, … Continue reading Trying out RavenDB
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 🙂