Sign in to follow this  

Random questions

Recommended Posts

Ysaneya    1383
Hi ho, It's quite funny that i'm a regular member of gamedev since 5 years now and never visited this forum before. Well, today i did, and so far i'm impressed. Awesome work, Witchlord! I'm working on a game engine (including 3D, sound, networking, GUI, input, etc..) that i hope to become commercial one day. It's starting to grow quite a lot (currently 65k lines for the 3D engine "only"), and so i'm slowly starting to look for a script language easy to interface with. 1. I particularly appreciate the ease-of-use of AS, its C-like syntax and how easy it is to call application code. I've read the overview, but it's not quite clear how you can get from the application the return value of a function executed by AS ? Can it return objects, arrays of objects or structures too ? 2. So far i was considering seriously Python and LUA. Did anybody make a performance comparison between Python, LUA and AS (or any other script language) ? Since AS works on top of a virtual machine with strong typing (as opposed to Python and LUA), i am guessing AS should win quite easily.. Thanks! Y.

Share this post

Link to post
Share on other sites
Rain Dog    136
In some previous tests it was discovered that LUA was approximately 50% faster than AS, then witchlord made some changes and optimizations and i believe the last statistic was that AS is now 50% faster than LUA.

Lua: 20.499574 sec
AngelScript: 23.772902 sec 1.9.1-WIP1
1.9.2 = 10% faster = 21.47
ASM VM 50% faster = 14.31
1.10 final 10% faster = 12.8
new asm promises 25-50% increase in speed.

These are the results just extrapolated from the performance increases based on the different versions, and
do not promise to be correct, only a guideline from which to follow. As you can see, it thereby follows that AS is
now approximately 40% faster than LUA.


[Edited by - Rain Dog on November 3, 2004 5:19:24 PM]

Share this post

Link to post
Share on other sites
WitchLord    4677
Hello Ysaneya, and welcome to my forum

This forum is quite new (it was created in March), so it's not so strange that you never noticed it before.

1. Yes, AngelScript can return objects. It will do this using a calling convention similar to that of C/C++. Unfortunately this means that it is a bit cryptic, since the application needs to pass a pointer to the memory that should receive the object. Here's an example code for that:

asIScriptContext *ctx;
ctx->Prepare(engine->GetFunctionIDByDecl(0, "Vector3 TestVector3()"));

// Allocate memory for the returned object
// Note: The memory should be uninitialized
char buffer[sizeof(Vector3)];
Vector3 *ret = (Vector3*)buffer;

// Pass the pointer to the memory as first parameter
// Note: This parameter is hidden and wasn't declared by the script
ctx->SetArguments(0, (asDWORD*)&ret, 1);
int r = ctx->Execute();
// Use the returned object, or copy it to a more permanent location

// Call destructor on the returned object (only if the execution was successful)


I'm working on automatizing this, so that the application can simply call a function with the parameters it wishes to pass to the script.

2. As Rain Dog said, Lua was found to be almost 50% faster than AngelScript. I couldn't allow that of course so I have since worked hard on improving the speed of AS. Since version 1.9.0 AS has become between 2 and 3 times faster, depending on the situation. And there is still more that can be done.


Share this post

Link to post
Share on other sites

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