Program construction in imperative languages remains largely based on writing textual code that specifies sequences of instructions operating on program data. This approach requires developers to anticipate the effects of instructions on evolving data states, which increases cognitive load and the likelihood of errors during early and incremental development. This paper presents AlgoTouch, an execution-based system for incremental construction of imperative programs through direct manipulation of program data. Rather than assembling syntactic structures, programs are constructed by executing concrete data transformations that are recorded and incorporated into an internal intermediate representation. AlgoTouch relies on an explicit notional machine that exposes data storage, computation, and control flow, enabling continuous alignment between observed execution and program structure. A central contribution of the system lies in its deterministic synthesis of control structures from execution behavior. Conditional statements are derived from observed comparisons, while iterative behaviors are encapsulated in loop macros that support non-linear and incremental construction. This design enables partial and incomplete programs to be executed, refined, and completed while preserving semantic consistency. AlgoTouch automatically generates correct and readable programs in several mainstream imperative languages, including Python, C, C++, and Java. The system is evaluated through engineering-level validation on a representative set of algorithmic benchmarks, demonstrating correctness, expressiveness, robustness, and language independence. By integrating execution, construction, and code generation within a unified architecture, this work introduces an alternative model for interactive program construction and contributes a new class of execution-centered development systems.
翻译:摘要:指令式语言中的程序构造仍然主要基于编写文本代码,这些代码指定了对程序数据进行操作的指令序列。这种方法要求开发者预知指令对不断变化的数据状态产生的影响,这增加了认知负荷,并在早期和增量开发过程中增加了出错的可能性。本文提出了AlgoTouch,一个基于执行的系统,通过直接操作程序数据来实现指令式程序的增量构造。程序不是通过组装语法结构来构建,而是通过执行具体的数据转换来构建,这些转换被记录并整合到一种内部中间表示中。AlgoTouch依赖于一个显式的“概念机器”,它暴露了数据存储、计算和控制流,从而使观察到的执行结果与程序结构之间能够持续对齐。该系统的核心贡献在于它能够根据执行行为确定性地综合出控制结构。条件语句源于观察到的比较结果,而迭代行为则被封装在支持非线性和增量构造的循环宏中。这种设计使得部分和不完整的程序能够在保持语义一致性的前提下被执行、优化和完成。AlgoTouch能以包括Python、C、C++和Java在内的几种主流指令式语言自动生成正确且可读的程序。该系统通过在一组具有代表性的算法基准测试上进行工程级别的验证,证明了其正确性、表现力、鲁棒性和语言无关性。通过将执行、构造和代码生成整合在一个统一的架构中,本文为交互式程序构造引入了一种替代模型,并贡献了一类新的以执行为中心的开发系统。