I'm making a programming game in C++ and Qt, but have a unique constraint as far as my choice in engines go; because it's possible that the player may write code that loops infinitely or takes a long time to run, I need to be able to terminate a scripting engine's execution at any time. I asked a question about this on StackOverflow yesterday, and unfortunately there's no way to kill a thread in C++ without potentially causing resource problems (locks not being released, memory leaks, etc.).
I was advised that I need a scripting engine that allows me to terminate scripts at will without jeopardizing the player's session. What options do I have, subject to these requirements?
- It must be embeddable in a C++ application.
- It must work on Windows, Mac, Linux, and Android.
- It doesn't need to be a mainstream language like Python, but it must be teachable to someone entirely new to programming.
- Haskell, Scheme, Prolog, etc. are right out unless you can convince me that they would be good first languages for an 11-year-old to learn.
- I need to be able to stop a script's execution at any time.
- I can't kill the thread itself, so why not kill the scripting engine?
- I should have full control over the scripting context (e.g. what objects/functions/types are available).
- Qt integration would be nice, but is optional (I can make my own wrapper).
- It doesn't need to be very fast -- the player's code will run repeatedly, but no more than once every half-second or so.
- I must be able to call C++ functions from this scripting engine, and I must be able to call functions written in this scripting language from C++.