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 performing floating point operations on matrices, they’re specialized hardware that allow you to perform matrix operations in a highly parallel way. The DirectX runtime takes advantage of this to perform the operations need to for 3D shading. However, there are other algorithms that could benefit from being run on the GPU and Accelerator opens up the GPU for just about any algorithm that you can imagine.

 

The usage I demonstrated was the game of life running either on the CPU or with the calculations performed on the GPU. On my current machine this yields a 10 fold increase in execution time. It takes advantage of F# quotations system (similar to C#’s expression trees), these are used to allow you to compile an algorithm in F# to operations that the Accelerator runtime understands. This is how we can easily show an algorithm running on the CPU and then switch it to the GPU. The slides can be found here and code examples here. The example comes from Tomáš Petříček’s web site and more details can be found about in this series of articles.

 

I had several people come and access me for more information about Accelerator at the end of the talk. Accelerator v2 is available from Microsoft connected, here. It’s currently licensed under a restrictive MSR license that stipulates non-commercial use only. However, in stating the objectives of their project, they say “Accelerator v2 is an MSR incubation project whose goal is to validate the architecture and API approach with high quality engineering sufficient to gather real-world usage data.” It would seem to me that in order to achieve this objective they would need to have some commercial users, so maybe if you contact the team directly they would be able to get you a less restrictive license. I certainly have a project in mind for accelerator, though at this point it would be non-commercial. If you’re interested check out activity on my github account, you can probably guess what my idea is.

 

The slides can be found here and the code can be found here. The session was videoed, I’ll let you know as soon as it’s on line.

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 probably usable for a project with simple data access needs. Obviously you need to ready to put up with some teething problems and there will definitely be some breaking changes as the project evolves.

 

The project uses Mercurial for source control and is hosted at bitbucket.org, but don’t need to install Mercurial to use it, you can download the zipped source here: http://bitbucket.org/robertpi/functionalnhibernate/downloads/

 

I’ve licensed it under a simple BSD like license: http://bitbucket.org/robertpi/functionalnhibernate/src/tip/LICENSE.txt

 

I’ve also created a google group for announcements, discussions and questions about the project:
http://groups.google.com/group/functionalnhibernate

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 FluentNHibernate works with C#’s expression trees, it would be nice use F#’s quotation system instead.

Record types are a fixed collection of names and fields a lot like the row in a database. Below shows a record type we’d like to be able to store in a database table. Here we show an invoice record type that we’d like to serialize in the database.

Record type 

What we’d like to be able to write is a mapping class that describes how it should be serialized, like you can do in FluentNHibernate:

functional nhibernate mapping 

The idea of FunctionalNHibernate is to provide a layer to do just this. As you see we provide a neat way to describe the mappings. We achieve the record serialization by providing a custom tupilizer for F# record types. There’s also the start of a wrapper for the SessionFactory that will hopefully allow you to store and retrieve data in way more natural for F#.

The idea of this project is not to detract from FluentNHibernate, it’s a great project and works really nicely from C#. I want to provide something that will work equally well from F#. We’re a long way behind them and to be honest the project isn’t really usable yet. I have project in mind that I want to use it on, so hopefully I’ll be able to improve it as I go along.

The result is you can now write the following program to store, update and retrieve our invoice record type:

fun nhibernate program 

The project is hosted on bitbucket.org, where you can explore or download the code. Feel free to drop me a line if you want to help out.

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 with the addition of “Asynchronous Workflows” to F# and “Parallel Fx” to the .NET framework itself I believe F# has a lot more to offer in this area that it did when “Foundation of F#” was release. I’ve also split the chapter on Language Oriented Programming into too chapters, one on Language Oriented Programming itself and the other on parsing text. This reflects my belief that combinator libraries are the most important part of Language Oriented Programming. Other than 3 chapter, the one that introduces functional programming, has been heavily rewritten and is now much more organized. I also believe the organization of the book as whole has been improved as has the quality of the code in the examples. All the examples can be downloaded from codeplex, so there’s no need to type them out!

 

Here’s a picture of me clutching it proudly:

Robert Pickering and Beginning F# book

I’ve also decided to experiment with selling direct so if you’d like a copy you can buy it on ebay here. Just 10 copies available, for now, but maybe more will follow. Can’t promise the same delivery speed as amazon but I will write a dedication if you want.

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 this nice run down of the day. Keep an eye on http://functionalpx.ning.com/ for the videos, but I’ll also be posting a notice here.

 

We’ve already talked about do it again next year, so keep an eye on this space for more infomation.

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 of ValTech

... with more exciting speakers to be announced soon!

Book before 30th October and you’ll be able to register for just £25, places are limited to just 125 delegates to sign up quickly for what should be an interesting, informative and fun day out of the office.

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.

 the twites

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 uses .NET 3.5, F#, and WPF, if you’re running vista or win7 it’ll probably work okay out of the box, any other else and you’ll need install .NET 3.5 etc. Caveat: if you have more than about 50 friends (people you follow) it’s unlike to be able to map them all at once, first there’s the twitter API limits, then there’s the fact the algorithm is exponentially expensive in processing time and also you just won’t be able to find them on the screen. I may consider doing a Silverlight port, if it becomes popular, to make it more accessible. The main idea of the app is to show off some of Collective Intelligence work, this app is another example of hierarchical clustering and also uses optimization. There’s also some interesting use of async workflows. If you want to try the source it’s available on git hub. I've lots of ideas for future version - but not much time to develop them. Licence is GPL 2.0, if you'd like that to change, lobby me. If you like it let me know!

UPDATE: The download was broken because of a missing dll, this is fixed now. Thanks to @samjiman for noticing.

Links

 Subscribe in a reader
Twitter Follow me on Twitter
FaceBook View my Facebook
LinkedIn View my LinkedIn Profile Viadeo Viadeo Profile (Français)

Badges


Progressive .NET Tutorials 2009

Disclaimer

The views expressed on this weblog are mine and do not necessarily reflect the views of my employer.

All postings are provided "AS IS" with no warranties, and confer no rights.

www.flickr.com
This is a Flickr badge showing public photos and videos from Robert Pickering. Make your own badge here.