F# updates

What is object oriented programming really all about?

People often ask me what functional programming is all about and why is it useful. In an attempt to answer this question in a way that is relevant to object oriented programmers it struck me it might be useful to look at what people find useful in modern object oriented programming. Once we know what programmers like about OOP, specifically what problems it helps them solve that structured programming didn’t, we can look again at FP and look at how it approaches these problems. While we could fall back on a traditional definition of what OOP is all about,...

My Talks in London: The F# User Group & At Progressive.NET

I’ve been in London for the past few days. I arrived Tuesday afternoon and gave at talk at “The F#unctional Londoners Meetup Group” on the Tuesday evening. The talk was entitled “Using Language Oriented Programming to Execute Computations on the GPU” and thanks to the efficiency of the good folks at Skills Matter the talk is already available on line. The event was very well attended, with around 50 people turning up. The talk covers more the Language Oriented Programming aspects than the knitty gritty details for detailing with the GPU and the audience seemed to enjoy it. It was...

Strings and F# Immutable Lists

In .NET strings are immutable. I think most .NET programmers agree that this is a good thing, as it generally makes code that works with strings safer and more predictable. However, operations that involve large amounts of string manipulation perform poorly because each time a string concatenation occurs then both strings must be copied. His often leads people to believe that all immutable objects will perform poorly. 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...

#Develop, F# and Google Summer of Code

A few days ago Chris Wille, the man behind #Develop contacted me to say that #Develop had been accepted on the Google summer of code scheme. Essentially Google summer of code means that Google will pay CS students to spend their summer writing code for open source projects. Chris told me one area they are interested in extending is the F# integration into #Develop; particularly they’d like to get the auto-completion working. So if you’re a CS student on the lookout for a summer job, you could end up being paid by Google to work on F#! Contact me if you...

Beginning F# Workshop and Progressive.Net

I’ll in London on the 10th/11th May giving a two day course entitle “Beginning F# Workshop” in conjunction with the lovely folks at Skills Matter. I think I give a fairly good description of the course on the workshop webpage, so I wanted to use this blog post to talk about why you would want to attend. I believe, as I stated in my book, that functional programming will be the next big wave in programming, and that F# will be one of the languages at the forefront of this functional programming renaissance. I don’t believe this will be sole...

My Talk with Don and Adam at TechDays 2010

It was TechDays this week and I was lucky enough to be invited to speak with Don Syme and Adam Granicz. Don gave a short introduction to mailboxes/agent programming in F# and Adam gave an introduction to IntelliFactory’s WebSharper project.   My section of the talk was on using F# with Microsoft Accelerator. Accelerator is an interesting product, it allows you to take advance of the GPU of your PC. Even the most basic PCs have a specialized graphics chip and for most of the tasks you perform on your PC it just sits there doing nothing. GPU are very good at...

FunctionalNHibernate: RCed and now with added build server

I’m very happy to announce that FunctionalNHibernate has now been updated to work with the recently released Visual Studio 2010 release candidate. Also, it has now been setup to run on the codebetter build server. You can create a log on and download the latest binaries from here (you need an account but it’s very simple to create one).   A huge thanks to Steffen Forkmann, who did the work to get this set up.

Functional Programming eXchange: The Videos

I’ve recently noticed that talks from Functional Programming eXchange, that I organized and spoke at, are now online. This is a great resource for people looking for some more advanced material on Functional Programming. So here are the videos:   SADEK DROBI: Computation Abstraction http://skillsmatter.com/podcast/cloud-grid/computation-abstraction   MATTHEW SACKMAN: Supercharged Rabbit: Resource Management at High Speed in Erlang http://skillsmatter.com/podcast/cloud-grid/supercharged-rabbit-resource-management-at-high-speed-in-erlang   ANTON SCHWAIGHOFER: F# and Units-of-measure for Technical Computing http://skillsmatter.com/podcast/cloud-grid/f-and-units-of-measure-for-technical-computing   GANESH SITTAMPALAM: Functional Programming for Quantitative Modeling at Credit Suisse http://skillsmatter.com/podcast/cloud-grid/functional-programming-for-quantitative-modelling-at-credit-suisse   DUNCAN COUTTS: Strong Types and Pure Functions http://skillsmatter.com/podcast/cloud-grid/strong-types-and-pure-functions   ROBERT PICKERING: Combinators, DSLs, HTML and F# http://skillsmatter.com/podcast/design-architecture/using-combinators-to-tackle-the-html-rendering-problem

Update about FunctionalNHibernate

I’ve been working quite a lot on the FunctionalNHibernate project recently. I’ve implemented the following features: - Save records with native F# lists. - Create one-to-many and many-to-many relations - Generate identities automatically   We can now do just about everything you the FluentNHibernate first example project does, although admittedly this is just a very small subset of what one can do with FluentNHibernate  and NHibernate itself.     In the future I’ll be looking at how to broadening what you can do with FunctionalNHibernate ClassMap descriptions and improve data access by integrating Linq like features.   In terms of usability, it’s still early days but I think it’s...

Introducing FunctionalNHibernate

