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.

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 Luke gave a peak behind the scenes of how you run a major F# project - the productization.

http://www.langnetsymposium.com/2009/talks/25-LukeHoban-FSharpProductization.html

Amanda Laucher on F# Concurrency: This a very interesting talk from the charismatic Amanda “Pandamonial” Laucher. Amanda presents a case study of a real world project she’s been working on in the insurance domain. Her mission was to use the concurrency features of F# speed up the companies risk calculations, and the results she achieved are quite amazing. She presents what I see as very compelling reasons for using F#:

http://www.langnetsymposium.com/2009/talks/21-AmanderLauter-FSharpConcurrency.html

Of course I can’t not mention the “Language Oriented Programming in F#” talk by Roger Castillo at Lang.net’s sister event “DslDevCon”. I was briefly involved with the organization of this talk, though to be fair it was Chance Coble and Roger who did the hard work. I was hoping to make it to the event to co-present the talk, but alas, Paris is a long way from Seattle:

http://msdn.microsoft.com/en-us/oslo/dd727739.aspx

Other note worthy videos are Luke Hoban on F#, who makes some very interesting points about how F# programming differs from programming in C#. I like this video because it builds on what Brian McNamara said in this blog post.

Phil Trelford, did a nice session for the skillsmatter.com guys and gals, and also has another planned.

There’s also this series of 4 web casts from Tomáš Petříček, which to be honest I haven’t had chance to watch yet, but knowing Tomas’ work I’m sure they’ll be very high quality.

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 working on CI project for a while now, but will pick it up sooner or later. I’ve also been talking to Matthew Podywsocki, Joel Pobar, and a few others, who have similar interests in F# and CI, if you’re interested in contributing please contact me)

I was also lucky enough to be invited by Scott Bellware to give a tutorial at the “Progressive .NET Tutorials” at London, in partnership with skillsmatter.com. The podcast of this tutorial is now available on line, but its 3 hours long so not really for one sitting! The code form the tutorials in available here.

I currently have no concrete future speaking engagements, but have a few things in the offing. Feel free to contact me if you’d like me to present or run a tutorial for you.

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

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.