Microsoft’s Build 2014 conference is currently in full flow, one of the new products announced is Orleans, an Actor framework with a focus on Azure.
There’s an MSDN blog article with some details, apparently it was used on Halo 4.
Demis Bellot of ServiceStack fame, tweeted his reaction:
I retweeted, as it wasn’t far off my initial impression and the next thing I know my phone is going crazy with replies and opinions from the .Net community and Microsoft employees. From what I can make out the .Net peeps weren’t overly impressed, and the Microsoft peeps weren’t overly impressed that they weren’t overly impressed.
So what’s the deal.
Actors
Erlang has distributed actors via OTP, this is the technology behind WhatsApp, recently acquired for $19BN!
The JVM has the ever popular Akka which is based heavily on Erlang and OTP.
An industrial strength distributed actor model for .Net should be a good thing. In fact Microsoft are currently also working on another actor framework called ActorFX,
The .Net open source community have projects in the pipeline too including:
There’s also in-memory .Net actor implementations with F#’s MailboxProcessor and TPL Dataflow. Not to mention the departed Axum and Retlang projects.
Orleans
From what I can tell, Orleans appears to be focused on Azure, making use of it’s proprietary APIs, so there's probably still a big space for the community's open source projects to fill.
Like Demis I’m not a huge fan of WCF XML configuration and code generation. From the Orleans MSDN post, XML and code-gen seem to be front and centre.
You write an interface, derive from an interface, add attributes and then implement methods, which must return Task<T>. Then you do some XML configuration and Orleans does some code generation magic for hydration/dehydration of your objects (called grains).
Smells like teen spirit WCF, that is methods are king, although clearly I could be reading it wrong.
From my limited experience with actors in F# and Erlang, messages and message passing are king, with pattern matching baked into the languages to make things seamless.
Initial impressions are that Orleans is a long way from Erlang Kansas…
The Good Parts
Building a fault-tolerant enterprise distributed actor model for .Net is significant, and could keep people on the platform where they may have turned with Erik Meijer to the JVM, Scala and Akka otherwise.
Putting async front and centre is also significant as it simplifies the programming model.
C# 5’s async is based on F#’s asynchronous workflows, which was originally developed to support actors via the MailBoxProcessor.
Coroutines
Underneath, Erlang’s processes, F#’s async workflows and C#’s async/await are simply implementations of coroutines.
Coroutines are subroutines that allow multiple entry points for suspending and resuming execution at certain locations. They’ve been used in video games for as long as I can remember (which only goes back as far as the 80s).
Coroutines help make light work of implementing state machines and workflows.
Methods
In Erlang messages are typically described as named tuples (an atom is used as the name), and in F# discriminated unions are typically employed.
Orleans appears to use methods as the message type, where the method name is analogous to an Erlang atom name, or an F# union case name and the parameters are analogous to a tuple. So far so good.
Where they differ is that return values are first-class for methods, and return values feel more like an RPC approach. In fact this is the example given in the article:
public class HelloGrain : Orleans.GrainBase, IHello
{
Task<string> IHello.SayHelloAsync(string greeting)
{
return Task.FromResult("You said: '" + greeting + "', I say: Hello!");
}
}
Also current wisdom for C# async is to avoid async void... which is why I guess they’ve plumped for Task as the convention for methods with no return value.
Messages
.Net’s built-in binary serialization is bottom of the league for size and performance, hopefully alternative serialization libraries like Google Protocol Buffers will be supported.
Judge for yourself
But these are just my initial impressions, try out the samples and judge for yourself.