paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Exempla gratis (E.G.): code examples for free

Exempla gratis (E.G.):免费的代码示例
FSE Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering2020匹配度 2/10 · 论文聚焦于从代码库挖掘 API 惯用示例并集成到代码搜索,属于开发者工具/程序分析应用;与用户核心关注的 LLM/Agent 与静态分析/形式化验证、浮点程序分析、贝叶斯程序分析等方向几乎没有交集。仅工业落地和程序分析标签构成弱相关。引用 0 inbox
Celeste Barnaby, Koushik Sen, Tianyi Zhang, Elena Glassman, Satish Chandra
crossref: 2026-09-12

AI 速览

一句话:提出工具 EG,通过挖掘代码库自动生成简洁、具代表性的 API 惯用示例,并集成到 Facebook 代码搜索中。

现代软件开发中,程序员常需借助文档和代码搜索来回忆 API 的正确用法,但高质量 API 示例的整理与维护成本很高,而从公司级代码搜索中检索到的示例又往往冗长、难以快速审阅。本文提出工具 EG,它通过挖掘代码库,为 API 方法自动找出常见且惯用的使用示例。EG 被集成到 Facebook 内部面向 Hack 语言的代码搜索工具中,并在 Python 开源项目上进行了评估。作者还将 EG 与代码搜索结果以及知名编程网站 ProgramCreek 上的手写示例进行对比。结果显示,EG 生成的示例更加简洁、更具代表性,包含的多余语句更少;此外,一项面向 Facebook 开发者的调查表明,在 97% 的情况下开发者更偏好 EG 生成的示例。

问题
API 使用示例难以高质量地人工整理和维护,而从代码搜索中检索到的示例往往冗长、包含大量无关语句,开发者需要花费额外精力筛选。
方法
EG 工具挖掘代码库,为 API 方法识别并展示常见、惯用的用法示例;该工具集成到 Facebook 内部 Hack 代码搜索中,并在 Python 开源项目上评估。
评估
将 EG 与代码搜索结果及 ProgramCreek 手写示例对比,EG 示例更简洁、更具代表性且多余语句更少;Facebook 开发者调查显示 97% 的情况下更偏好 EG 示例。
原文摘要(Abstract)

Modern software engineering often involves using many existing APIs, both open source and – in industrial coding environments– proprietary. Programmers reference documentation and code search tools to remind themselves of proper common usage patterns of APIs. However, high-quality API usage examples are computationally expensive to curate and maintain, and API usage examples retrieved from company-wide code search can be tedious to review. We present a tool, EG, that mines codebases and shows the common, idiomatic us-age examples for API methods. EG was integrated into Facebook’s internal code search tool for the Hack language and evaluated on open-source GitHub projects written in Python. EG was also compared against code search results and hand-written examples from a popular programming website called ProgramCreek. Compared with these two baselines, examples generated by EG are more succinct and representative with less extraneous statements. In addition, a survey with Facebook developers shows that EG examples are preferred in 97% of cases.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot5830,
  title = {Exempla gratis (E.G.): code examples for free},
  author = {Celeste Barnaby and Koushik Sen and Tianyi Zhang and Elena Glassman and Satish Chandra},
  booktitle = {FSE},
  year = {2020},
  doi = {10.1145/3368089.3417052}
}