Microsoft Axum: .NET Language for Parallel Computing

| Comments

Followed by F#, one more language is coming out from Microsoft .NET campus named “Axum”. 

Based on Concurrency and Coordination Runtime (CCR) in Microsoft Robotic Studio, Axium is a language which allows to define your application to do parallel computing in your .NET applications.

Axum comes into play for the following:

  • Asynchronous behaviour
  • Dealing with concurrency
  • Dealing with partial failure

We know that asynchronous enables to scale our code better with greater responsiveness.  However, callback structure lacks the readability.  Concurrency is a way to utilizes the resources well to execute code in parallel with safe sharing of state.  Unlike typical OO languages, Axum is designed for modeling applications with concurrency behaviour, so it deviates from object-oriented programming.   

The core aspects in Axum are:

  • Agent.  It is an autonomous entity which communicate with other agent via messages, act on the data received from other agents.  ConsoleApplication is one such agent for representing System.Console.
  • Channel.  This is medium for transmitting messages from one agent to another.
  • Ports.  This is used to specify the direction of messages.  A channel consists of input and output port.
  • Domain. This enables to group agents so that state can be shared between the agents.

Let us see a sample code taken from Axum Programing Guide.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 

using System;
using System.Concurrency;
using Microsoft.Axum;

namespace HelloAxum
{
    public domain Program
    {
        channel Adder
        {
            input int Num1;
            input int Num2;
            output int Sum;
        }
       
        agent AdderAgent : channel Adder
        {
            public AdderAgent()
            {
                int result = receive(PrimaryChannel::Num1) +
                receive(PrimaryChannel::Num2);
                PrimaryChannel::Sum <-- result;
            }
        }
       
        agent MainAgent : channel Microsoft.Axum.Application
        {
            public MainAgent()
            {
                var adder = AdderAgent.CreateInNewDomain();
                adder::Num1 <-- 10;
                adder::Num2 <-- 20;
    
                var sum = receive(adder::Sum);
               Console.WriteLine(sum);
               Console.ReadLine();
              PrimaryChannel::ExitCode <-- 0;
            }
        }
    }
}

Adder is a channel which contains two input port and one output port.  AdderAgent implements Adder channel.  It receives the two input port values, add these two and set the result into PrimaryChannel.  The primary channel actually refers Adder in AdderAgent.  MainAgent is another agent which is actually a main Axum application.  It creates AdderAgent and send the message to it.  The result is received on “sum”.

Download and drive Axum from https://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=cfe70d5d-37aa-4c4c-8eeb-d4576c41baa2