EG: A Tool For API Snippets |
Written by Ian Elliot |
Wednesday, 25 November 2020 |
As programmer's our modis operandi is to use existing APIs and turn them to novel uses. In order to do this we rely on good examples of how APIs are used. This is where EG, a tool that mines codebases and shows the common, idiomatic usage examples for API methods, can help. EG stands for Exempla Gratis and it is detailed in a paper Exempla Gratis (E.G.): Code Examples for Free, presented at the 28th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE ’20). This event took place as a virtual event between November 8–13, 2020 and the paper by Celeste Barnaby et al, affiliated with Facebook where the tool was developed, UC Berkeley and Harvard is now available on arXiv. Explaining why a tool to aid in the discovery of free code examples was needed, the paper states: Application programming interfaces (APIs) are becoming a pervasive component of modern software engineering. A core challenge for software engineers in industry is to use existing APIs in idiomatic ways within their organization. In order to do this, developers often search for API documentation and usage examples. However, this can be especially challenging in companies where many APIs are proprietary. Because those proprietary APIs are only documented within the company by its engineers, there is no externally crowdsourced documentation or examples posted on sites like StackOverflow. The paper goes on to explain how EG works, which is by indexing a large code corpus: Given a query method, it assembles a list of method bodies in the corpus containing that method, then finds the maximal subtree that contains the query API and is part of a meaningful proportion of methods. EG then reconstructs this subtree into a succinct, relevant and representative code example. EG was integrated into Facebook’s internal code search tool for the Hack language and evaluated on open-source GitHub projects written in Python. It 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: A survey with Facebook developers shows that EG examples are preferred to code search results 97% of the time, and that 100% of developers agreed that the color-coding of the common usage pattern in EG examples is helpful. More InformationExempla Gratis (E.G.): Code Examples for Free by Celeste Barnaby, Koushik Sen, Tianyi Zhang, Elena Glassman, Satish Chandra Related ArticlesFacebook Introduces Hack, A Better PHP
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Wednesday, 25 November 2020 ) |