一句话:系统评估 n-gram 与 Transformer 语言模型在 Scratch 积木式程序上的代码补全与缺陷发现可行性,发现积木结构降低可预测性但方法仍可用。
基于块的编程语言(如 Scratch)在编程教育与终端用户编程中日益流行。已有程序分析常借鉴自然语言处理技术,用语言模型对源代码建模,但这类方法所依赖的源代码规律性很大程度上源于文本编程语言强制的语法冗余,而积木式语言恰恰通过移除这些冗余来简化编程,因此语言模型在积木程序上的适用性尚不明确。本文针对流行的积木式语言 Scratch,采用最基础的 n-gram 模型与主流深度学习模型 Transformer 对积木程序建模,并以代码补全和缺陷发现为示例任务进行评估。实验证实,积木结构确实抑制了可预测性,语言模型在积木程序上的表现受到限制,但其使用仍然可行。该研究为改进积木式语言的工具与程序分析奠定了基础。
Block-based programming languages like Scratch are increasingly popular for programming education and end-user programming. Recent program analyses build on the insight that source code can be modelled using techniques from natural language processing. Many of the regularities of source code that support this approach are due to the syntactic overhead imposed by textual programming languages. This syntactic overhead, however, is precisely what block-based languages remove in order to simplify programming. Consequently, it is unclear how well this modelling approach performs on block-based programming languages. In this paper, we investigate the applicability of language models for the popular block-based programming language Scratch. We model Scratch programs using n-gram models, the most essential type of language model, and transformers, a popular deep learning model. Evaluation on the example tasks of code completion and bug finding confirm that blocks inhibit predictability, but the use of language models is nevertheless feasible. Our findings serve as foundation for improving tooling and analyses for block-based languages.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2302-03927,
title = {On the Applicability of Language Models to Block-Based Programs},
author = {Elisabeth Griebl and Benedikt Fein and Florian Obermüller and Gordon Fraser and René Just},
booktitle = {ICSE},
year = {2023},
doi = {10.1109/icse48619.2023.00199}
}