It’s already fairly well documented that F# doesn’t play too well with NHibernate and Fluent NHibernate, although you can make it play a littler nice with a bit of effort. However there are a few fundamental problems with this approach. The first is F# class’ are not really designed to be data containers because that’s what its record type is for. The second is that F# class’ do not put too much emphasis on virtual methods as in functional programming we tend to using pass functions as values as a way to achieve polymorphism rather than virtual methods. Third and finally...

Beginning F# is here!

This morning there was an unexpected knock at the door and a courier arrived with a large package. I was quite surprised as hadn’t ordered anything. It turned out that it was my box of author copies of “Beginning F#”. So I’m happy to announce that “Beginning F#” is finally here and if you’ve pre-ordered it will be with you shortly.   “Beginning F#” is the updated version of “Foundation of F#”, it shares very much the same structure but I has been completely updated for the VS 2010 release of F#. I’ve also added an extra chapter on parallel programming as...

Functional Programming eXchange 2009

The functional programming exchange in London last Monday (7th Dec) when off really smoothly. We had just over 50 people, mostly from the south east of England, but a few had travelled from places like Scotland, Brussels and Holland to see us. I’d like to say big thanks to all the speakers for providing interesting and thought provoking talks. So, thanks to Sadek, Matthew, Anton, Ganesh, and Duncan. Also, a big thanks to Skills Matter for providing the location, logistics, pizza and beer. Photos and video from the event should start appearing soon, in the meantime Mike Hadlow has provided...

Speaking Engagements in Paris in October/November 2009

UPDATE:The talk tonight (29 Oct) at Zenika has been postoned till November due to unforeseen circumstances. I'll let you know the exact date as soon as it is confirmed. My apologies for this. I’ll be doing a talk about functional programming in F# at Zenika, this Thursday, 29th October at 19h, as part of their community program. The talk will cover what functional programming is and how a language like F# is adapted to functional programming. I’ll also be doing a talk at Epita with Laurent Le Brun on 12th November for the students at this college.

Functional Programming eXchange - 7th December 2009

I’m very happy to announce the “Functional Programming eXchange” which will take place in London at Skills Mater head quarters on the 7th December. I’ve been involved in organizing a program which will cover F#, Erlang, Scala and Haskell. The program has been designed to interested both people actively involved in functional programming in industry and working programmers with an interest in functional programming would like to learn more about how they can use these two techniques in their day job. The program will include, me, as well as: Duncan Coutts of Well-Typed Ganesh Sittampalam of Credit Suisse Anton Schwaighofer of MSR Sadek Drobi...

The twits - Yet another Twitter app

Taking its name from twitter, with a large nod towards Roald Dahl's cautionary tale, the twits is a twitter app that lets you visualize you network of friends on twitter. It’s available to try here. Before we go any further you should know that this software is in alpha status, i.e. not for the fait hearted. Here’s an image of the results below.   As you can see it does a reasonable job of separating other developers I follow from people at the guardian I follow (the coloured lines & text are added afterwards). The app is designed to run local and...

Videos to Watch

So this blog has been quite lately, well it never was the most active in the world. Anyway the good news is there are lots of other good F# resources on the web at the moment. Particually Lang.NET was a great source of F# videos, I was there myself, but I’ve spoke with a few people who were, and indeed there they told me there was lots of interest in F#. A couple of videos I really liked were: Luke Hoban on F# Productization: This was an interesting talk, not because it when in depth into F# the language, but because...

Past Speaking engagements

Back in February this year I spoke at TechDays Paris 2009, I’ve always enjoyed TechDays Paris so a big thanks to Eric Mittelette and his team for inviting me to speak. Also, many thanks Julien Laugel who help me review the presentation slides and also shared some his experiences using F# with the audience. A screen cast of this presentation is now available. The slides for this presentation are available on the slideshare.net site and the code from the slides is available here, except from the collective intelligence part which is available in its github project. (aside: I’ve not been actively...

F# in Beta1 of Visual Studio 2010

F# is now available as part of the beta1 of Visual Studio 2010. I felt a strange sense of pride when I could select F# as the default language in Visual Studio: Find a summary of where to get it here: http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/release.aspx

“Beginning F#” is “Foundations of F# 2nd Edition”

A few people have noticed that a new book “Beginning F#” by me is available for pre-order on Amazon. I wanted to make it clear that this is the new title for the second edition of “Foundations of F#”. The publisher wanted the title change to make it clear that this was a complementary rather title to “Expert F#” rather than competing with it. It also reflects that during the rewrite that I’m focusing a lot on making the book more accessible to people with no functional programming experience.

Interesting performance Consequences of Seq.map

It’s fairly well know that Sequences or “seq”, the short hand for IEnumerable, are lazy. This has some interesting performance consequence I had not considered until recently. When we execute a line like: let lotsOfInts = Seq.map (fun x -> x + 1) (seq { 1 .. 1000000 }) The command executes almost instantaneously, despite the fact we’re creating a list of a million integers (Real: 00:00:00.001, CPU: 00:00:00.000 on my PC).  This is because everything is lazy; no actual work is done till the list is enumerated. Executing a command like: let lotsOfInts' = List.of_seq lotsOfInts Takes a significant amount of time...

Progress on the “DataTools” Project

