What programming language features are well suited for developing a live coding framework?

前端 未结 8 2175
孤城傲影
孤城傲影 2021-02-07 17:39

I would like to build a \"live coding framework\".

I should explain what is meant by \"live coding framework\". I\'ll do so by comparing live coding to traditional codin

8条回答
  •  攒了一身酷
    2021-02-07 18:05

    I have implemented a live coding feature in Lua as part of the ZeroBrane Studio IDE. It works exactly as you described by reloading the application when a change in the code is made. I'm working on possible improvements to modify values at run-time to avoid full reload of the application. It's a pure Lua-based solution and doesn't require any modifications to the VM.

    You can see the demo of the live coding as currently implemented here: http://notebook.kulchenko.com/zerobrane/live-coding-in-lua-bret-victor-style.

    In terms of language features used/required, I rely on:

    1. the ability to interrupt/resume a running application (this is based on debug.hook and error() calls),
    2. the ability to interact with the (unmodified) application remotely (this is done based on debug.hook, TCP interactions with select() support to detect if a new request is being sent from the host machine, as well and on coroutines to switch between the main application and the live coding module), and
    3. the ability to inject new code into the application (this mechanism is also using co-routines, but I'm sure there are alternatives). There is also a possibility to inject just a modified fragment, but it need to be at the level of a function, and if this function is a local to some other function, you need to include that too and so on.

提交回复
热议问题