Jump to content

Recent Comments

- - - - -

Runtime Compiled C++

4: Adsense

I came across the Runtime-Compiled C++ project the other day and I'm intrigued. I've always been fascinated by scripting, virtual machines, reflection and other dynamic runtime stuff that adds flexibility into development. The Unreal 4 engine also has this with the "Hot Reload" feature, so I can see it really becoming more popular.

I'm interested in what effect this new sort of dynamically compiled C++ will have on scripting in particular.

One of the use cases for scripting has always been because you can change the script and modify behaviours quickly without having to stop and recompile your own game. Runtime-compiled C++ will blow that out of the water, especially when you see that it also has crash protection built in (eg: a crash won't kill your game).

Naturally, scripting will still have a valid place in development - script languages are often simpler for non-developers to use and often present functionality at a higher level than how you'd code C++ or any other low level language. But it does make me wonder whether this runtime compiled stuff will move some people away from scripts.

I'm going to grab the runtime-compiled code and have a play around with it.

Jun 17 2012 09:19 AM
Interesting project but for me it doesn't really address the key features of scripting:

  • Users don't require any tools other than a text editor installed to change moddable scripts
  • Script language can be chosen that best suits the domain that is being scripted

Compilation model is one of the least significant things for me that makes C++ a poor choice to use for expressing the high level concepts that a scripting system would address.
Jun 17 2012 10:28 AM
I agree entirely. I think the prime reason for this sort of tech has to be for those scenarios where performance is paramount. And even then, the JIT systems implemented in script libraries nowadays will challenge that assertion.

Still, it's an interesting project.
Jun 17 2012 11:14 AM
Glad you liked our project. Our primary goal is to make it possible to use C++ for rapid iteration for C++ developers, however we also believe the approach can be extended to other use cases avoiding the issues mentioned by Aardvajk.

The compilation tool we currently use in the prototype is the Visual Studio compiler, for which a free version exists. Developers don't even need to use the Visual Studio IDE - we have an example where people can write code in the prototype console. Future versions could ship with an open source compiler such as LLVM + Clang, avoiding the need for any installed tools.

The actual language itself is an issue which can be dealt with in a few approaches:
  • via cross-compilation, see HipHop for PHP as to why that might be a good approach
  • through a DSL which is based around C++ (see Games Programming Gems 8, DSLs in Game Engines)
  • through a graphical tool which outputs C++ but allows the designers to work with symbols
There will always be cases where scripting is a preferred approach, but we hope to offer a viable alternative. We hope to write more about why this is needed in future.
/ abcdef44
Jun 18 2012 01:23 AM
Interesting. I could imagine using it on large projects alike Flightgear for ex. Now you could have a meal while waiting for fgfs to recompile or searching through the code. Hence it would speed up work nicely. Should I try that on fgfs with Eclipse or will such not work?
Jun 18 2012 03:40 AM
We only support windows at the moment, with Visual Studio as the IDE. However only a few changes are needed to add a new compiler, probably less work than is needed to make changes to the codebase to support this style of approach (changes are required to make the code hot swappable).
Jun 18 2012 08:53 AM
Wow, I'd like to try this sometime.... my codebase is around 400k lines of code, and the recompile/link times can be painful when making small adjustments to the code.
Jun 18 2012 02:19 PM
I guess what interests me most now is what sort of changes you'd have to make to make your code hot swappable?
Jun 19 2012 12:27 AM
C++ has been used in a few engines for scripting, probably the best implementation (until Runtime Compiled C++ and UE4 demos) was in the C4 engine where scripts are written and compiled in C++ and designers use the script node graph tool. Honestly I think there will be a much larger push towards this in the future simply because of how much time gets burned near the tail end of a project due to bad code/scripts by designers (no offence designers we love you!) that your programmers now have to go in and fix / optimize. In my opinion it is so much more efficient to have dedicated gameplay script programmers working in C++ and designers using the node based / property grid system. If you have them working together as a team you will end up with optimal code, features, and usability.
Jun 19 2012 03:08 AM
@evolutional - take a look at the source code for one of the runtime objects or headers. Basically in the current prototype you derive from a base class, declare the class in a C++ file with a macro, and optionally declare headers as being runtime editable. There's a video of the later just gone up on the site.

@Saruman - this isn't C++ scripting, but runtime compiling and loading of C++. That I know of this is the first public example of this approach, though some developers have hot loaded dll's for similar functionality. The C4 example is actually not altering C++, but using a data driven GUI node graph which is interpretted to provide scripting functionality, akin to CryENGINE's Flowgraph or Unreal's Kismet. I agree with you on giving designers better tools than scripting to create gameplay, with visual tools being a great way to do that.
Jun 19 2012 03:16 AM

And even then, the JIT systems implemented in script libraries nowadays will challenge that assertion.

An important consideration for console developers is that data can't be executed due to content protection measures, so JIT systems can't be used. I know of several developers bitten by script performance on consoles, indeed Havok Script was developed in part to address this issue by creating a higher performance script interpreter for consoles.
Jun 19 2012 10:52 AM
@dougbinks Yes wrong terminology by me I just meant replacing scripting gameplay code with compiled C++ and I'm dead sure that you do in fact have the first public example as the topic interests me quite a lot :) I just meant that C4 took the approach of writing code in C++ that has traditionally been scripted and letting designers leverage visual tools. When you take this approach and merge it with Runtime Compiled C++ in my opinion it turns into the best possible solution.
Jun 19 2012 11:40 AM
Yes - that does sound like a great approach, since you can write new code for visual objects on the fly, then play with them. I was wondering about using this with Google's Blocky...

Note: GameDev.net moderates comments.