C/C++ is a prevalent programming language. Yet, it suffers from significant memory and thread-safety issues. Recent studies have explored automated translation of C/C++ to safer languages, such as Rust. However, these studies focused mostly on the correctness and safety of the translated code, which are indeed critical, but they left other important quality concerns (e.g., performance, robustness, and maintainability) largely unexplored. This work investigates strengths and weaknesses of three C-to-Rust translators, namely C2Rust (a transpiler), C2SaferRust (an LLM-guided transpiler), and TranslationGym (an LLM-based direct translation). We perform an in-depth quantitative and qualitative analysis of several important quality attributes for the translated Rust code of the popular GNU coreutils, using human-based translation as a baseline. To assess the internal and external quality of the Rust code, we: (i) apply Clippy, a rule-based state-of-the-practice Rust static analysis tool; (ii) investigate the capability of an LLM (GPT-4o) to identify issues potentially overlooked by Clippy; and (iii) perform a manual analysis of the issues reported by Clippy and GPT-4o. Our results show that while newer techniques reduce some unsafe and non-idiomatic patterns, they frequently introduce new issues, revealing systematic trade-offs that are not visible under existing evaluation practices. Notably, none of the automated techniques consistently match or exceed human-written translations across all quality dimensions, yet even human-written Rust code exhibits persistent internal quality issues such as readability and non-idiomatic patterns. Together, these findings show that translation quality remains a multi-dimensional challenge, requiring systematic evaluation and targeted tool support beyond both naive automation and manual rewriting.


翻译:C/C++ 是一种主流的编程语言,但它存在严重的内存和线程安全问题。近期研究探索了将 C/C++ 自动翻译为更安全的语言(例如 Rust)的方法。然而,这些研究主要关注翻译代码的正确性与安全性——这固然至关重要,但其他重要的质量考量(例如性能、健壮性和可维护性)在很大程度上尚未得到充分探究。本研究调查了三种 C 到 Rust 翻译工具的优势与不足,即 C2Rust(一种转译器)、C2SaferRust(一种基于 LLM 引导的转译器)和 TranslationGym(一种基于 LLM 的直接翻译工具)。我们以人工翻译为基准,对流行 GNU coreutils 工具集翻译后的 Rust 代码进行了多个重要质量属性的深入定量与定性分析。为评估 Rust 代码的内部与外部质量,我们:(i)应用了 Clippy,一种基于规则、代表当前最佳实践的 Rust 静态分析工具;(ii)探究了大型语言模型(GPT-4o)识别可能被 Clippy 遗漏的问题的能力;(iii)对 Clippy 和 GPT-4o 报告的问题进行了人工分析。我们的结果表明,虽然较新的技术减少了一些不安全和非惯用的模式,但它们常常引入新的问题,揭示了在现有评估实践中不可见的系统性权衡。值得注意的是,在所有质量维度上,没有任何一种自动化技术能够持续达到或超越人工编写的翻译代码,但即便是人工编写的 Rust 代码也表现出持续的内部质量问题,例如可读性和非惯用模式。总之,这些发现表明,翻译质量仍然是一个多维度的挑战,需要超越简单自动化和手动重写的系统性评估及有针对性的工具支持。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
【经典书】现代C语言教程,408页pdf手写教你写C代码
专知会员服务
66+阅读 · 2022年8月5日
【干货书】C++实战编程指南,附549页pdf与Slides
专知会员服务
84+阅读 · 2021年4月23日
Effective.Modern.C++ 中英文版,334页pdf
专知会员服务
68+阅读 · 2020年11月4日
【2020新书】C语言编程傻瓜式入门,第二版,464页pdf
专知会员服务
66+阅读 · 2020年10月15日
专知会员服务
82+阅读 · 2020年9月28日
【经典书】算法C语言实现,Algorithms in C. 672页pdf
专知会员服务
82+阅读 · 2020年8月13日
【经典书】C++编程:从问题分析到程序设计,1491页pdf
专知会员服务
65+阅读 · 2020年8月11日
【2020新书】现代C++初学者指南,301页pdf
专知会员服务
163+阅读 · 2020年7月24日
社区分享 | TensorFlow Lite C++ API 开源案例教程
TensorFlow
10+阅读 · 2020年11月7日
Effective.Modern.C++ 中英文版,334页pdf
专知
26+阅读 · 2020年11月4日
82页《现代C++教程》:高速上手C++ 11/14/17/20
专知
21+阅读 · 2020年10月19日
机器翻译学术论文写作方法和技巧
清华大学研究生教育
11+阅读 · 2018年12月23日
各编程领域最好的入门书籍
程序猿
28+阅读 · 2018年7月29日
福利 | 当Python遇上大数据与机器学习,入门so easy!
清华大学:刘洋——基于深度学习的机器翻译
人工智能学家
12+阅读 · 2017年11月13日
神经网络机器翻译原理:LSTM、seq2seq到Zero-Shot
北京思腾合力科技有限公司
11+阅读 · 2017年8月10日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
VIP会员
相关VIP内容
【经典书】现代C语言教程,408页pdf手写教你写C代码
专知会员服务
66+阅读 · 2022年8月5日
【干货书】C++实战编程指南,附549页pdf与Slides
专知会员服务
84+阅读 · 2021年4月23日
Effective.Modern.C++ 中英文版,334页pdf
专知会员服务
68+阅读 · 2020年11月4日
【2020新书】C语言编程傻瓜式入门,第二版,464页pdf
专知会员服务
66+阅读 · 2020年10月15日
专知会员服务
82+阅读 · 2020年9月28日
【经典书】算法C语言实现,Algorithms in C. 672页pdf
专知会员服务
82+阅读 · 2020年8月13日
【经典书】C++编程:从问题分析到程序设计,1491页pdf
专知会员服务
65+阅读 · 2020年8月11日
【2020新书】现代C++初学者指南,301页pdf
专知会员服务
163+阅读 · 2020年7月24日
相关资讯
社区分享 | TensorFlow Lite C++ API 开源案例教程
TensorFlow
10+阅读 · 2020年11月7日
Effective.Modern.C++ 中英文版,334页pdf
专知
26+阅读 · 2020年11月4日
82页《现代C++教程》:高速上手C++ 11/14/17/20
专知
21+阅读 · 2020年10月19日
机器翻译学术论文写作方法和技巧
清华大学研究生教育
11+阅读 · 2018年12月23日
各编程领域最好的入门书籍
程序猿
28+阅读 · 2018年7月29日
福利 | 当Python遇上大数据与机器学习,入门so easy!
清华大学:刘洋——基于深度学习的机器翻译
人工智能学家
12+阅读 · 2017年11月13日
神经网络机器翻译原理:LSTM、seq2seq到Zero-Shot
北京思腾合力科技有限公司
11+阅读 · 2017年8月10日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员