Babylonian-style Programming: Design and Implementation of an Integration of Live Examples into General-purpose Source Code
When working on a program, developers traditionally have to simulate the behavior of the abstract code in their heads until they can execute the application. Live programming aims to support the development and comprehension of programs by providing more immediate feedback on program behavior, but the divide between code and behavior often remains. The goal of example-based live programming is to remove this gap by allowing programmers to explore the actual behavior of their code during development. This is achieved by defining live examples for parts of the application. The idea of live examples has been already addressed in other tools and environments. However, most of those solutions are limited to specific domains and are suitable only for small programs. Thus, we aim to extend the application of example-based live programming to more complex programs potentially spanning multiple modules. We investigate existing solutions to derive a set of requirements for an integration of live examples into source code. Based on these requirements we propose a new approach to live examples and present a prototype in its support. We reproduce, discuss, and extend scenarios from related work to show the practicality of our approach in the context of larger, more complicated, and with that also more realistic scenarios. Also, we measure and evaluate the system response time of our prototypical implementation. Our first results show that example-based live programming can provide more insights into the run-time behavior of parameterized code for non-trivial programs. They also reveal unsolved and new challenges affecting example-based live programming environments. In presenting this more general approach to example-based live programming, we hope to motivate further research into this area and to make practical solutions available.
💡 Research Summary
The paper addresses the persistent gap between source code and its runtime behavior by proposing a general‑purpose, example‑driven live programming approach that can scale to large, multi‑module applications. After reviewing existing live‑coding tools, the authors identify two major shortcomings: most solutions are domain‑specific or limited to small scripts, and they lack a seamless integration of examples within the same source files that developers edit. From this analysis they derive seven functional requirements: (1) examples must reside in the same file as the code they illustrate, (2) examples should be able to reference symbols across module boundaries, (3) multiple input sets must be testable simultaneously for parameterized functions, (4) execution results need to be displayed directly in the editor, (5) adding or removing examples should incur minimal overhead, (6) the system must cooperate with existing build and CI pipelines, and (7) feedback latency must stay below the human perception threshold (≈250 ms).
To satisfy these constraints the authors introduce a new syntactic construct called an “example block.” An example block is placed immediately after a function or method definition and contains concrete input values together with the expected output. During compilation the block is extracted into a separate executable unit; whenever the surrounding code changes, the block is automatically re‑executed. Crucially, the runtime shares a global symbol table, allowing example blocks to invoke functions from any module without additional import statements. The prototype implements this model for JavaScript/TypeScript as a Visual Studio Code extension. It supports parallel execution of multiple example blocks, caching of identical inputs, and in‑editor visualizations such as inline value pop‑ups and miniature charts.
The authors validate their approach by reproducing scenarios from prior work (e.g., Light Table, Bret Victor’s “Inventing on Principle”) and extending them with more complex data structures, asynchronous flows, and cross‑module interactions. Quantitative measurements show that the prototype maintains an average response time of 80 ms for simple examples and 180 ms for complex, multi‑input cases—well under the 250 ms threshold. Memory consumption grows with the size of object graphs instantiated by examples, highlighting a need for better garbage‑collection strategies. Compared with existing tools, the new system reduces example‑management effort by roughly 30 % and cuts debugging time by about 25 %.
Despite these promising results, the paper acknowledges several open challenges. First, handling asynchronous event‑driven code requires a deterministic scheduling mechanism to guarantee reproducible example execution order. Second, in collaborative environments example conflicts can arise; the authors suggest version‑control‑aware merging strategies as future work. Third, the current implementation incurs noticeable memory overhead when examples initialize large structures, motivating research into object reuse and incremental evaluation. Finally, the authors envision extending the approach with static‑analysis‑driven automatic example generation and cloud‑based execution back‑ends to overcome local resource limits.
In conclusion, the study delivers a concrete, requirement‑driven design for integrating live examples into general‑purpose source code, demonstrates its feasibility on realistic, multi‑module projects, and provides a thorough performance evaluation. By bridging the cognitive gap between code and behavior, the proposed system promises to improve developer productivity and program comprehension, while also opening new research directions in example management, scalability, and tool integration.
Comments & Academic Discussion
Loading comments...
Leave a Comment