一句话:首个针对正则表达式开发周期的混合方法研究,揭示开发者在决策、验证、维护及安全风险认知上的普遍困难。
正则表达式广泛存在于现代语言与项目中,但既有研究多关注可读性。本文首次系统研究正则开发周期,聚焦开发者如何做决策、面临哪些困难、对严重风险是否了解。作者采用混合方法:问卷调研279名来自不同背景的专业开发者,并访谈17名开发者获取细节。结果显示正则不仅难读,还难搜索、难验证、难文档化;多数参与者未意识到关键安全风险,知情者也缺乏有效应对。研究提出语义化正则搜索引擎、改进输入生成器等未来方向。
Regular expressions (regexes) are a powerful mechanism for solving string-matching problems. They are supported by all modern programming languages, and have been estimated to appear in more than a third of Python and JavaScript projects. Yet existing studies have focused mostly on one aspect of regex programming: readability. We know little about how developers perceive and program regexes, nor the difficulties that they face. In this paper, we provide the first study of the regex development cycle, with a focus on (1) how developers make decisions throughout the process, (2) what difficulties they face, and (3) how aware they are about serious risks involved in programming regexes. We took a mixed-methods approach, surveying 279 professional developers from a diversity of backgrounds (including top tech firms) for a high-level perspective, and interviewing 17 developers to learn the details about the difficulties that they face and the solutions that they prefer. In brief, regexes are hard. Not only are they hard to read, our participants said that they are hard to search for, hard to validate, and hard to document. They are also hard to master: the majority of our studied developers were unaware of critical security risks that can occur when using regexes, and those who knew of the risks did not deal with them in effective manners. Our findings provide multiple implications for future work, including semantic regex search engines for regex reuse and improved input generators for regex validation.
@inproceedings{paperbot5275,
title = {Regexes are Hard: Decision-Making, Difficulties, and Risks in Programming Regular Expressions},
author = {Louis G. Michael and James Donohue and James C. Davis and Dongyoon Lee and Francisco Servant},
booktitle = {ASE},
year = {2019},
doi = {10.1109/ase.2019.00047}
}