I note on in a previous blog post that I’ve started creating an open source project for manipulating data. For the moment it’s mainly based around the idea of “Collective Intelligence”, but I hope to draw on influences from other sources as it evolves. I’ve reorganised the source so it’s a bit clearer and added some other concepts, notably a tool for accessing books from “Project Guttenberg” and the work I did on generic algorithms. For the moment it’s licensed under GPLv2. I’m not a licensing expert but I believe this gives protection to the source while allowing it to remain...

Collective Intelligence and the Guardian Data-Store

I’ve been interested in collective intelligence and machine learning for a while now. These too related fields centre round using statistical tools on large sets of data to make measurements and predictions. So when the UK’s Guardian newspaper announced their “Data-store”, a collection of data set open to the public I felt it was time to apply some of what I’ve learned to the data they were offer. I choose to apply hierarchal clustering to the data on world health. The idea of hierarchal clustering is to measure how similar data sets are then pair off the similar data sets to build a...

Feature Speaking Engagement – F# Tutorial at the Progressive .NET Tutorials, May 11-13th, London

I will be giving a half day F# tutorial at the “Progressive .NET Tutorials” organised by Skills Matter. This will be an excellent 3 daylong event with 2 tracks featuring half day and full day Tutorials by Gojko Adzic, David Laribee, Hammet, Ian Cooper, Mike Hadlow, Scott Belware and Sebastien Lambla. My will be giving a half day tutorial on Wednesday May 13th (the last day of the event). I will be presenting 'F# Tutorial ', which will aim to give delegates the building blocks for using F# productively and to start having fun with it. For the full programme...

ALTi

(Sorry I’ve been a bit quiet recently; this is the first of several posts I’ll be making this morning) I decided a little while ago that I’d like to change direction in my career and go back to consulting, after interviewing around a bit I decided to join ALTi. It was my first day on Monday, and so far I’m enjoying my first week, although obviously I’m just getting settled in. The thing I like most about the company so far is that they seem quite open to suggestions and seem will to let you develop your career in the direction...

Foundations of F# - Second Edition

I’m very pleased to announce I’ve started working on a second edition of Foundations of F#. The aim is to document the language in the form it will be in when it is released in with Visual Studio 2010. This will be a challenge since it’s not yet known exactly what features will be in the final release. So, why a second edition? It’s true that the original book is only about 2 years old, but that’s quite a long time in the IT industry these days and much has change in the F# landscape since the original was wrote and...

How to Recognise Code Constructs (from quite a long way away)

No. 1 the Foreach Loop Last weekend I attended JB Evian’s code camp in the l’Ardeche département in the south of France, just to the north of the Provence region that forms the south east part of the French Mediterranean coast. (I was very interested in visiting this area since my wife and I became begin fans of Nigel Farrell’s “A Place in the France”  and  “A Place in the France – Indian Summer” when we first move to France, Nigel’s problems seem to dwarf any we had and helped put things in perspective). Anyway the aim of the project was to create...

Solvers, Optimization, and more on DSLs

To coincide with the release the CTP release of F# Microsoft also released and early version “Solver Foundation”. Don Box described himself as being elated by its release. You can tell it’s an early version as it’s currently the only way to get it is part of “F# Optimization Modelling Language” sample on the MSDN code gallery. So what does optimization mean in this context? Simply put an optimization problem is the problem of finding the best solution from all feasible solutions. Or (slightly) more formally: Given a function “f” which takes a value from set “A” and transforms it to...

F# on dotnetrocks! - My Thoughts on the Show

F# is on dotnetrocks again, this time it’s Amanda Laucher and Ted Neward’s turn to talk F# with Carl and Richard. I have to say of all the F# podcast there have been so far this is my favourite. Why? Amanda and Ted do a really great job of articulating what I’ve been thinking about F#, and functional programming in general, for some time now. I think this is because Amanda and Ted have a similar background to me – they both come from the world of line of business applications. This is interesting because if you read the marketing...

Genetic Programming – A Language Oriented Programming Example

As mentioned in my previous post, I’ve been reading “Collective Intelligence” by Toby Segaram and I’m really enjoying in it. It’s different to a lot of programming books, in that rather than focusing a specific language or API it focus on a particular set of problems and shows techniques that can be used to crack them. For example I’ve known for a long time that it’s easy to create an abstract syntax tree (AST) in F#: /// Untyped expression tree type Expression =     | Multiply of Expression * Expression     | Add of Expression * Expression     | Subtract of Expression * Expression     | GreaterThan...

F# T-Shirt Update

Well the F# T-shirt I ordered arrived last Thursday, meaning it took about a week or so after ordering: If you want to see me in it then you’ll have to wait for pictures of alt.net London (yes I know you probably can control yourself for that long).

What I’ve Been Doing

Now that the F# CTP is out, you may be wondering what I think of it. Well I’m planning to tell you in a later post, first let me explain what I’ve been up to: If you’re a follower of this blog you’ve probably noticed that there hasn’t been a lot of activity lately (apart from the short announcement about JAOO.dk). This is largely due to the fact I’ve moved house and have been doing a lot of gardening and DIY lately. I haven’t been entirely slack on the code front, I’ve started a couple of new projects, which probably deserve...

