Geeks With Blogs

News

This blog has moved to ericnelson.wordpress.com

 Subscribe in a reader

Add to Google Reader or Homepage


Links
View my teams slideshare
These postings are provided "AS IS" with no warranties, and confer no rights.



IUpdateable has moved to ericnelson.wordpress.com Please visit http://ericnelson.wordpress.com

[Warning – this is shamelessly taken from the documentation but I felt it deserved a wider viewing]

Yesterday I delivered a session on the new parallel capabilities of .NET 4.0 (see slides and links). I also managed to slip in a little section at the end on Axum and Concurrent Basic. These two programming languages are nothing to do with .NET 4.0 but are very interesting if you care about what the future beyond .NET 4.0 might bring for parallel development on Windows.

Axum is available for download today. It moves away from object orientation (there are no public methods or fields) and instead uses message passing on channels between agents as the fundamental idioms of the language.

For example, to implement a solution which adds numbers you could use the following pattern:

image_thumb[2]

The following is the code contained within a single file, separated out for clarity.

First the using statements. NB: Axum can access standard .NET classes and methods such as Console.WriteLine.

   1:  using System; 
   2:  using System.Concurrency; 
   3:  using Microsoft.Axum; 

Next, the implementation of the channel (Adder at line 1) and the agent (AdderAgent at line 8). The AdderAgent waits for two values to appear on the channel (Num1 and Num2 at line 12) and then returns the total on the same channel (as Sum at line 14):

   1:  channel Adder 
   2:  { 
   3:      input int Num1; 
   4:      input int Num2; 
   5:      output int Sum; 
   6:  } 
   7:   
   8:  agent AdderAgent : channel Adder 
   9:  { 
  10:      public AdderAgent() 
  11:      { 
  12:          int result = receive(PrimaryChannel::Num1) + 
  13:              receive(PrimaryChannel::Num2); 
  14:          PrimaryChannel::Sum <-- result; 
  15:      } 
  16:  } 

The consumer of AdderAgent creates an instance (line 5) and sends the values to be added to the channel as messages (lines 6 and 7) and then later checks for the answer (line 9). End result is the MainAgent can continue to run in parallel with the work of AdderAgent:

   1:  agent MainAgent : channel Microsoft.Axum.Application 
   2:  { 
   3:      public MainAgent() 
   4:      { 
   5:          var adder = AdderAgent.CreateInNewDomain(); 
   6:          adder::Num1 <-- 10; 
   7:          adder::Num2 <-- 20; 
   8:          // do something useful ... 
   9:          var sum = receive(adder::Sum); 
  10:   
  11:          Console.WriteLine(sum); 
  12:   
  13:          PrimaryChannel::ExitCode <-- 0; 
  14:      } 
  15:  }

There are lots more examples in the documentation (PDF to download)  but hopefully the above was enough to get you interested. Enjoy!

Posted on Wednesday, May 13, 2009 2:13 PM Misc | Back to top


Comments on this post: Introducing Axum – a new programming language for parallel development

# re: Introducing Axum – a new programming language for parallel development
Requesting Gravatar...
Interesting - and everyone should visit Axum at least once. Does Axum wrap the Intel library or proceed from Parallel Extensions ?
Left by Raimond on May 20, 2009 2:21 PM

# re: Introducing Axum – a new programming language for parallel development
Requesting Gravatar...
Yes this is interesting as I've recently read some functional languages handle concurrency this way (Erlang or Haskell it may of been).

I'm also thinking maybe F# might have something similar. Please do not quote me on that but F# has it's roots in many of the functional languages that do this sort of thing.

I agree completely with you; learning this messaging approach is very important for writing concurrent applications in the future.
Left by Derek Smyth on May 20, 2009 8:05 PM

# re: Introducing Axum – a new programming language for parallel development
Requesting Gravatar...
Thanks Eric.
Yes, what is the realationship between F# and Axum?

Art Scott
Left by Art Scott on Aug 17, 2009 7:39 PM

Your comment:
 (will show your gravatar)


Copyright © Eric Nelson | Powered by: GeeksWithBlogs.net