Less Code and Less Bugs : with Functional Programming languages

With a FP language many problems can
be solved with elegantly less code and
less-code leads to less-bugs.

Functional Programming (FP) insider know that, because they have personally experienced it. This can be tweeted and blogged many times, but how can others believe this? How do you prove it?

That problem inspired me to do some investigation. We need facts. What I’ve found so far are two studies that show this from a data analysis side. There is some evidence that both is true, according to these newer papers from 2014, based on data analysis of source code and its history from Github and from Rosetta Code :

Functional languages have a smaller relationship to defects than other language classes where as procedural languages”
– [1] A Large Scale Study of Programming Languages and Code Quality in Github
Functional and scripting languages provide significantly more concise code than procedural and object-oriented languages.”
– [2] A Comparative Study of Programming Languages in Rosetta Code


In [2] the data analysis covers 8 widely used languages representing the major programming paradigms
- procedural: C and Go;
- object-oriented: C# and Java;
- functionalF#  and  Haskell;  
- scripting:  Python  and  Ruby


I think the “less code” property is underestimated, because the too easy Lines of Code (LOC) counting is ridiculed. Looking beyond the LOC of the code base to the more important depending consequences :

less code  ->  less to read (more often than write!) and understand   -> 
less to review ->  less to communicate ->  less to refactor -> 
less to test  ->  less bugs  -> 
less to maintain  ->  less cost!!!

Btw. less code -> more time to think -> better solution -> more fun!


References

Other related analysis about software quality metrics, especially circular dependencies can be found here:
- “Comparing F# and C# with dependency networks
- “Cycles and modularity in the wild – Comparing some real-world metrics of C# and F# projects”

[1] A Large Scale Study of Programming Languages and Code Quality in Github
Baishakhi Ray, Daryl Posnett, Vladimir Filkov, Premkumar T Devanbu, Department of Computer Science, University of California, Davis, CA, 95616, USA
2014 http://dl.acm.org/citation.cfm?id=2635922


[2] A Comparative Study of Programming Languages in Rosetta Code
Sebastian Nanz, Carlo A. Furia, Department of Computer Science, ETH Zurich, Switzerland
2014 http://arxiv.org/abs/1409.0252



Unsere Referenzkunden und Referenzstimmen

Deutschland

generic.de_logo

„Der F# Schulungskurs wurde von Roman Bossart strukturiert aufgebaut und sehr kompetent durchgeführt. Vor allem ist der Referent auf unsere individuellen Bedürfnisse, wie zum Beispiel Flow Design, eingegangen und hat die Schulung darauf zugeschnitten. Wir erlebten den Referenten als sehr kooperativ, flexibel, unkompliziert und hatten einen sehr guten persönlichen Austausch. Wir haben darüber hinaus wertvolle Tipps und Anregungen erhalten. Uns hat die Schulung wirklich weitergebracht! Wir freuen uns auf eine weitere, gute Zusammenarbeit.”


Sebastian Betzin, Chief Technology Officer, generic.de software technologies AG

 

Schweiz


Chess Computer
“Der F# Kurs von Roman Bossart war für mich wegweisend. Die gewichtigen Vorteile dieser Programmiersprache sind einerseits begeisternd. Andererseits brachte mir die kompetente und klare Präsentation durch Roman Bossart, den lang ersehnten Aha-Effekt. Auf Fragen wurde gründlich eingegangen. Wer gewillt ist, effizienter zu programmieren, dem ist dieser Kurs nur zu empfehlen.”


Peter Waldburger, CEO, PEWATRONIC Exklusive Schachcomputer, www.pewatronic.com




Metrohm_logo

Karl Leu, Leiter PC-Software, Metrohm AG www.metrohm.com