Let's compare the code from two projects using Kit Eason's code analyser on fssnip. One project is written in C# and the other in F#. Both projects consume data feeds, perform some calculations and report the results to the users. The major difference between the projects is that the F# project consumes many more feeds and performs all the calculations in real-time.
Comparison of Lines of Code
Here are the numbers:
|Metric||C# Project||F# Project||The F# Difference|
|Null check lines||3036||27||112x|
|Project Duration||5 years||4 months||15x|
|Defects since go live||too many||zero||tending to infinity|
WTF C#!!, OMG F#!!
... more seriously
It is hard to draw any conclusions comparing different projects written by different teams using only various line counts as a metrics.
I am both a C# dev and an F# dev. I can only offer subjective anecdotal evidence based on my experience of delivering projects in both languages (I am too busy delivering software to do anything else). I will leave rigour to others (btw let me know if you write a code analyser that can produce metrics for both C# and F#, I would love to run it on the projects I have and report the results).
That said, the one stat in the summary that I find most compelling is the defect rate. I have now delivered three business critical projects written in F#. I am still waiting for the first bug to come in. This is not the case with the C# projects I have delivered. I will continue to monitor and report on this. It might be that I am just on a lucky streak, but I suspect that the clarity and concision of F# code contributes greatly to its correctness.
More details on the F# project here.
More details on the scarcity of bugs in F# code here.
Saxon Matt performs another C#/F# code comparison here.