首页> 外文期刊>ACM transactions on software engineering and methodology >How C++ Templates Are Used for Generic Programming: An Empirical Study on 50 Open Source Systems
【24h】

How C++ Templates Are Used for Generic Programming: An Empirical Study on 50 Open Source Systems

机译:C ++模板如何用于泛型编程:对50个开源系统的实证研究

获取原文
获取原文并翻译 | 示例

摘要

Generic programming is a Key paradigm ror developing reusable software components. The inherent support for generic constructs is therefore important in programming languages. As for C++, the generic construct, templates, has been supported since the language was first released. However, little is currently known about how C++ templates are actually used in developing real software. In this study, we conduct an experiment to investigate the use of templates in practice. We analyze 1,267 historical revisions of 50 open source systems, consisting of 566 million lines of C++ code, to collect the data of the practical use of templates. We perform statistical analyses on the collected data and produce many interesting results. We uncover the following important findings: (1) templates are practically used to prevent code duplication, but this benefit is largely confined to a few highly used templates; (2) function templates do not effectively replace C-style generics, and developers with a C background do not show significant preference between the two language constructs; (3) developers seldom convert dynamic polymorphism to static polymorphism by using CRTP (Curiously Recursive Template Pattern); (4) the use of templates follows a power-law distribution in most cases, and C++ developers who prefer using templates are those without other language background; (5) C developer background seems to override C++ project guidelines. These findings are helpful not only for researchers to understand the tendency of template use but also for tool builders to implement better tools to support generic programming.
机译:通用编程是开发可重用软件组件的关键范例。因此,对通用构造的固有支持在编程语言中很重要。对于C ++,自从该语言首次发布以来,就一直支持通用构造,模板。但是,目前关于如何在开发实际软件中实际使用C ++模板知之甚少。在这项研究中,我们进行了一个实验,以研究实际中模板的使用。我们分析了50个开放源系统的1,267个历史修订版,其中包括5.66亿行C ++代码,以收集模板实际使用的数据。我们对收集的数据进行统计分析,并产生许多有趣的结果。我们发现以下重要发现:(1)模板实际上用于防止代码重复,但是这种好处很大程度上仅限于一些高度使用的模板; (2)函数模板不能有效替代C样式的泛型,并且具有C背景的开发人员在这两种语言结构之间没有显示出明显的偏爱; (3)开发人员很少使用CRTP(好奇递归模板模式)将动态多态性转换为静态多态性; (4)在大多数情况下,模板的使用遵循幂律分布,并且更喜欢使用模板的C ++开发人员是那些没有其他语言背景的开发人员; (5)C开发人员的背景似乎覆盖了C ++项目准则。这些发现不仅有助于研究人员了解模板使用的趋势,还有助于工具构建者实施更好的工具来支持通用编程。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号