Search this blog

06 June, 2008

Live coding

Never saw that in games. Some games use scripting languages, but that's kinda different, they are limited usually to AI or gameplay. And usually you can't change a script while it's running. It's a shame because it's surely possible to do that for non interpreted languages as well. It's Microsoft edit-and-continue, a similar stuff in java was implemented by ZeroTurnaround.

p.s. Actually I'm lying, there are many interesting experiments about livecoding for games. But nothing is publicly available, and it's strange considering that livecoding is nothing too strange (lisp... smalltalk!) and it's used in other fields (to make music?!? weird!).

Update: I've found this paper to be an intersting read... It's an edit-and-continue implementation, in C#, out of the IDE, that was used in a 3d Virtual Reality application called goblin. It's using the .net framework, so it doesn't deal with native assembly code, but that could be done as well, the key point is not having a JIT to compile the bytecode, but using a language/compiler that has enough metadata to perform the trick.

Update: This is very intersting as well. Well written


Unknown said...

We've had a long tradition of being able to dynamically load code. Back in the days of Jak it was quite the touted feature of GOAL. Now with some finagling from SN systems we can reload .o files as well. Not quite as snappy but still much, much faster than recompiling and reloading.

All our scripts are reloadable too... provided you have enough memory ;)

Anonymous said...

In Unity we can reload script assemblies on the fly while the game is running as well. State of objects is serialized and restored back after reload is done. Of course if your changed script removes some variables or adds new ones, then old values will be lost and new ones will be default for those.

Anonymous said...

Re-loadable code is possible. We do this on PC, more complicated on Consoles. And this apply to native code and/or scripts. The idea is similar to a serialization process for data and DLL swapping for code. TiZ

Nick said...

As Aras implied, if you design your script system for it, you can do it. It's particularly easy if you are running your own virtual machine since all aspects of execution are under your control. I prefer to include on the fly script modification in most of my engines.

DEADC0DE said...

I like Unity. And I know that it suppports dynamic script reloading. Actually I wanted to add a link to Unity in the article, but then I forgot (sorry, my posts are always done in a rush).
But that's easier as it's only about scripts, I was hinting about the ability of doing it for native code, that's possible as TiZ says. Possible, but not easy, and not common, so I felt it was an interesting thing to blog on.