Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using Boo as a scripting language in my C#/.NET game via the in memory compiler with it and I really love it, however I'm having trouble deciding when I should load my scripts.

This is my first time using a scripting language with a game and my first time implementing one into anything.

Currently I load scripts as needed - this works well. However I end up with a lot of assemblies loaded(one per file currently, as I'm just loading each when it is needed) and realized as my game expands this could turn into a large number of assemblies - is this bad? I guess I could get around this by managing appdomains and loading/unloading after scripts haven't been used for a long time. I currently don't use any appdomains for my scripts at all so I end up with a lot of appdomains due to them getting recompiled while working on them.

Loading all scripts at the same time would be a big overhead when loading as my loading times are quite fast right now, rather big memory usage due to them all being loaded at the same time, and if I want to dynamically recompile scripts when they're changed while the game is running I have to recompile all of them. Currently I can just recompile them one file at a time. The benefits of this is that I obviously have a lot less assemblies loaded.

I guess my real question is having a lot of small assemblies loaded in C# a bad thing compared to one large assembly, and compiling scripts during gameplay vs a big loading screen?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Your question basically consist of two smaller ones:

  • If it's better to load all scripts while loading the game?
    Loading all scripts when the game is loading has advantage of easing game-time coding. I mean you know all the scripts are loaded and you can call whatever you want whenever you want. But it also result in larger memory consumption and an increase in game load time. Exactly Opposite to that when you load scripts on the run, you'll save some memory and decrease load time, but instead you need to make sure each script is loaded before calling it, and if loading an script takes noticeable time (maybe more than 0.1s) then you need to somehow predict script usage and load it before you need it in a separated thread. I guess gameplay time loading is just an optimization you shouldn't think about before you get an actual problem with performance.

  • If it's better to split your scripts between several files or put them all into one large file?
    It is better to split scripts whether you are loading them separately during gameplay time or loading them all at once while loading the game. You've pointed out the main problem yourself, if you combine all scripts into one file you'll need to recompile everything even with smallest changes. Also note that if you create a large file, later changing it will also be hard for game designer, even if you are the game designer. Reading ,editing and maintaining a file with 200 lines of code, is a lot harder than working with 10 files each 30 lines of code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.