A Lightweight Polyglot Code Transformation Language (Video, PLDI 2024)
Ameya Ketkar, Daniel Ramos, Lazaro Clapp, Raj Barik, and Murali Krishna Ramanathan
(Gitar, USA; Carnegie Mellon University, USA / INESC-ID, Portugal / Universidade de Lisboa, Portugal; Gitar, USA; Gitar, USA; Amazon Web Services, USA)
Abstract: In today's software industry, large-scale, multi-language codebases are the norm. This brings substantial challenges in developing automated tools for code maintenance tasks such as API migration or dead code cleanup. Tool builders often find themselves caught between two less-than-ideal tooling options: (1) language-specific code rewriting tools or (2) generic, lightweight match-replace transformation tools with limited expressiveness. The former leads to tool fragmentation and a steep learning curve for each language, while the latter forces developers to create ad-hoc, throwaway scripts to handle realistic tasks.
To fill this gap, we introduce a new declarative domain-specific language (DSL) for expressing interdependent multi-language code transformations. Our key insight is that we can increase the expressiveness and applicability of lightweight match-replace tools by extending them to support for composition, ordering, and flow. We implemented an open-source tool for our language, called PolyglotPiranha, and deployed it in an industrial setting. We demonstrate its effectiveness through three case studies, where it deleted 210K lines of dead code and migrated 20K lines, across 1611 pull requests. We compare our DSL against state-of-the-art alternatives, and show that the tools we developed are faster, more concise, and easier to maintain.
Article: https://doi.org/10.1145/3656429
Supplementary archive: https://doi.org/10.5281/zenodo.10948026 (Badges: Artifacts Available, Artifacts Evaluated — Functional)
ORCID: https://orcid.org/0000-0003-0402-0239, https://orcid.org/0000-0002-2147-2176, https://orcid.org/0009-0001-9773-7273, https://orcid.org/0000-0003-4779-1391, https://orcid.org/0000-0002-6568-017X
Video Tags: Source-code rewriting, Automated refactoring, Code cleanup, pldi24main-p359-p, doi:10.1145/3656429, doi:10.5281/zenodo.10948026, orcid:0000-0003-0402-0239, orcid:0000-0002-2147-2176, orcid:0009-0001-9773-7273, orcid:0000-0003-4779-1391, orcid:0000-0002-6568-017X, Artifacts Available, Artifacts Evaluated — Functional
Presentation at the PLDI 2024 conference, June 24–28, 2024, https://pldi24.sigplan.org/
Sponsored by ACM SIGPLAN,
Информация по комментариям в разработке