Functional programming appears to be enjoying a renaissance of interest for developing practical, “real-world” applications. Proponents have long maintained that the functional style is a better way to modularize programs and reduce complexity. What is new in this paper is we test this claim by studying the complexity of open source codes written in Scala, a modern language that unifies functional and object programming. We downloaded from GitHub, Inc., a portfolio of mostly “trending” Scala repositories that included the Scala compiler and standard library, much of them written in Scala; the Twitter, Inc., server and its support libraries; and many other repositories, several of them production-oriented and commercially inspired. In total we investigated approximately 22,000 source files with 2 millions lines of code and 223,000 methods written by hundreds of programmers. To analyze these sources, we developed a novel compiler kit that measures lines of code and adaptively learns to estimate the cyclomatic complexity of functional-object codes. The data show, first, lines of code and cyclomatic complexity are positively correlated as we expected but only weakly which we did not expect with Kendall’s t=0.258–0.274. Second, 75% of the Scala methods are straight-line, that is, they have the lowest possible cyclomatic complexity. Third, nearly 70% of methods have three or fewer lines. Fourth, the distributions of lines of code and cyclomatic complexity are both non-Gaussian (P<0.01), which is as surprising as it is interesting. These data may offer new insights into software complexity and the large-scale structure of applications including but not necessarily limited to Scala.
Coleman, R., & Johnson, M. A. (2014). A Study of Scala Repositories on Github. International Journal of Advanced Computer Science and Applications, 5(7). https://doi.org/10.14569/IJACSA.2014.050721
Coleman, Ron, and Matthew A. Johnson. "A Study of Scala Repositories on Github." International Journal of Advanced Computer Science and Applications, vol. 5, no. 7, 2014, https://doi.org/10.14569/IJACSA.2014.050721.
@article{Coleman2014,
title = {A Study of Scala Repositories on Github},
journal = {International Journal of Advanced Computer Science and Applications},
volume = {5},
number = {7},
year = {2014},
publisher = {The Science and Information Organization},
author = {Ron Coleman and Matthew A. Johnson},
doi = {10.14569/IJACSA.2014.050721},
url = {https://doi.org/10.14569/IJACSA.2014.050721}
}
Open Access — licensed under a
Creative Commons Attribution 4.0 International License.
Unrestricted use, distribution, and reproduction in any medium, even commercially, as long as the original work is properly cited.