Sign in to follow this  

Scripting speed?

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've thought some more about having a scripting language implemented in my game engine. I first thought Python would be a good idea, but it's nasty C API is a serious drawback... Although Boost.Python makes extending easier, but not embedding. I've discovered several languages, like AngelScript, GameMonkey, and Squirrel. GameMonkey, I believe, is used in the Omni-Bot library for Q3 games. Anyway, the question is, does anyone have any comparison or speed test on AngelScript Vs. LUA Vs. Squirrel Vs. GameMonkey Vs. Python?

Share this post


Link to post
Share on other sites
I dont have any information on speed, but in my own experience, Lua is a brilliant scripting language to use. You dont have to take my word for it, Lua is used in many commercial games. The only real problem with the language, is that it does not support C++, but that can be fixed via LuaBind.

Share this post


Link to post
Share on other sites
You don't typically care about speed for a scripting language, because the stuff that needs to be fast is not scripted. What you do often care about is memory use, though. In that respect, Python is probably the heaviest, and Lua is probably the lightest, with Squirrel being close. (All guessing here.)

Share this post


Link to post
Share on other sites
Yeh, when I mean "speed", I mean memory footprint, and of course how fast it really executes. Of course the things that need speed aren't scripted, but I'd still like the scripting to go as fast as possible. But, yes, memory footprint is more important.

What you mean, is that I should use LUA?

[Edited by - knutaldrin on July 9, 2007 4:14:12 AM]

Share this post


Link to post
Share on other sites
Quote:

Although Boost.Python makes extending easier, but not embedding.


Embedding has never been difficult with Python :
Calling Py_Initialize(), PyRun_SimpleString(), and Py_Finalize() is enough for basic embedding.
More complex embedding is hardly harder, and the documentation is quite good on this point.

Extending is another beast !!

Emmanuel

Share this post


Link to post
Share on other sites
Well, also, in addition to just running a string, I'd love to use files, as well as loading the files as a library kinda... Yes, I know I can just read the file, and use it as a param in PyRun_SimpleString()... I have gotten that to work, but it's simply too heavy...

Share this post


Link to post
Share on other sites
Quote:
Original post by knutaldrin
Well, also, in addition to just running a string, I'd love to use files, as well as loading the files as a library kinda... Yes, I know I can just read the file, and use it as a param in PyRun_SimpleString()... I have gotten that to work, but it's simply too heavy...


May I ask what you mean by too heavy?
Have you also tried PyRun_File?

Share this post


Link to post
Share on other sites
I think I might have decided on Squirrel: I like it's syntax, it's fast, and fairly easy to implement.

If anyone has any experienes with Squirrel, care to share them? :)

Share this post


Link to post
Share on other sites
Really you should evaluate each scripting language to see what fits your needs/wants, no one can tell you what language to use as they all have different strengths and weaknesses.

For my part, I personally like Lua, even more now that I've found out how easy it is to sandbox scripts/modules o.O (see journal...)

Share this post


Link to post
Share on other sites
Quote:
Original post by knutaldrin
Well, also, in addition to just running a string, I'd love to use files, as well as loading the files as a library kinda... Yes, I know I can just read the file, and use it as a param in PyRun_SimpleString()... I have gotten that to work, but it's simply too heavy...


The real stuff is explained here, and is quite easy :
http://www.python.org/doc/ext/pure-embedding.html

But nothing prevent you to use simple string like this :


PyRun_SimpleString("import MyStartingFile");
PyRun_SimpleString("MyStartingFile.MyStartingFunction()");


And do all your stuff in your 'MyStartingFile' python file...


Emmanuel

Share this post


Link to post
Share on other sites
Quote:
Original post by knutaldrin
If anyone has any experienes with Squirrel, care to share them? :)

I really like working with Squirrel. I first implemented it as a scripting language in my engine and I am now incorporating it into a commercial product. I would definitely rate it on par with lua, and i personally prefer it. I use SqPlus for binding (slightly modified) and it works just great.

Share this post


Link to post
Share on other sites
I've been curious about this myself. I'm trying to create scripted behaviors which can then be built into individual AIs for different units. However, I want to eventually have a LOT of units so the execution speed is important. I did some research on compiler theory and decided to write a simple scripting language which turned out severely limited but serves my specific purposes for this project quite well. The footprint is small and the speed is more than I hoped for. Running it on an old P3 700MHz, the virtual machine executed 650,000 instructions per sec (.65 MIPS).

Now, I'm trying to decide if it's worth using. Would Lua be able to handle executing possibly tens of thousands of objects simultansously (considering that scripts are fired off when a decision is made, not every frame)?

I'll be doing some stress-testing on Lua to see what it's capable of and would suggest the same for the OP. Delagating most of the high level functionality to the application and calling it from the script should allow for a lot of elbow room in script performance.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
boost::python can definitely be used for embedding.


SiCrane is back? Good!

More on topic, Promit has it right. Although depending on your game you might find "stuff you need to be fast" can vary with what you might expect. I've found Lua to be an excellent embedded language. The more I use it the more code I want to port from C++ to it to improve flexibility, and so far I haven't experienced any major slowdown.

Share this post


Link to post
Share on other sites
Allright, thanks for the reply :)

I'm still wanting to implement Python, but I'm afraid it'll be a major slowdown, as it's so huge and complex (but powerful :)).
Personally, I don't like LUA's syntax, but I like Squirrel's, so I'm considering him ;)

Also wanting to develop my own language, but that'll be too far a project, I don't even know where to start... I tried writing a brainf*** interpreter once, in php, still isn't finished xD

Share this post


Link to post
Share on other sites

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this