Context In the first part of his 2012 presentation “Inventing on Principle” [31], Bret Victor gives a demo of a live code editor for Javascript which shows the dynamic history of values of variables in real time. This form of live programming has become known as “probes” [3, 15, 18]. Probes provide the programmer with permanent and continuous insight into the dynamic evolution of function or method variables, thus improving feedback and developer experience. Inquiry Although Victor shows a working prototype of live probes in the context of Javascript, he does not discuss strategies for implementing them. Later work [18] provides an implementation approach, but this requires a programming language to be implemented on top of the GraalVM runtime [32]. In this paper we present LiveRec, a generic approach for implementing probes which can be applied in the context of many programming languages, without requiring the modification of compilers or run-time systems. Approach LiveRec is based on reusing existing debug protocols to implement probes. Methods or functions are compiled after every code change and executed inside the debugger. During execution the evolution of all local variables in the current stack frame are recorded and communicated back to the editor or IDE for display to the user. Knowledge It turns out that mainstream debug protocols are rich enough for implementing live probes. Stepwise execution, code hot swapping, and stack frame inspection provide the right granularity and sufficient information to realize live probes, without modifying compilers or language runtimes. Furthermore, it turns out that the recently proposed Debugger Adapter Protocol (DAP) [16] provides an evenmore generic approach of implementing live probes, but, in some cases, at the cost of a significant performance penalty. Grounding We have applied LiveRec to implement probes using stack recording natively for Java through the Java Debug Interface (JDI) [20], and through the DAP for Java, Python, C, and Javascript, all requiring just modest amounts of configuration code. We evaluate the run-time performance of all four probes prototypes, decomposed into: Compile-after-change, hot swap, single step overhead, and stack recording overhead. Our initial results show that live probes on top of native debug APIs can be performant enough for interactive use. In the case of DAP, however, it highly depends on characteristics of the programming language implementation and its associated debugging infrastructure. Importance Live programming improves the programmer experience by providing immediate feedback about a program’s execution and eliminating disruptive edit-compile-restart sequences. Probes are one way to shorten the programmer feedback loop at the level of functions and methods. Although probes are not new, and have been implemented in (prototype) systems, LiveRec’s approach of building live probes on top of existing and generic debug protocols promises a path towards probes for a host of mainstream programming languages, with reasonable effort.

, , ,
The Art, Science, and Engineering of Programming
Centrum Wiskunde & Informatica, Amsterdam (CWI), The Netherlands

van Gent, D., van Rozen, R., & van der Storm, T. (2024). Liverec: Prototyping probes by framing debug protocols. The Art, Science, and Engineering of Programming, 8(3), 16:1–16:36. doi:10.22152/