This post is a very interesting study of the differences between “functional-first” (F#) and “object-first” (C#) design for medium-sized software, by comparing software metrics for a number of C# and F# projects.

Here are the conclusions, #3 and #4 are the most important I think.

  1. Project complexity. For a given number of instructions, a C# project is likely to have many more top level types (and hence files) than an F# one -- more than double, it seems.
  2. Fine-grained types. For a given number of modules, a C# project is likely to have fewer authored types than an F# one, implying that the types are not as fine-grained as they could be.
  3. Dependencies. In a C# project, the number of dependencies between classes increases linearly with the size of the project. In an F# project, the number of dependencies is much smaller and stays relatively flat.
  4. Cycles. In a C# project, cycles occur easily unless care is taken to avoid them. In an F# project, cycles are extremely rare, and if present, are very small.

To me, this is good evidence that functional-first programming offers fundamental improvements in taming the complexity of software systems. Honestly, would you prefer to work on software with cyclic dependencies involving 50-200 components (C#) or 1-3 components (F#)?

I’d be interested to know what people think of this study and, if they disagree with the results, how they would refute it.  And if the results are valid, then what does it mean for software engineering and programming languages?