paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Lightweight Polyglot Code Transformation Language

一种轻量级的多语言代码转换语言
PLDI 8(PLDI)2024匹配度 3/10 · 论文属于程序转换与代码重构方向的PL/软件工程工作,具备工业落地和问题驱动特点,与用户对工程实现的偏好部分契合;但它不涉及静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户核心研究问题距离较远。引用 1 inbox
Ameya Ketkar, Daniel Ramos, Lazaro Clapp, Raj Barik, Murali Krishna Ramanathan
crossref: 2026-09-10

AI 速览

一句话:提出声明式多语言代码转换 DSL,通过组合、排序和流扩展轻量匹配替换,支持相互依赖的跨语言重构。

在大型多语言代码库中,API 迁移、死代码清理等维护任务缺乏兼具表达力和通用性的自动化工具:语言专用重写工具造成碎片化,通用匹配替换工具表达力有限。本文提出一种声明式 DSL,用组合、排序与流来控制相互依赖的跨语言代码变换,将轻量匹配替换扩展到多语言场景。作者实现开源工具 Polyglot Piranha 并在工业环境部署。三个案例研究删除 21 万行死代码、迁移 2 万行代码,覆盖 1611 个 pull request;与先进替代方案相比,所开发工具更快、更简洁且更易维护。

问题
大型多语言代码库中的 API 迁移、死代码清理等自动化维护任务,缺少既通用又有足够表达力的代码转换工具。
方法
设计一种声明式 DSL,通过组合、排序和流来表达相互依赖的多语言代码变换,并实现开源工具 Polyglot Piranha。
评估
在工业环境部署,并通过三个案例研究统计删除与迁移代码行数、pull request 数量,同时与现有先进工具比较速度、简洁性和可维护性。
原文摘要(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) languagespecific 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 P olyglot P iranha , 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.

链接与引用

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

BibTeX
@article{paperbot2518,
  title = {A Lightweight Polyglot Code Transformation Language},
  author = {Ameya Ketkar and Daniel Ramos and Lazaro Clapp and Raj Barik and Murali Krishna Ramanathan},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {PLDI},
  year = {2024},
  doi = {10.1145/3656429}
}