面向静态分析的真实世界R代码剖析研究
On the Anatomy of Real-World R Code for Static Analysis
AI总结:
该研究对超5000万行真实R代码开展大规模静态分析,对比用户脚本与包源码的特性使用差异,为静态分析工具与解释器优化提供参考。
摘要:
研究背景与问题:R编程语言拥有庞大且活跃的社区,尤其在统计计算领域。其解释型特性支持多种特殊语法结构,例如运行时函数操作,这类特性会阻碍R程序的静态分析。同时,目前缺乏关于这些特性乃至R语言整体在实际中使用方式的现有研究。研究目标:本文对超5000万行真实世界R程序与包开展大规模静态分析,识别其特征与实际使用的特性;对比R用户脚本与包开发者实现的异同;为lintr包等静态分析工具、潜在的解释器优化提供洞见,并揭示未来研究方向。研究方法:分析4230份随论文提交的R脚本,以及19450个CRAN包的源码,覆盖超35万个R文件,收集并汇总目标特性的量化信息。研究结果:发现基于名称的索引操作、赋值与循环使用频率较高,而R的大多数反射函数使用频率较低;此外,在随论文提交的脚本中,既未发现测试函数,也少有对R外部函数接口(FFI)的大量调用。研究结论:R脚本与包源码在代码规模、引入其他包的方式、反射功能使用情况等方面存在差异;本文给出了高频使用、应被静态分析工具优先支持的特性,例如运算符赋值、函数调用,以及load等特定反射函数。
英文摘要:
CONTEXT The R programming language has a huge and active community, especially in the area of statistical computing. Its interpreted nature allows for several interesting constructs, like the manipulation of functions at run-time, that hinder the static analysis of R programs. At the same time, there is a lack of existing research regarding how these features, or even the R language as a whole are used in practice. OBJECTIVE In this paper, we conduct a large-scale, static analysis of more than 50 million lines of real-world R programs and packages to identify their characteristics and the features that are actually used. Moreover, we compare the similarities and differences between the scripts of R users and the implementations of package authors. We provide insights for static analysis tools like the lintr package as well as potential interpreter optimizations and uncover areas for future research. METHOD We analyze 4230 R scripts submitted alongside publications and the sources of 19450 CRAN packages for over 350000 R files, collecting and summarizing quantitative information for features of interest. RESULTS We find a high frequency of name-based indexing operations, assignments, and loops, but a low frequency for most of R's reflective functions. Furthermore, we find neither testing functions nor many calls to R's foreign function interface (FFI) in the publication submissions. CONCLUSION R scripts and package sources differ, for example, in their size, the way they include other packages, and their usage of R's reflective capabilities. We provide features that are used frequently and should be prioritized by static analysis tools, like operator assignments, function calls, and certain reflective functions like load.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。