F# T-Shirts

As mentioned previously I’ll be attending a couple of conferences soon and mainly inspired by Amanda Launcher’s F#TW t-shirt I decided to print up an F# t-shirt of my own. I had more ideas for designs that I could actually fit in my t-shirt draw, so I decided to make up a few designs and see if anyone else would like to buy them, you can see all the designs here. I’ve only just ordered my t-shirt and so I can’t vouch for the quality or service yet, but tshirtcity.com seems like a serious company and I’ll post an update...

JAOO.dk and ALT.NET UK Summer Conference

I’m very pleased to announce that I’ve been invited to speak at the JAOO conference in Aarhus, Denmark, 28th September till 3rd October. I’ll speak on 1st October and I’ll actually be at the conference 29th September till 1st October attending sessions. The title of my presentation is “Learning F# and the Functional Point of View” and you can see the full abstract here. I’m very pleased to have been invited to speak at conference were the other speakers include Martin Fowler, Anders Hejlsberg, and Erik Meijer, and I’m really looking forward to it. Feel free to drop me a...

Immutability and Concurrency – Part II – A Review of F#’s Immutable Data Structures

The first half of this series the accent is on immutable programming, because in the first part of the series we had an introduction to immutable data, and in this second part we’re going to look in depth at immutable programming possibilities, with the idea of show that this is actually not too different to what your used. Once we’ve conquered the immutability we’ll start to dig into the concurrency. The main idea behind this post is take a look at everything that makes working with immutable data bearable, even likable.   Expressions and Returning Multiple Values (a.k.a. Tuples) In F# everything is...

Immutability and Concurrency – Part I – Getting to Know Immutable Data Structures

When asking the question how does functional programming help me with concurrent programming? The standard response tends to be functional programming use immutable data structures, read-only data structures can be shared between threads without issues, end of problem. Except it isn’t. Immutable data structures have a different set of problems associated with them when working on concurrent problems. This post will examine what these problems are, and then show that this is just a special case of a more general set of problems when working with immutable data structures. Finally will start taking a look at how we solve some...

Instrumentation of Your F# Applications with Custom Performance Counters

Although the performance counters built into the CLR give you a pretty good handle on what’s going, there’s nothing quite like having your own counters to help you monitor your applications performance. There’s nothing quite like being able to see your own counters alongside the build in ones in perfmon. There are several things that make this a little tricky, first you must install your counter to make it visible to perfmon, then you need to create instances of the counters for the application to use, finally you need to remove your counters when there done with to ensure old...

Ants everywhere! An ant colony simulation in F#

About a week ago Rick Minerich made this blog post about an ant colony simulation in F#. I downloaded the code and played with it, I liked the simulation a lot but wasn’t too keen on the implementation – it used lots of thread and lots of mutable data. So I decided to dig around a tweak a little here and there, but before I knew it I’d rewritten the whole thing using immutable data structures. I also end up breaking the thing and having to mail Rick for help about why it was broken, anyway with a little help...

Euler Project Problem 14 in F# - An exercise in optimization

Euler Project Problem 14 in F# - An exercise in optimization The coding “coding-experiments” blog presents two alterative solutions to the “Euler Project Problem 14” (http://projecteuler.net/print.php?id=14): http://coding-experiments.blogspot.com/2008/03/projecteulernet-problem-14-csharp-vs.html   His F# solution is around 55 times slower in than the C# version, the implication being that while F# is elegant, it’s also slow. My problem with this conjecture is that that the implementation of the F# version is considerably different to the implementation of the C# version. So lets have a look at the two different version, first the F#:     let seq_length n =         n |>         Seq.unfold(fun x ->                     match x...

Abstraction of Control Flow

One thing functional languages excel at is abstraction of control flow. Although you may not be familiar with the term, you’re probably already familiar with the concept. Programmers coming from an OO background are generally familiar with implementation polymorphism (overriding a method in a base class) and dependency injection (using an interface or base class to call methods an object, dynamically generated or otherwise); these are both forms of abstraction of control flow. They both allow the programmer to implicitly choose a different method to execute as long as that method conforms to some predefined signature. Let’s quickly remind ourselves...

F# Add-in Now Part of SharpDevelop 3.0 Beta 1

Lately I’ve been working on integrating F# into the open source IDE SharpDevelop. I’m pleased to announce that this has been released as part of SharpDevelop 3.0 beta 1. See the screen shots below to get an idea of the look and feel:     All you need to is install F# and install SharpDevelop and it all should just work - a big improvement on the old installation process. The integration is still far from finished, but I’ve been “dogfooding” away and feel I’m making pogress, expect to see more improvements in beta2!

TechEd Barcelona 2007 Video: Functional Programming Explained

Been a while since I posted anything, but I do have a few new ideas forming so keep watching! For now you can see me being interviewed in this Video filmed at TechEd Barcelona 2007 “Functional Programming Explained” (on the second page seems to be no way to do a direct link). I was very nervous before making the video and I think this show’s quite a bit at the beginning but I think I getting into my stride a bit more after a couple of questions. Having David McMahom as the interviewer really helped, he asked intelligent questions and...

F# at Microsoft TechDays Paris

