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

前端 未结 8 2179
孤城傲影
孤城傲影 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:13

    Clojure has pretty much everything you are likely to want as a live coding language. Main highlights:

    • Interactive REPL - so you can interact directly with your running program. Even when I'm doing "traditional programming" I tend to write code interactively and copy the bits I like into a source file later. Clojure is just designed to work this way - pretty much everything in your program is inspectable, modifiable and replaceable at runtime.
    • Great concurrency support - you can kick off concurrent background tasks trivially with code like (future (some-function)). More importantly, Clojure's STM and emphasis on high performance immutable data structures will take care of the more subtle concurrency aspects (e.g. what happens if I update a live data structure while it is in the middle of being rendered??)
    • Library availability - it's a JVM language so you can pull in all the audio, visual, IO or computational tools you require from the Java ecosystem. It's easy to wrap these in a line or two of Clojure so that you get a concise interface to the functions that you need
    • Macros - as Clojure is a homoiconic language you can take advantage of the Lisp ability to write powerful macros that extend the language. You can effectively build the exact syntax that you want to use in the live environment, and let the compiler do all the hard work of creating the complete code behind the scenes.
    • Dynamic typing - the benefits of this can be argued both ways, but it's certainly a huge benefit when trying to write code quickly and concisely.
    • Active community with a lot of cool projects - you're likely to find a lot of people interested in similar live coding techniques in the Clojure community.

    A couple of links you might find interesting:

    • Paul Graham on Lisp - beating the averages
    • Live Clojure coding example with the Overtone sound synthesizer (a frontend to SuperCollider)

提交回复
热议问题