Android Wear Starter Project – F# + Xamarin

Wearable computing is undeniably a hot topic currently, what with all the major mobile players (Apple, Google and Microsoft) having entered the market. There is also a plethora of smaller players such as Timex, Nike, Pebble, etc.

Cheap, ubiquitous wearable computers – along with Internet-of-things – may be the next big wave in technology. As they say, “possibilities are endless…”.

As this blog is dedicated to F# and functional programming, here is a starter barebones Android Wear project for Xamarin – written entirely in F# :

Please go through the repository documentation (“” file). It will give you an overview of the Android Wear app deployment process. There you will also find a list of potential ‘gotchas’ to avoid and tips on debugging and troubleshooting.

Rich / Mobile Web Development – Without Losing Your Sanity

Web development is so different today than what it was even a few years ago. Web 1.0 (if we can call it that) is fading fast. Web 2.0 is in full swing. HTML 5 + CSS 3 and JavaScript are in.

There are two issues:

1) JavaScript is being asked to do what it was never designed to do.

2) Rich and mobile web development is becoming more like client-server development but the client side and the server side are two different worlds; lacking is a way of developing in a cohesive way for both.

Fortunately there is F# and WebSharper!

Recently I rolled up the sleeves and jumped in with both feet to build a mobile web application in WebSharper and JQuery mobile – as a learning exercise.

The end result is quite effective. I did not have to write a single line of JavaScript! Most of the time was spent learning the intricacies of JQuery Mobile.


Sample application is online here: (needs an HTML5 capable browser). The full source code is here:

F# Push Notification; 33K Concurrent Clients; 1 Relaxed Server

This post is about maximizing the number of concurrent connections to a single server using F# Async and Async IO. A perfect use case is for ‘push notification’ type services which exist for all the major smartphone platforms (iPhone, Android, Windows Phone).

Note: This post is about 33000 concurrent push notification clients. However in a separate test I achieved 5000 concurrent connections to a single server under load. Each client connection continually sent requests to the server with random data and no “think time” between subsequent requests. Here again I ran out of client resources to scale up. The server could handle more as it was mostly IO bound (AppFabric cache calls and SQL Server Async IO queries)

Continue reading

Hidden Markov Models and a ‘Reactive’ Viterbi Algorithm Implementation

Brian Beckman over at c9 has implemented a reactive version of the classic Viterbi algorithm using System.IObserver. It seems that Viterbi is natrually suited to this type of an implementation because it deals with events (observations) over time so this is a very cool innovation.

I took Brian’s implementation and ported it to F# and parallelized the main computational part along the way. The parallelized part relies on the Task Parallel Library (TPL) under the covers and uses the F# PowerPack TPL wrapper.


Understanding Monads Sample: F# Async Monad

In the previous post I explained, at a very high level, that monads are really about function composition with side activities.

In this post, I will use an example based on F#’s Async monad to demonstrate practical uses of monads.

Imagine that there are 3 asynchronous web service calls that we want to sequence together before doing something else. The calls have data dependencies where the data from the previous call is required by the next. The calls are asynchronous so the calling thread starts the request and then continues on. The thread will not block waiting for a response as is the case with regular synchronous calls. However the next service call cannot start unless the previous one is done, which requires special handling.

Continue reading