I probably should have posted this a bit earlier but here goes anyway: I will be presenting at Microsoft TechDays Paris, my talk will be co-presented with Don Syme and we'll be talking about parallelism and F#. Don will also be presenting an introduction to F#. Don's talk is at 14:30 and our joint talk is at 17:30. Sign up for TechDays here: http://www.microsoft.com/france/mstechdays/ It's free and it's in central paris at the Palais des Congrès. Hope to see you there!

Concurrency in F# – Part IV – Queuing Working using Semaphores or Message Queues

In part three of this series we looked at how message queues could be used to receive updates from multiple threads and ensure that a data structure remain consistent. Now I would like to look at how messages queue can be used to spread work between different queues to allow it to the work to be performed in parallel. We will also look at an alternative mechanism of doing this using semaphores. To illustrate this we’re going to take another look at option pricing as we did in the “Recalculating Values Only When Dependencies Change” series. We’ll used the same simplified...

F# on InfoQ

I have written an article for InfoQ explaining the Active Patterns, a new feature of F# that didn't make it into "Foundations of F#". Read it here.

F# meets facebook

There’s a new place in town for you to geek out over F#, as well as the http://cs.hubfs.net new there’s also a face book group: http://www.facebook.com/group.php?gid=5394519167&ref=nf (Requires a facebook profile but seems everyone has one these days). The group was created by Joel Pobar.

Concurrency in F# – Part III – Erlang Style Message Passing

Why is the introduction of Erlang style message passing into F# interesting? Well you may have never heard of Erlang but if you’ve ever used a cell phone you’ve probably used an Erlang system. Erlang was originally built by Ericsson and released as open source in 1998, it was built to support the highly distributed and fault-tolerant systems required to support mobile phone networks. Many people consider Erlang to be the language that gets concurrency right. So if you want to do concurrency why not just use Erlang? Well the fact that Erlang is built on its own custom runtime means...

Somasegar Announces Productization of F#

Somasegar, the head of the Developer Division at Microsoft, has announced the productization of F#. Read more about it here.

Concurrency in F# - Understanding how Asynchronous Workflows Work

As Don Syme points out in his piece on asynchronous workflows, they are not about getting the whole of concurrency right but rather about getting asynchronous I/O.  I think that to fully appreciate the beauty of asynchronous workflows one must understand the ugliness of what it’s like to do asynchronous I/O without them. I think this may be true for many areas of software development,  hell even good old C looks great if you’ve been forced to spend some time assembler, and I guess Joel and his law of “leaky abstractions” is saying something along a similar lines. So I...

Concurrency in F# – Part I – The Asynchronous Workflow

So I was going to start this series with an over of concurrency options on the .NET framework, but after playing F# asynchronous workflows, I decided to blog about them as they just too exciting to keep quiet about. Maybe I’ll spin back at the end of the series and do a summary of other options at the end of the series. This post will look at how to use concurrent workflows; it will not look into the mechanics of workflows themselves, which are explained in this nice blog post from Don Syme. First we’ll walk though what you need to do...

F# @ TechEd Barcelona November 2007

There will be two F# presentations at TechEd Europe this year, one by Don Syme on concurrent programming in F#. See the full abstract below for more details Parallel and Asynchronous Functional Programming on .NET with F#    Functional programming a hot topic: there is a growing awareness of functional techniques in the developer community, and people are beginning to see that imperative OO programming has deep limitations in a networked and concurrent multi-core world. This session will use the research language F# to explore how declarative and functional techniques are relevant to these new programming challenges. F# includes constructs called asynchronous...

#Develop integration of F# - Alpha Release

