Learn F# at TechMesh and SkillsMetter
Autumn is a busy period and I already invited you to a couple of interesting events, but there are two more events that you definitely should not miss. In only two weeks, you can come to two-day Progressive F# Tutorials packed with tutorials for both F# beginners and experts. At the beginning of December, the TechMesh Conference comes with three days of talks about alternative (and future) technologies.
I'll be speaking at both Progressive F# Tutorials and TechMesh and I'm also doing a tutorial at TechMesh, so if you want to learn about F#, type providers in F# 3.0 and financial computing with F#, here are some talks that you should not miss...
F# Courses and Talks for Autumn 2012 (I.)
Similarly to the last year, I already have a number of F# events planned for the end of the summer and autumn that I'd like to invite you to!
The Visual Studio 2012 has been completed recently and it comes with F# 3.0. For me, this means two things. Firstly, it is the second Visual Studio version of F#, which means that functional programming is worth taking seriously. Secondly, F# 3.0 comes with type providers, which is a killer feature for working with data. No matter if you're a C# programmer now to functional programming or if you're an F# user in the real-world, I hope you can find some interesting and useful event below!
The two main things that I'm going to be involved in are SkilsMatter trainings in London and New York and a few events at the biggest functional conference (ICFP) in Copenhagen...
Asynchronous client/server in F# (QCon 2012)
Last week, I gave a talk on asynchronous programming in F# at London QCon 2012. The talk was a part of The Rise of Scala & Functional Programming track organized by Charles Humble. Reactive and asynchronous programming was a topic that was repeated a couple of times during the whole session - Sadek Drobi talked about non-blocking reactive web framework Play2 and Damien Katz talked about Erlang and CouchDB.
If you have been following my blog, you've probably already heard of joinads. It is a research extension of F# computation expressions (or monads in Haskell). The extension makes computation expressions more useful in domains like parallel, concurrent and reactive programming. However, it can be used for any type of computation including, for example, parsers. If you're interested in detailed description, you can find it in two academic papers that I blogged about previously: PADL 2011 and Haskell 2011.
The extension adds a keyword
match! - as the syntax suggests, it is akin to pattern
match, but instead of pattern matching on values, you can pattern match
on computations like
Async<'T> (or on other monadic values). Just like other features of
computation expressions, the
match! syntax is translated to applications of several
methods defined by the computation builder.
I won't say more about joinads in this post, because you can now easily try joinads yourself...
F# courses and talks (Autumn 2011)
The end of the summer holiday season is getting closer. Luckily, I was in Prague last week so I actually noticed there was summer this year!
After a few quiet months, the autumn is going to be quite busy. Microsoft's //build/ conference will reveal the future of software development for Windows, but great things are going on in the F# world too. Don Syme is going to talk about F# Information Rich Programming at Progressive F# Tutorials in November, which should reveal more about F# 3.0 and type providers!
I have quite a few speaking engagements planned already, so if you want to learn about functional programming in .NET (and become a better C# programmer) or about F# and asynchronous programming, here are a few events that you may be interested in...
Real-World F# Articles on MSDN
More than a year ago, Mike Stephens from Manning (who was also behind my Real-World Functional Programming book) asked me if I'd be interested in collaborating on a project for MSDN. The idea was to collaborate with Microsoft on creating some additional content for the official F# Documentation.
A few days ago, the new content appeared on MSDN, so I finally have an excuse for the recent lack of blogging! Although the content contains a large number of new articles that are not based on my book, you can find it in the MSDN section named after my book, right under Visual F#. If you can't wait to check it out, here are all the links:
- The Real-World Functional Programming section on MSDN.
- The source code for individual chapters is available on MSDN Code Gallery.
- I also published annotated TOC with source code links on my functional programming web site.
While working on the articles, I also wrote about a few topics that we didn't use in the final version. You'll see them on my blog in the next few days, as soon as I edit them into a blog post form. Continue reading for more information about individual chapters.
MonoDevelop & Teaching F# & QCon tutorial
Point of sale application from QCon tutorial
It appears that I have been doing a lot more talking than writing in the last two months. I'm hoping to change this direction and I have two articles almost ready, so stay tuned! I was also posting all my interesting F# snippets to fssnip.net, which has grown quite a bit since I announced it in the last blog post. Thanks to everybody who submitted their snippets already and I'm looking forward to more! By the way, you can now run snippets using tryfs.net by clicking at "Load in TryF#" button.
In the meantime, the queue with talk materials that I wanted to post on my blog has grown to 3. I talked about F# in MonoDevelop in the Mono room at FOSDEM in February, then I did an online talk for the Community for F# . Finally, this week, I did a tutorial on F# with Phil Trelford at QCon in London (to fill in for Michael Stal due to unexpected health reasons).
Before I move on to writing about my recent experiments with LINQ, you can find materials from all of the recent talks below...
Announcing F# snippets web site
When writing F# programs, I often write some nice code snippet or some useful helper function that I'd like to share with the F# community. Unfortunately, my blog posts are usually longer and more elaborate, so I never get to blogging about it. Now that I have a twitter (follow me if you don't already) I thought I could just post the snippet somewhere, but there was no good web site for posting F# snippets - until now!
- If you can't wait any further, then go directly to the new F# snippets web site at fssnip.net.
F# in Education & Concurrency with Agents
November was quite a busy month for me. First, I traveled to Cambridge (the "new one" in Massachusetts :-)) to present my work on the F# plugin for MonoDevelop at the F# in Education workshop. Shortly after getting back to London, I started working on a presentation about Concurrent Programming with Agents at the F#unctional Londoners meeting.
Now that both of the events are over, I'd like to write a short summary and also finally publish my slides and demos. In addition, both of the events were recorded (thanks to External Research group at MSR and SkillsMatter), so if you missed them, you can watch the recording...
Both of the events were really great and I had a chance to meet quite a few interesting people. One of the things that make F# great is the community around it. I think that one unique aspect of the F# community is its diversity. The same language is appealing to high school teachers, academics and researchers as well as software developers and technical directors from the industry. This combination is really valuable for both sides. It helps to transfer ideas from research to practice it gives researchers clear picture of problems in the industry that deserve their attention.
Reactive, parallel and concurrent programming in F# (PADL 2011)
Don Syme blogged about a paper on the F# Asynchrounous Programming Model that I helped to write. Without any doubt, the asynchronous programming features of F# are one of the reason for its success and also influence other teams in Microsoft. However, I'm very glad that there is now also an academic paper that makes this idea accessible to the academic community. I believe that the ideas could evolve in interesting ways when used in other programming languages and also, it is now easier to create research projects that build on top of the F# model.
Don already mentioned that we have another paper accepted at PADL. The paper describes work that started during my internship at Microsoft Research in 2009. It presents a simple language extension for computation expressions that makes them even more useful in some reactive, concurrent and parallel programming models. Note that this is only a research project and there are currently no plans to support the extension in the F# language (although, if there will, eventually, be an open-source F# release, then you'll hear about the extension again...)
Here is the abstract of the paper (accepted at PADL 2011) and a PDF download link:
Joinads: A retargetable control-flow construct for reactive, parallel and concurrent programming
Modern challenges led to a design of a wide range of programming models for reactive, parallel and concurrent programming, but these are often difficult to encode in general purpose languages. We present an abstract type of computations called joinads together with a syntactic language extension that aims to make it easier to use joinads in modern functional languages.
Our extension generalizes pattern matching to work on abstract computations. It keeps a familiar syntax and semantics of pattern matching making it easy to reason about code, even in a non-standard programming model. We demonstrate our extension using three important programming models – a reactive model based on events; a concurrent model based on join calculus and a parallel model using futures. All three models are implemented as libraries that benefit from our syntactic extension. This makes them easier to use and also opens space for exploring new useful programming models.
- Download the full text (PDF, pre-publication draft)
The paper can still be revised before the final publication, so any comments and suggestions for improvement are largely welcome. You can contact me either via comments (below) or using email at firstname.lastname@example.org. I would be also quite interested to hear from anybody who would like to implement similar feature in other programming languages (for example Haskell or Scala).
Recording and samples from my Reactive F# talk
Almost a week ago, I posted an invitation to my F# talk at the F#unctional Londoners user group. The theme of my talk was reactive programming, which was also a topic of my Master's thesis (defended earlier in June), so I really enjoyed talking about it. In the talk, I discussed the two approaches that you can use for developing reactive applications in F# (using examples in Silverlight):
- Declarative (or data-flow oriented) allows you to describe "what" should be
done with data that your component receives from various events (such as mouse position etc.) This can
be written using F# event combinators such as
- Imperative (or control-flow oriented) - in this style, we describe various
states of the component (e.g. semaphore with green, orange and red) and describe transitions between the
states. This can be written using F# asynchronous workflows and the
AwaitObservableprimitive (which you can get as part of the source code).
Thanks to the folks from SkillsMatter who provided place for the meetup and helped with the organization, the talk was also recorded and is already available online! Below, you can also get all the nice Silverlight demos that I used during the talk...
Thanks again to Carolyn Miller and Phil Trelford for organizing the talk and also to Don Syme for taking me to the airport in the early morning (at 4 AM...) after the talk.
Links & Resources
- Reactive Programming in F# (recording) - Skills Matter
- Slides from the talk (PDF, PPTX formats)
- Reactive F# demos in Silverlight (includes
Calculating with infinite sequences on MSDN
About a year ago, I wrote an article about using lazy computations in C# 3.0. It was published by the C# Community PM Charlie Calvert at the C# Developer Center. The article was a first of two articles where I wanted to demonstrate that C# 3.0 can be used for implementing useful constructs known from functional languages. I realized that I never posted the link to the second article to my blog, so you can find the annotation and link below.
However, I remembered about these two articles because I was just working on chapters 11 and 12 of the Real-world Functional Programming in .NET book that I’m writing. Lazy values, which were the topic of my first article, are discussed in the second part of chapter 11 and IEnumerable and F# sequences are the topic for the first part of chapter 12. Because I already wrote two articles on this topic, I had to think really hard to find better (and still simple enough) examples where these concepts are useful in practice. I also finally have enough space to show how these two concepts relate and talk about some interesting background – for example in Haskell, lazy sequences are in fact just ordinary lists that are lazy thanks to the Haskell nature.
A year ago, I definitely wouldn’t believe that today, I’ll be writing about the same topics, but this time as part of a book that has partly the same goal as these two articles – to show that functional programming ideas are really useful in the real-world and can enrich your programming toolbox (no matter whether you’re using C# or F# language). Anyway, here is the link to the second article – as usual when I look at something that I worked on a long time ago, I think I should rewrite it to make it better :-), but it still gives you an idea what is the book that I’m working on about...
Thesis: Client-side Scripting using Meta-programming
I realized that I haven’t yet posted a link to my Bachelor Thesis, which I partially worked on during my visit in Microsoft Research and which I successfully defended last year. The thesis is about a client/server web framework for F# called F# WebTools, which I already mentioned here and its abstract is following:
The full text is available here: Client side scripting using meta-programming (PDF, 1.31MB)
Phalanger at Lang.NET Symposium
Last week I attended the Lang.NET Symposium and I also did a short presentation about Phalanger (below you can find the demos and slides from my talk). By the way – during the trip from Prague to Seattle I missed a connecting flight from Paris, so I had one day to visit Paris and since I was traveling on Saturday I actually quite enjoyed it :-), so that’s where the picture comes from.
Overall it was really a fantastic event with many great talks from many interesting people. I hope that there will be recordings as a last year, so I won’t comment every topic that I found interesting (that would be really a long post). But just quickly – people from Microsoft often talked about DLR (dynamic language runtime) related topics, which was interesting as we’re planning to look at DLR in Phalanger. Luckily, Wez Furlong from the PHP community was there too, so we discussed how we could work on “PHP on DLR” project together (see also our mailing list).
There were also two talks about F# (from Luke Hoban and Harry Pierson), and it was a lot of fun to hang out with them. Finally, Erik Meijer presented the Volta project, which I was particularly interested in as it shares many goals and ideas with my F# Web Tools.
Non-Microsoft talks covered wider range of topics including Mono and Moonlight project (by Miguel de Icaza) and I actually had a chance to talk with Miguel about Phalanger and we even tried running the Helicopter sample on Moonlight – there were some issues, but it seems quite promising, so I hope to have the sample running on Moonlight on Linux quite soon! Miguel mentioned that the installation of Moonlight is currently a bit painful (due to some issues with media codecs), but it should be fixed in next few weeks, so I hope to be able to try it on my machine too!
Lazy Computation in C# on MSDN
I think that one of the interesting things about C# 3.0 is that it gives you the ability to use many techniques known from functional languages (like Haskell or F#). Most of the articles about C# 3.0 and LINQ focus on the queries and LINQ to SQL, but I believe that using these functional techniques deserve some attention as well. This is why I'm very happy that my article about one of these techniques - representing lazy computations - is now available at the C# Developer Center. I would like to thank to Charlie Calvert [^], who is the Community Program Manager for C# and who edited and published my article there. Here is the annotation:
Most of the programming languages used in practice (including for example C#, VB.NET, C++, Python or Java) employ so called eager evaluation, which means that the program evaluates all expression and statements in the order in which they are written, so all the preceding statements and expressions are evaluated before executing the next piece of code. This, for example, means that all arguments to a method call are evaluated before calling the method. Sometimes it may be useful to delay an execution of some code until the result is actually needed, either because the result may not be needed at all (but we can’t tell that before executing some computation) or because we don’t want to block the program for a long time by executing all computations in advance and instead we want to execute the computations later, when we will actually need the result.
In this article we will look how these lazy computations can be written in C# (using some of the new language features from version 3.0). We will first implement a Lazy class to represent this kind of computation, then look at a few simple examples to demonstrate how the class can be used, and finally we will examine one slightly more complicated, but practically useful application.
You can read the complete article here: Lazy Computation in C# [^]