什么编程语言特性非常适合开发实时编码框架? [英] What programming language features are well suited for developing a live coding framework?

查看:189
本文介绍了什么编程语言特性非常适合开发实时编码框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个直播编码框架。

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 coding.

通常,在传统编程中,你编写代码,有时编译它,然后启动一个可执行文件或打开一个脚本在某种形式的翻译。如果要修改应用程序,必须重复此过程。实时编码框架允许在应用程序运行时根据需要更新代码,并根据需要重新加载。也许这种重新加载发生在每次包含代码的文件被更改或通过一些其他操作。代码中的更改随后会在应用程序运行时反映出来。没有必要关闭程序并重新编译并重新启动它。

Generally put, in traditional programming you write code, sometimes compile it, then launch an executable or open a script in some sort of interpreter. If you want to modify your application you must repeat this process. A live coding framework enables code to be updated while the application is running and reloaded on demand. Perhaps this reloading happens each time a file containing code is changed or by some other action. Changes in the code are then reflected in the application as it is running. There is no need to close the program and to recompile and relaunch it.

在这种情况下,应用程序是一个带有更新/绘制循环的窗口应用程序,最有可能使用OpenGL的图形,声音处理的音频库(SuperCollider? )和理想的网络库。

In this case, the application is a windowed app that has an update/draw loop, is most likely using OpenGL for graphics, an audio library for sound processing ( SuperCollider? ) and ideally a networking lib.

当然,我喜欢语言,虽然我不确定他们中的任何一个都非常适合这种架构。理想情况下,我会使用Python,Lua,Ruby或另一种更高级的语言。但是,一个朋友最近建议使用Clojure作为一种可能性,因此我也考虑了这一点。

Of course I have preferred languages, though I'm not certain that any of them would be well suited for this kind of architecture. Ideally I would use Python, Lua, Ruby or another higher level language. However, a friend recently suggested Clojure as a possibility, so I am considering it as well.

我想知道什么语言适合这种框架,但一般来说,什么语言特性会使这样的框架

推荐答案

Clojure有几乎所有你可能想要作为一个实时编码语言。主要亮点:

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


  • 互动式REPL - 您可以直接与正在运行的程序进行交互。即使我在做传统编程,我倾向于交互编写代码,并将我喜欢的位复制到源文件中。

  • 强大的并发支持 - 您可以启动使用(future(some-function))的代码轻松地执行并发后台任务。更重要的是,Clojure的STM和强调高性能不可变数据结构将会处理更细微的并发方面(例如,如果我在更新一个活动数据结构,而它正在呈现的时候会发生什么)

  • 库可用性 - 它是一种JVM语言,因此您可以从Java生态系统中获取所需的所有音频,视觉,IO或计算工具。很容易将它们包装在Clojure的一行或两行中,以便您获得所需函数的简洁界面

  • - 因为Clojure是一个< a href =http://en.wikipedia.org/wiki/Homoiconicity =nofollow>同语言语言,您可以利用Lisp的能力编写功能强大的宏扩展语言。您可以有效地构建要在实时环境中使用的确切语法,并让编译器执行所有在后台创建完整代码的艰巨工作。

  • 动态 - 这种方法的好处可以通过两种方式来论证,但是当尝试快速简洁地编写代码时,这当然是一个巨大的优势。

  • 的酷项目 - 你可能会发现很多人对类似的现场编码技术感兴趣的Clojure社区。
  • 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)

这篇关于什么编程语言特性非常适合开发实时编码框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