There is not much that I can add over the experiences and opinion expressed by optionsScalper.
I have been working on AI for the last 10 years and have used and tried a lot of programming languages over this time including C/C++/C#/Java/JavaScript/MATLAB/R/S/S+. I am now using F# most of the time, in particular when it comes to non-linear data analysis (MATLAB is a good vehicle when all you are doing is linear model analysis and the datasets are only moderately sized).
The three major advantages I see for using F# are:
- Succinctness: For example, I have recently ported a factor graph inference library from C# to F# using language concepts that are only availabel in F# ( for example, object expressions ) and have shortened the code by a factor of 5.
- Performance: I do not notice any performance difference between C# and F#. In my job, I often perform a very detailed data analysis of 100's of GB of Xbox Live log data and performance is as good as it can get.
- .Net Intereprability: The possibly biggest advantage of F# is that it integrates deeply with .Net. The power of F# lies in the fact that you get the beauty of a functional programming language with the whole CLR at your fingertips. In the above mentioned data analysis I work with SQL 2005 servers and the whole task of getting the data from the server takes a staggering 15 lines (I am sure this can be improved and I would like to hear other people's opinion
).
As an example, here is the above mentioned SQL reading code
open System
open System.Data.SqlClient
///Creates a SQL connection for a database.
let createSqlConnection database =
let sqlConnection = new SqlConnection ("Initial Catalog = " ^ database ^ "; Data Source = testserver; Integrated Security = SSPI") in
sqlConnection.Open();
sqlConnection
///Creates a SQL data reader iterator.
let sqlIterator statement connection =
let command = new SqlCommand (statement, connection) in
command.CommandTimeout <- 0;
command.ExecuteReader()
|> IEnumerable.unfold (fun (reader:SqlDataReader) -> if (reader.Read()) then Some(reader,reader) else (reader.Close(); None))
Hope this helps your decision making,
Ralf Herbrich
Applied Games Group, Microsoft Research Ltd., Cambridge, UK