[Update 05-09_2007: minor change to both source and binary release to fix F# interactive intergration, if you download a version before this date please redownload] Recently I’ve been working on integrating F# into #Develop. It’s a nice, well designed and developed platform, and despite one or two glitches integration has gone pretty quick. My aim is to get the F# made part of the #Develop distribution, but, rightly so, there are a couple of legal and quality hurdles that need to be reached before it can be integrated into their main release. I’m sure these hurdles will be over come soon,...

Recalculating Values Only When Dependencies Change – Part II – Testing the Frameworks

In part one we build a couple of simple frameworks that allow the programmer to specify that a value should be cached until one of its dependencies changed. I wanted to put these frameworks though their paces in a semi realistic environment. I decided to use the idea of pricing european options, since it’s similar to what we do at LexiFi, rather that work we the LexiFi pricer I took the simplest pricer I could find written in OCaml and adapted it to F# (this was hardly any work at all). I did this as I simply wanted the price...

F# MSBuild provider

I recently started working on the F# integration with #Develop. #Develop is a free and open source IDE base that in many respects is very similar to Visual Studio. I actually found getting the basic integration going fairly easy, I have something that allows you to edit text files and build them. But as there’s not yet any colouring or auto-completion there no signification advantage over using that to any other text editor, so I’m not going to release it just yet, but watch this space. However the first step in integrating F# into #Develop was to create an msbuild provider...

Recalculating Values Only When Dependencies Change

I had an interesting exchange of emails with a reader recently. They wanted to be able to execute a function and cache the result and revaluate the function only when one of the values in depends on changes. It’s a common enough problem I guess, but one that’s surprisingly tricky to get right. This is because when you evaluate a function it’s difficult to know what it depends on and therefore difficult to know when the results of the evaluation become dirty. But between we came up with two different approaches to this problem. The first approach was to reuse idea...

Me on Hanselminutes talking about F#

As promisted on yesterdays blog post you can listen to me talking about F# on Hansel Minutes: http://hanselminutes.com/default.aspx?showID=94 You may also want to take a look at this accompanying blog post about what we talked about on the show: http://strangelights.com/blog/archive/2007/08/09/1590.aspx Warning it may contain spoilers :)

Another Quality Radio Item

When I was doing my A-levels way back in 1997 I often used to stay up late to listen to the Mark Radcliff Show in its grave yard shift phase on Radio 1. One catch phrase that does seem to be completely covered in the catch phrase guide is a “Another Quality Radio Item” although in later versions of the show this was shorten to “Quality Item” and used to refer to any feature on the show, I believe its origins came from when Mark and Lard would invite some guest on the show and they would proceed to have...

F# versus IronPython

“Comparisons are odious” as my Mum used to say, but I hope this little comparison doesn’t pong too much. I have a range a little competitions of my own, a language bench mark, based on “The Computer Language Benchmarks Game” (http://shootout.alioth.debian.org), between IronPython and F#, with measurements for C# thrown in as a kind of control group. I would have liked to chuck in the new IronRuby language too, but I had problems finding a current release. This was largely inspired by the benchmarks Ben Jackson posted to the hubfs.net (http://cs.hubfs.net/forums/thread/3196.aspx), thanks Ben! Now obviously as an author of a book...

F# in MSDN Community Distribution June Release

I’ve just notice that the “MSDN Community Distribution June Release” has a video presentation about F#. An overview of all the CD: http://mosessaur.blogspot.com/2007/06/msdn-community-distribution-june.html Direct download link: http://www.microsoft.com/downloads/details.aspx?FamilyId=A65F7733-A626-4F69-86E8-0465FA5E4669&displaylang=en

Foundations of F# - Finally Here!

I recieved my copies of Foundation of F# today. Am I pleased about it? See for yourself:

Life, F# and Silverlight

As I alluded to in my earlier post I’ve wanted to find the time to write a longer post on developing Silverlight application. Using Silverlight is very straightforward and does actually require you to install anything other than F# and the Silverlight runtime. What out when installing the runtime, turn version are available confusingly name “1.0 beta” and “1.1 alpha”. It is the “1.1 alpha” version that you need as this the only one that includes the new version of the CLR, the dynamic language runtime or the “DLR” (not to be confused with the Docklands Light Rail). Once installed you...

Game of Life in Silverlight and F#

I’m too tired to write a proper blog post about this but I managed to port DonSyme’s Game of Life Demo that comes with the F# Distribution to Silverlight. It’s not a full port as there were some UI events that I couldn’t get to work for love nor money – I think these maybe bugs in Silverlight itself. However the game does look pretty cool. Also Silverlight currently has no way to marshal back to the UI thread which makes multithreading a bit difficult. The game was relatively simple to port, in fact I kept the first few files, “alg.fsi”,...

Foundations of F# - Announcement

I know I've been very quite here lately. The reason for this is I've spend a lot of time working on _the book_. Anyway, all thats nearly over now, so hopefully I can get back to being a bit more chatty. Anyway, here is the announcement that I've made just a few moments ago on the hubfs.net that says its almost finished printing: http://cs.hubfs.net/blogs/roberts_strange_f_blog/archive/2007/05/20/3153.aspx

ROT13 in F#

Over on his blog, Andrei Formiga has a series of post on implementing ROT13 in F# and Haskell. http://codemiscellany.blogspot.com/2006/12/rot13-in-f.html http://codemiscellany.blogspot.com/2006/12/rot13-in-haskell.html http://codemiscellany.blogspot.com/2006/12/rot13-in-f-revisited.html http://codemiscellany.blogspot.com/2006/12/still-more-rot13.html   I like is implementation using library functions that don’t yet exist in F#, such as drop and zip. Here is the implementation itself, stripped of the extra library functions he had to implement, for the original see the above links.   #light let rot13 s =     let letters = ['a' .. 'z']    let transp = zip letters ((drop 13 letters) @ (take 13 letters))    let rotchar c = List.assoc c transp    strmap rotchar s   The clever bit of...

Foundations of F#

Wow. Just seen that my book has been officially announced on my publisher’s, Apress, website. You can see the announcement for yourselves here. It is also available for pre-order on amazon.com.

Why I like functional programming: F#, Mandelbrot and more WPF

I was playing around with implementing drawing a Mandelbrot set in F#. F# makes this very easy because of its Microsoft.FSharp.Math namespace provides a very easy to use complex implementation which means you just need to type out the equation and viola you have the Mandelbrot set. Or so I thought. My implementation end up being about 40 lines about 11 of which were the equation on which the Mandelbrot set was based and the rest of the code was infrastructure to use the equation and display the results. While the resulting code, shown below, is still reasonably short this...

Free articles on F# on ASP Today

Although already spotted by optionsScalper here, I thought I’d mention this myself. Frank Antonsen a programmer from Copenhagen (one of my favorite cities) has written two articles which are available freely on ASP Today until 15th July. So hurry you still have time to read them freely.   The first article is a general introduction to F# and then the second digs a little deep into F# data types. Both are well written but I enjoyed part two more.   To read them you need to register, but this is...

Bending the Cat: F# meets WPF 3D

I’ve been playing with F# and Windows Presentation Foundation (WPF a.k.a Avalon) and the combination is really nice. WPF comes with a new(ish) markup language called Xaml. This is another declarative language that works in a complimentary way to F#. Xaml allows you initialise an object graph into a specific state in a declarative style; moreover various designers will soon be come available to do this, so you won’t even have to hand code the Xaml file. You can then load the xaml file and use F# to tweak resulting images.   I have written...

C# style continuations in F# - yet another Fibonacci implementation

F# does not get support C# style continuations yet; I am reliably informed that it will do at some point.   However if you can not wait that long it is already fair easy to get C# style continuations by implementing System.Collections.Generic.IEmunerable your self. What’s more this can be implemented as a library function then implementing your enumerator becomes just a couple of lines of code.   Here is my implementation:   module Strangelights.Continuations   open System open System.Collections open System.Collections.Generic   // This function makes an IEnumerable interface from // a mutable value "n" and a function "f" that takes unit and // returns a...

Alois Kraus on F#

Alois Kraus just made this nice post about functional programming in F# and C#. I enjoyed the article very much and he even bigs up one of my own posts, which of course tickled me.   However, I disagree with quite a lot of what he said in his conclusion paragraph. He writes:   “Not all concepts of functional languages should be explored by Mort and Elvis since most of them are fairly complex to understand because functional languages are very picky (just like unix) who can be their friend and who not. If Einstein does write...

A simple parser in F#

It’s a lovely evening here in Brussels and I am sitting on my balcony, I think summer might have finally arrived, except every time I think that we get two days of clouds and rain. The only problem with this is below are two restaurants with out terraces who have plenty of customers, the only problem with this is the smell drifts up into my apartment makes me hungry.   Anyway I have been neglecting my blog lately, there is a reason for this, but nether the...

New F# hub

It seems there is a new F# hug in town; I will of course be signing up, why don’t you too? http://cs.hubfs.net  

Forwards is the new backwards with the |> operator

Recently Don Syme made a post to the F# mailing list about some proposed changes to the F# libraries. In it talked about the virtues of using the new |> operator, sighting the following example as something it would be difficult without it:   let methods = System.AppDomain.CurrentDomain.GetAssemblies()             |> List.of_array |> List.map ( fun assm -> assm.GetTypes() ) |> Array.concat             |> List.of_array |> List.map ( fun t -> t.GetMethods() ) |> Array.concat   After squinting at it for a while I realised that I didn’t really understand what the sample was doing, let alone see the advantage...

Rico Mariani’s performance quiz 8 – Part 2 – The Great Parsers Shoot Out

Rico made some more interesting posts in his parser performance quiz, first producing a parser where the predicates are compiled into an in memory representation and also a parser where he produces IL on the fly. He talks about them here and here respectively.   So I ported both of these parsers to F#; as they demonstrate some nice uses of patterns commonly used in ML, such as take one data structure that is easy to read and transforming it into another than is easy to evaluate. This gives us 6 parsers in total, so...

A little too lazy

Last night I too another look at my parser and unfortunately discovered some quite serious flaws in the algorithm, it was just too lazy and almost always terminated before it should. To fix these I basically ended up starting from scratch, I’ve reloaded the results. I’ll be tidying it up and talking about what went wrong as part of a wider comparison of all 3 parsers.

Rico Mariani’s performance quiz 8 - Parsers

The snow is falling over Saint Germain en Laye and it makes everything look really pretty, but I have absolutely no whish to go outside, so I sit in the flat and what it fall and write this blog entry instead.   I’ve been following Rico Mariani’s performance quizzes for a while now and always found them interesting. The latest quiz on the performance of a parse, reminded me of a famous CS quote that every large software project has badly implement lisp engine in it. However I know little about lisp so I thought...

F# docs

As noted here and here I have created some documents for F# using NDoc and the xml files that are available on with the F# download. There still in "beta" phase as I'll be making refinements such as search engine optimisations, as well as a build in search, but you may already find them useful. Enjoy!

AsssmeblyExplorer : Reloaded

I recently started measuring what gets downloaded and this made me noticed that my AssemblyExplorer tool is still very popular. I found this a little strange as its hopeless out of date. Also, why wouldn't you just use reflector Anyway as it was popular I decided I’d revamp it, and sat down to do just that this morning. I successful completed the first stage of things, it now it works with the latest version of F# and AbsIl.   Updating it was a bit of a strange experience, the design of the application is a little odd...

F# and LINQ

If you take a look under the hood at the new System.Query name space you will see that the core of it is located in the “Sequence” class and this class bears an amazing resemblance to the F# List library located in the MLLib.dll. Okay you have to use your imagination a tiny bit, but if you consider that:   System.Collections.Generic.IEnumberable<T>()   Is really not that different from:   Microsoft.FSharp.List<A>   Then you start to see that: val map: ('a -> 'b) -> 'a list -> 'b list // F# signature public static List<B> map<A, B>(FastFunc<A, B> f, List<A> x); // C#...

Aspf Demo

I have update the Aspf Demo so it now utilises F# 1.1 ablity to define classes. It now also inculdes a web serverice. Enjoy! http://www.strangelights.com/fsharp/AspfDemo/

Arg Parsing – The Chris Sells Challenge

A couple of days ago Chris Sells made this post about the way best to parse command line augments. Given an xml document describing the structure of a command line augment, he wants to know would it be best to use code gen or an interpreter to parse command line arguments. Here is the xml structure he was talking about.   <args description="Two wrongs don't make a right, but three lefts do">  <arg name="lefts" description="Number of left turns" type="int" default=4" />  <arg name="attitude" description="Driver attitude" required="true" type="string" /></args>   F# (and the ML languages in general) offers a...

Dynamic compilation, evaluation, and a console

A couple of weeks ago Don Box made a post about dynamic evaluation in C#. Since a console and dynamic evaluation are popular feature request for F# I decided to have ago at implementing this in F#. The results can be found here.   At the moment it’s pretty limited, you can just evaluate an express and the result will get thrown away, only values that are not functions will be evaluated properly, there’s no error handling and the printing of the output types is a little limited. It's only been tested with Framework 2.0,...

Continuation Style Passing

Don Box made another post on Continuations and Closures that made me realised I’d made a mistake in my last post. I had not used continuation; I merely used a closure that captured some mutable variables. Also F#/Caml does not have continuations in the same way Ruby does. F# does however have continuation style passing, also discussed in Mr. Box aforementioned post.   Anyway I thought I’d write a sort piece to show continuation style passing in action in F# , using my old favourite the Fibonacci series. Consider the following recursive code function that calculated the...

Don Box/Sam Ruby on Continuations

The ever charismatic Mr. Box made a lovely post about continuations in C# 2.0: http://pluralsight.com/blogs/dbox/archive/2005/04/17/7467.aspx   Because I have used a simpler Fibonacci implementation in couple of places, I thought I’d port it to F#.   Of course continuations are not a new idea; they have been used for a long time in ML style programming. The implementation is most like the continuations by anonymous methods, as anonymous methods work well in ML as they are very similar idea to lambdas.   Here is the source:     let fib() =       let i = ref 0 in       let j = ref...

F Sharp Wiki

I haven’t had a lot of time lately to update my FSharp site, as I’ve been very busy with at work. I thought it would be a neat idea if other people could update it too, so I have created the FSharpWiki. Have and look and remember YouAreEncouragedToChangeTheWiki.

Why Some/None is better than null

People interested in the advantages for F# might do well to take a look at F# option type. This allows an F# programmer to specify the presents or absence of some data much the same way a C# programmer might use a null reference.   Let us take a quick look at how you might use the option type. It is implemented as a discriminating union so can be investigated with F#’s pattern matching constructs.   let nodeText = match (get_single_node node “/fruit/apples”) with             | None -> “”             | Some node -> get_node_text node   If we imagine...

The Expressiveness of a Language

  People have been known to ask me, what makes F# better than C#? This is a since what people think is good or bad about a programming languages just comes down to taste. However Alejandro Serrano blog post about how an F# typeof operator can be defined got me thinking about things you can do in F# that you can in C#. In it he describes how you can define a typeof operator for F#, this is something you can not do it C# the type of function is build in to the...

Visual Studio intergration for F#

Don Syme recently made this post about adding IntelliSense to the visual studio intergration of F#. Although I do missing the <ctrl>-<space>, there are some nice features to the current version. In fact the back ground error checking is better that C# in both visual studio 2003 and 2005. The F# intergration will warn you if you are using an type that does not exists, C# will not do this.   This can be seen in the two images below, first the F#:   Then the C#, no warning here:  

Don Syme has started a blog

Don Syme, the creater of F#, has started a web log, it's part of the msdn blogs site http://blogs.msdn.com/dsyme. This is going to be one to watch if you any interest in F#.

Aspf Demo

I’ve create this demonstration of how to implement active server pages in F#. Hope you like it.   The rest of the site should  be getting an overhall soon.

Inferred type system

  A couple of days ago I was reading a post about dynamic languages (scripting languages with good PR) on lambda the ultimate. The author wrote “’strong’ typing is not the same as ‘explicit typing’”, which is very true and got me thinking about inferred type system, such as the one F# uses.   The big advantages is that doesn’t seem to be talked about much is that because in inferred type you don’t explicitly say what type an identifier is you get a lot more choice about what you compile it down to. This is...

Links update

There is a new version of F# coming, so I've started to revamp my site. I started slowly with a revamp of my links page. I think I now list just about everything google can find on the F# programming language.

Parser Library for F#

Dominic Cooney has create this parser library for F#.

Regular expression interpreter in F#

Domonic Cooney has published an interesting blog post on a regular expression interpreter in F#    

F# updates

I'll be noting all f# updates in my blog, so you can just subscribe to the "F# updates" feed and be automatically informed of any new F# updates. On a related note I've added 5 new tutorals to the f sharp site. A summary of these is available here.