Toward the Async World

CPUs with multiple cores can run many tasks in parallel. Making the best out of this ability needs more efforts on design side through implementation, test, and profiling which with the introduction of .Net Parallel Extensions we have greater set of tools to starting thinking and living the parallel way.

Visual Studio 2010 also ships with F# as a first class language which should gain more attention in different ways. F# takes your hand and brings you to a very practical functional environment which on top of all of its features adjusts a new way of thinking about programming in particular and software development in general. F# also speaks a new language in parallel programming. Its simple and efficient way of implementing the parallel life helps programmers and system engineers to provide better software faster; maybe it’s unusual to say but programming in F# has a very similar taste of developing the agile way. Everything you build is the result of functions interaction; growing, extending and fixing the software is just doing the same to the functions. Therefore you just need to think about the functions of the system you are trying to build and build the essential functions that make it in whole.

It seems this aspect of F# (parallel abilities) is affecting other parts of the .Net framework. C# and VB are going to support the new async programming constructs built-in and therefore we are going to have a new road ahead in the parallel land. As a system engineer/software developer, people should reconstruct their building blocks inside their software repositories. We all have a huge amount of code here and there with the biggest overhead of taking care of parallelization (if available) which could be done in a more efficient and faster way. Many different parts of the programs could run in parallel now, which we may have been implementing the usual sequential way. If we think about our pockets and we need to compete in the market, I think we all should think again and think parallel.

This Async CTP is in its early stages but I’m sure it will become an uncontrollable giant facing every one of us. Take a look at it.

Isn’t it beautiful?

(*
    bool isOdd(int n)
    {
        return ( (n%2) == 1);
    }
 
    int sqr(int n)
    {
        return n*n;
    }
 
    main(void)
    {
        for(int i = 1; i <= 10; i++)    // I know this is stupid!
            if(isOdd(i))
                printf("%d ", sqr(i));
    }
*)
 
#light

[1 .. 10]
    |> List.filter (fun n -> n % 2 = 1)
    |> List.map (fun n -> n*n)
    |> List.map (printfn "%d")
Posted in F#. Tags: . Leave a Comment »

F# and simulation strategies

Today I had a discussion with a friend in the field who was trying to find a resolution to his problem on simulating a data generation/acquisition network in which he could be able to produce millions of records of data simultaneously and submit them in a database. He was asking for my opinion about my programming language preference and the overall architecture of the system.

I had many ideas for him ready in my pocket about the architecture and even the object model suitable for the project but when it came to the point of programming language I just had a second thought. It was somehow strange for me not to shout out C# or C++.

As you may have noticed from my initial post in this weblog, it’s been a while I was exploring different aspects of F# which is amazingly beautiful, straightforward, succinct and functional. I guess this whole F# thing is playing my head; you know why? Because it took me about 8 hours to write down a prototype of my idea about my friend’s project and about half an hour to make it real. I’m so much excited about this and it’s killing me to check with him, cause I’m not sure if it’s ok to publish the code.

By the way, what took me to the point of implementing a “blah blah simulator” in F# was curiosity at first, but the precise functional attributes of F# with the help of its active pattern and agents ended up in heaven. You may follow this story on my next one or two posts here by the subject of “F# and simulation strategies”.