Switching to another programming language is difficult. Especially if you are switching from an imperative one to a functional one. There are a number of reasons why you would think that switching is bad, and when considering F# I dare say that none of those reasons are correct. The language compiles to IL (Intermediate Language) code that runs on Microsofts tried and tested .NET runtime (or Mono’s ditto). You have access to all the same classes in the .NET hierarchy that you have from any other .NET capable language. You can write web applications, WinForms applications or console applications in F#. You can connect to any kind of database that you can connect to from any other .NET language. You can use your existing C# og VB.NET code in your F# applications, or you can write F# code and use it in your existing applications. You have the opportunity to write more concise and maintainable code in a language that has much higher performance than any other functional language I know – with the possible exception of Clean, but that is still debatable, and you can mix functional programming with object oriented ditto at your leasure.
But what about testing? In these TDD (Test Driven Development) oriented days being able to properly test your code with automated unit- and integration tests is paramount. And if you have to use another (or perhaps write your) test framework than the one you are already using and familiar with, that might be an insuperable problem. Fortunately you can easily use NUnit with F# and I will show you how. (more…)
For a while I have been toying with F# – a strict, functional programming language – primarily to get to know the language. I have written a few utility programs and I am working on the problems defined on the Project Euler site. These mathematical problems are perfect for being solved in a functional programming language and it is a great way to work with a new language as well as getting a brush-up on your mathematics.
I have made an implementation of the Huffman compression algorithm in F# to showcase a few of the important things that make functional programming so great to some classes of problems.
Huffman tree generated from the text ‘this is an example of a huffman tree’. Source:wikipedia.org
I recently discovered this webcast called “Erlang – software for a concurrent world” by Joe Armstrong. It is recorded at a JAOO conference. Yes, I wrote “a”… I can’t find any info on which one it is but i strongly suspect it is from either London, Sydney or Brisbane in 2008.
Anyway, the webcast is about an hour long, and is really interesting.
Remember to check out Joe Armstrongs blog if you are interested in Erlang and functional programming.
Those who know me knows that I am not a web-programmer. I don’t think I am compatible with PHP, HTML, XML, AJAX, and all the other web technologies out there. So when I need to do something with my domain I tend to rely heavily on open source software designed so that I have to write a minimum of code. The past months I have used Drupal for my homepage. It has worked okay, but lately I had grown a bit tired of it – it was slow, and it seemed impossible to get it to do exactly what I needed. Furthermore I couldn’t upgrade it to a more recent and secure version without crashing the entire webserver, so a new solution was needed.
Granted, Drupal is a big content management system and is not designed to run a small homepage. Yes, I am an idiot when it comes to web technologies – so what. Fortunately a good colleague suggested WordPress for my website, so this saturday I have spent an incalculable number of hours trying to convert the blog entries and pages from Drupal to WordPress.
Whatever happened to compatible technologies..? If there is an easy way to convert data from one CMS to another it has eluded me. I had to do it by hand (export from the MySql database to a local file, use a text editor to edit the INSERT-statements and extract the HTML, copy-paste into the new system, and repeat…), but now it is complete (I think). The only regret I have is that I lost the comments for the blog entries, but that is a small price to pay.
So now I can lean back and enjoy the fruits of my hard labour. And hope that I will not need to upgrade my website again… ever!