F# Productization and Visual Studio 2008

It has been a long time since I haven’t blogged. Lots of things have happened on my side and on the development world. After finishing the internship at Microsoft Research Cambridge and submitting my thesis, I started to work at European Product Development Center in Dublin. I am very excited to work at Microsoft again.

I started a new project and used Visual Studio 2008 for that. I say used because the project is prematurely ended. That’s why I find time to write actually. Anyway that’s another story. From now on, I will try to blog more often about F#, C# 3.0, Parallel FX Library and Silverlight.

Here are the developer news :) . There were so many exciting things happened.

First F# is getting productized. I want to congratulate for the achievement and looking forward for the next updates. It is great news for the developer  and research world. I am really happy for F# being a “product”. What does that mean as a developer point of view is that, the language will not die and it will be more stable and developped more quickly. A functional language getting to the main stream will involve lots of new development and research ideas. The team is now focusing on stability and feature fixing and I am really looking for the future releases.   

Moreover, Visual Studio 2008 is out there. At first it looks very similar in terms of user interface. But I have to admit that it’s lot better and faster. Here are the quick impressions. I like the window list when navigating between the tabs with Ctrl Tab with a small preview window. I liked the transparency of the code complete display. when you press Ctrl it becomes transparent so that it is possible to read the code underneath, you don’t have to navigate away. Of course beside the visual enhancements, the language extensions such as LINQ, DLINQ, XLINQ, collection initialisers and functional constructs in C# and VB (lambda expressions, anonymous types), new designers and  new classes (pipes..) in the framework are really welcome. More classes are now supporting the generic types and most of nongeneric types became abbreviated.I hope the same goes for all of the typed collection types as well. Such as XMLNodeList etc :) . Typed is something good..

Finally the project management system of Visual Studio 2008 allows us to target to lower frameworks as well. So there is no need to hack visual studio to compile on other frameworks. This is also possible because there is no update on the CLR, on the other hand it is not possible to target 1.1 because of the CLR change but who wants to do that anymore ?

Happy coding…

 

Almost Finished,What’s Next,.NET Source Code

What a nice morning after everything… It has been more than a week since I finished my coursework which means that I unofficially finished my masters. Things are started to change now, I really didn’t understand how this month has passed and couldn’t believe it’s just finished. Well the truth is I enjoyed every single moment of and very happy about it. Something is going to happen soon, I’ll tell you later but fingers crossed for the moment…

Back to business, the source code of the .NET Framework will be released under MS-RL license. Moreover debugging from Visual Studio, looking to the source locally will be possible. What an announcement! I just couldn’t believe it. Since the BCL Team insisted on the comments, I really wonder about the comments, as well as the code.

Have you ever wanted to look inside some of the BCL methods? Have you ever wondered about some exception thrown by our code? Are you curious to see what comments BCL developers write in their code?

Well yes to all those questions. This is a big step for the developer community. Previously Rotor is available as a research license but we weren’t sure it was the real .NET framework also it wasn’t usable from Visual Studio. Although the current license will allow only as a reference the code rather than using, I assume there will be some further movements to be more open, we’ll see. Also now you could see the news on Slashdot and digg so everybody is talking about it which is absolutely perfect

Parallelism on October’s MSDN Magazine

Although I am extremely busy this month, I can’t stop reading those wonderful articles about parallelism on October’s MSDN Magazine. Here are the articles, a very first gentle introduction to PLINQ (Parallel LINQ) by Joe Duffy,Ed Essey, Parallel Performance using System.Concurrency namespace and a ThreadPool article. Apparently in the near future we will have some more concurrency dlls.

Going back to work, enjoy!

Simple but Elegant, Creating a class from String

Creating a class from a string might be crucial for some very dynamic projects. It’s a single line of code that I wanted to share but I think it has a lot of power.

Simply get the executing assembly and call the GetType method. If your assembly is one of the linked assembly or even a dynamically loaded assembly, you might need to call GetReferencedAssemblies() method as well.

namespace reflectme
{
    using System;
    public class hello
    {
        public hello()
        {
            Console.WriteLine("hello");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Type t = System.Reflection.Assembly.GetExecutingAssembly().GetType("reflectme.hello");
            t.GetConstructor(System.Type.EmptyTypes).Invoke(null);
        }
    }
}

Bear in mind it will be extremely slow. Don’t do that :)

Astoria as a Database Service

It’s getting even more interesting. With the efforts of LINQ to be the solution for entity relationship now Microsoft adds additional features with Astoria services. Although it looks like an independent product, it has a dependency with ADO.Net Entity Framework (System.Data.Entity) which is not included in ORCAS Beta 2 and also not available for beta 2. So I couldn’t play with it.

Astoria as announced is a database service that supports different protocols and standards. At first it looks like Amazon S3 web service, but you can also host it yourself. Why would you want to host it? I don’t think this model would be useful for .NET applications, although you can, why to use another layer. Presumably it’s for Javascript and Silverlight usage mainly, you don’t need any additional libraries, it’s all there as a REST web service. Currently 100MB is provided by Astoria site…

I wonder if the web is going to provide enterprise services sooner or later. Although we store all our e-mail, calendar in the web, I still use my hosting database server or local cache rather than web services. Anyway I like the web relational database idea… I hope to play in the next release.

Compile LAPACK and BLAS as DLL on Windows

BLAS (Basic Linear Algebra Subprograms) is a library that provides standard routines for basic vector and matrix operations.

LAPACK is a library that provides functions for solving systems of linear equations, matrix factorizations, solving eigenvalue and singular value problems. LAPACK library have dependency to BLAS library because of the LAPACK functions using BLAS functions to work.

Both of those libraries are written in Fortran77 and no binaries provided for windows. The sources are downloadable from netlib site. So you can compile and use their libraries. However makefile and make solutions for compiling under windows are cumbersome.

So I recommend compiling directly from the sources using a FORTRAN compiler. There is a free and open source FORTRAN compiler for Windows which is the port of gnu FORTRAN compiler for Windows. You could also use Cygwin and tools in cygwin but your dynamic library loader will have dependency to cygwin dlls. MinGW is a collection of tools that allows you to produce native Windows programs. G77, make, gcc are the common tools provided by Mingw.

Here are the steps to go to compilation

  • Download most current version of LAPACK from Netlib and extract the sources
  • Download almost all of the Mingw tools and extract the tools
  • Copy dlamch.f and slamch.f from INSTALL directory SRC directory
  • Set path to have mingw binaries
    • set PATH=c:\mingw\bin\;%PATH%
  • Go to root directory of the extracted folder and compile using g77
  • First compile BLAS. –shared option is needed in order to functions to be exposed from the dll. -O generates optimised code. -o filename is the output file
    • g77 –shared -o blas.dll BLAS\SRC\*.f –O
  • Compile LAPACK with BLAS dependency
    • g77 –shared -o lapack.dll src\*.f blas.dll -O

Here is the output:

c:\\lapack-3.1.1\\copy INSTALL\\dlamch.f SRC\\dlamch.f
       1 file(s) copied.
c:\\lapack-3.1.1\\copy INSTALL\\slamch.f SRC\\slamch.f
       1 file(s) copied.
c:\\lapack-3.1.1\\set PATH=c:\\tools\\mingw\\bin\\;%PATH%

c:\\lapack-3.1.1\\g77 --shared -o blas.dll BLAS\\SRC\\*.f -O

c:\\lapack-3.1.1\\g77 --shared -o lapack.dll src\\*.f blas.dll -O

Hope this helps.