How do developers use C++ libraries? An empirical study

Di Wu, Lin Chen, Yuming Zhou, Baowen XuProceedings/Proceedings 2015

Abstract

C++ libraries provide an abundance of reusable components for writing high-quality programs and are thus widely adopted by software developers. However, to date there is little work investigating how these libraries are actually used in real software. In this paper, we perform an empirical study to investigate the adoption of C++ standard libraries in open-source applications, with the goal to provide actionable information for developers to help them employ libraries more efficiently. To this end, we analyze 379 historical revisions of 30 applications, containing 149 million lines of C++ code, to conduct the experiment. The experimental results show that: (1) three standard libraries (i.e. Containers Library, Utilities Library, and Strings Library) are significantly more often used than other libraries; (2) the new libraries of C++11 (i.e. Regular Expressions Library, Atomic Operations Library, and Thread Support Library) are significantly less often used than the formerly established libraries; (3) the deprecated library constructs (i.e. auto pointers, function objects, and array I/O operations) are not used at a declining frequency; and (4) applications with a larger size do not adopt libraries more frequently. Based on these results, we propose four suggestions, which could help developers learn and use C++ libraries in an efficient way.

Introduction

The C++ Standard Library is a cornerstone of modern software development, yet empirical evidence regarding its actual usage in the wild is limited. Developers often face a "paradox of choice" when navigating the library's extensive components. This study addresses this gap by analyzing real-world adoption patterns to provide actionable insights for developers and educators, aiming to reduce "reinventing the wheel" and promote more efficient library usage.

Methodology

The researchers conducted a large-scale static analysis of 30 diverse open-source applications sourced from SourceForge and GitHub.

  • Dataset: The study analyzed 379 historical revisions, totaling 149 million lines of code (LOC). Projects spanned 10 domains, including Audio/Video (VLC), Office Suites (LibreOffice), and Graphics (Blender), with ages ranging from 2 to 16 years.
  • Analysis Tooling: The "Understand" commercial-grade static analysis tool was used to identify constructs within the std:: namespace, filtering out user-defined code.
  • Statistical Rigor: Usage patterns were validated using the Wilcoxon signed-rank test and Spearman’s rank correlation. Cliff’s $\delta$ was employed to measure effect sizes and ensure the practical significance of the findings.

Key Findings

1. Dominance of the "Big Three" Libraries

The study identifies Containers, Utilities, and Strings as the undisputed heavyweights of the C++ Standard Library. For students and new contributors, mastering these three provides the highest "return on investment" for understanding existing codebases. Within these libraries, library functions (73.95%) were utilized far more frequently than classes (7.89%) or macros (18.16%).

Distribution of library usage across categories, highlighting the dominance of Containers, Utilities, and Strings.

2. Lag in C++11 Adoption

Despite being available for several years at the time of the study, newer C++11 libraries—specifically Regular Expressions, Atomic Operations, and Thread Support—were used significantly less than older alternatives. This suggests a persistent "knowledge debt," where developers continue to write manual string parsing or platform-specific threading code instead of adopting standardized features.

3. Persistence of Deprecated Constructs

Deprecated constructs, such as auto_ptr and legacy function objects, are not naturally phasing out of codebases. Their usage frequency remained flat between 2011 and 2014, even after official discouragement. This finding serves as a warning for maintainers: deprecated code requires active refactoring rather than passive observation.

Density of use for deprecated library constructs over time, showing a lack of significant decline.

4. System Size and Library Density

The study found no significant correlation between project size (KSLOC) and the density of library usage (p-value = 0.896). While larger projects have more library calls in absolute terms, they do not use libraries more densely than smaller projects. This implies that even small, relatively simple projects are excellent environments for learning standard library best practices.

Conclusion and Future Work

The empirical results reveal a significant gap between the evolution of the C++ standard and its practical application in open-source projects. To improve development efficiency, it is recommended that developers prioritize the "Big Three" libraries, actively refactor deprecated code, and bridge the knowledge gap regarding modern C++ features.

Future research should expand this analysis to include proprietary codebases and third-party libraries (e.g., Boost, Qt) to determine if adoption patterns differ outside the open-source ecosystem. Additionally, investigating the specific barriers to adopting new standard features—such as compiler support or performance concerns—would provide deeper insights into developer behavior.

Summary updated

BibTeX
@inproceedings{wu2015how,
  author = {Di Wu and Lin Chen and Yuming Zhou and Baowen Xu},
  title = {{How do developers use C++ libraries? An empirical study}},
  booktitle = {Proceedings/Proceedings},
  year = {2015},
  doi = {10.18293/seke2015-9},
}
Figure