Phillip Trelford's Array

POKE 36879,255

Orleans

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.

C# Eye for the APL guy

A Programming Language (APL) was invented in the swinging 60s, first appearing in 1964. C#, an OOP language, first appeared in the year 2000, to coincide with Britney’s Oops!… I did it again world tour.

Adding numbers

APL C#
2 + 2
using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(2 + 2);
    }    
}

 

Note: C# may get a REPL in Visual Studio when project Roslyn is finally released.

Min/Max

APL C#
11 ⌊ 20
75.6 ⌈ 87.3
11 28 52 14 ⌈ 20
Math.Min(11, 20);
Math.Max(75.6, 87.3);
(new[] { 11, 28, 52, 14 })
    .Select(x => Math.Min(x, 20));

Note: in C# math operations are preceded by Math and followed by dot.

Counting Costs

APL C#
Costs ← 10.4 11.5 10.8 24 16.9
+/ Costs
var costs = 
    new[] {10.4,11.5,10.8,24,16.9};
costs.Sum();

Computing Costs

APL C#

Price ← 5.2 11.5 3.6 4 8.45
Qty ← 2 1 3 6 2
Costs ← Price × Qty

var prices = 
    new[] {5.2,11.5,3.6,4,8.45};
var qtys =
    new[] {2,1,3,6,2};
var costs =
    prices
        .Zip(qtys, (price, qty) =>
        new {Price=price, Qty=qty})
        .Select(pair =>
        pair.Price * pair.Qty);

Summary

C# has the clear lead on the number of characters to express problems. That said if you’re not paid by the number of characters you write you may want to Try APL.

UK Tech Meets

Passionate about programming, interested in meeting other like minded individuals?

A good place to start is a local meetup group.

.Net

Here’s my short list of active .Net/Mono related groups in the UK which feature some C#, F# or VB content (let me know if I’ve missed your group):

Group Members
London Unity Usergroup 1074
Windows Phone User Group 850+ (on mailing list)
F#unctional Londoners 742
Software East (Cambridge) 673
London .Net User Group 538
Canary Wharf Dot Net User Group 501
Cambridge Developer’s User Group 355
Norfolk Developers (Norwich) 325
Nottingham Programmers 255
Developer South Coast (Southampton) 241
Functional Bridgton 141
Cambridge DDD Nights 122
Brighton ALT.NET 49
Smart Devs (Hereford) 43
Functional South Coast (Southampton) 37
Craft Coders (Worcestershire) 34
Wales & West Windows Applications Group 25
NxtGen (Birmingham)  
VBUG (Bristol)  
Agile Yorkshire  
Sheffield .Net User Group  
Gloustershire .Net User Group  
Dare Devs (Chesire)  
IWDev (Isle of Wight)  
Windows Phone (Bristol/Cardiff)  
Windows Phone (Manchester)  

 

In the .Net arena, it seems gaming, windows phone, and functional programing are hot right now. Overall there’s a good spread of groups across the regions, with high concentrations in London, Cambridge and the South Coast.

Curiously the London C#/.Net focused user groups appear to be eclipsed by the London Java Community meetup which has close to 4000 members, and PHP London with nearly 3000 members.

Functional

Interest in functional programming has been growing steadily as have related groups in the capitol:

Group Members
London Scala Users’ Group 1405
F#unctional Londoners 742
London Clojurians 540
London Haskell 423
London Erlang Uer Group 377

 

On the F# side, the F#unctional Londoners now meets every 2 weeks and has been growing at a rate of around 100 members every 6 months. Progress is not just confined to London, there’s F# user groups popping up across the globe

Data Science

Data Science and Machine Learning are another growth area, and the many machine learning based sessions have been very popular with the F#unctional Londoners.

Group Members
Data Science London 2980
London Machine Learning 1009
Women in Data 380

Hackers

Hacker News is something of a phenomena, and hacker groups appear to be among the biggest:

Group Members
Hacker News London 5771
Silicon Roudabout 5042
Hacks/Hackers London 2524
DevTank London 926

 

Get Involved

Like pizza, like beer, like learning, there’s a meetup group near you waiting :)