Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

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.

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.

I would like to know not only what languages would be suitable for this kind of framework but, generally, what language features would make a framework such as this possible.

like image 204
JeremyFromEarth Avatar asked Oct 25 '11 02:10

JeremyFromEarth


People also ask

Which programming language is used for framework?

Ruby. Any list of programming languages and frameworks is probably going to include Ruby. The most significant reason behind its popularity is its full-stack framework, Ruby on Rails.

Which language is best for framework?

PHP. PHP is a server-side language commonly used for scripts, but it has gained popularity as a general, all-purpose language over the years. Some of the PHP frameworks available include CakePHP, CodeIgniter, Laravel, Symfony, Yii, and Zend.

Which programming language is used for development?

JavaScript and Python, two of the most popular languages in the startup industry, are in high demand. Most startups use Python-based backend frameworks such as Django (Python), Flask (Python), and NodeJS (JavaScript). These languages are also considered to be the best programming languages to learn for beginners.

Which programming language has most features?

Java is one of the most powerful programming languages that is currently used in more than 3 billion devices. Java is currently one of the most trending technology. It is used in desktop applications, mobile applications, web development, Artificial intelligence, cloud applications, and many more.


2 Answers

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.
like image 92
Paul Kulchenko Avatar answered Oct 24 '22 18:10

Paul Kulchenko


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)
like image 45
mikera Avatar answered Oct 24 '22 17:10

mikera