Is there any C#/F# performance comparison available on web to show proper usage of new F# language?
Here are a few links on (or related to) this topic:
- http://cs.hubfs.net/forums/thread/3207.aspx
- http://strangelights.com/blog/archive/2007/06/17/1588.aspx
- http://khigia.wordpress.com/2008/03/30/ocaml-vs-f-for-big-integer-surprising-performance-test/
- http://cs.hubfs.net/blogs/f_team/archive/2006/08/15/506.aspx
- http://blogs.msdn.com/jomo_fisher/
What I seem to remember from another post on Robert Pickering's blog (or was it Scott Hanselman?) that in the end, because both are sitting on the same framework, you can get the same performance from both, but you sometimes have to 'twist' the natural expression of the language to do so. In the example I recall, he had to twist F# to get comparable performance with C#...
Natural F# code is slower than natural C# code. However, natural F# is much shorter than natural C# code. My experience is to code in F# first and optimize only the parts that matter. It might be easier to write the slow functions in C# rather that to try to tweak F#. There are a number of features that contribute to slowness: references (vs. class instance variables), F# comparison (<=) vs. System.Collections.Generic.Comparer, tail calls, F# sequences are twice slower than LINQ. However, it makes sense to start in F# then profile, disassemble and optimize.
Why bother coding in f# if it's slower? It just sounds like a pointless distraction to me. Microsoft Visual Studio has to bring in it's share of Microsoft revenue every 2-3 years. That means they have to come up with something meaty besides a few extra bells and whistles to make IT departments and programmers pull out their wallets for a the new version.
Why does every new MS language have to be slower than a previous language? When are they going to start moving in the other direction and come up with new languages that perform faster than previous ones?