Archived

This topic is now archived and is closed to further replies.

MickeyMouse

Best scripting language

Recommended Posts

My only question is what scripting language would you recommend for a big game engine that could be used for any action, adventure or RPG game. I''m interested in what are most popular scripting languages among game developers and why?

Share this post


Link to post
Share on other sites
python and lua are the big ones right now. Python is a somewhat more complex and featureful language, with a large runtime; Lua has a more lightweight syntax, and relies on customizable "metatables" to emulate things like OOP. Google is your friend.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Personally I use Lua for my little game engine. It''s very easy to setup and handle from Delphi or C/C++. Also the syntax is rather easy to learn (depends how you design the functions etc., of course).
Another plus, at least for me, is the size. The compiled Lua interpreter and toolkit DLLs are hardly 100k in size, where the Python DLL(s) are some 800k.
I also read somewhere that Lua was faster than Python.

Share this post


Link to post
Share on other sites
Lua is 3 times faster than python(benchmarked) and even if doesn''t support classes you can manage to do some nice OOP programming.The bigger problem is the garbage collector that is freakin'' slow.

Python is too big and slow for a realtime app I wouldn''t suggest it.Maybe for a RTS.

I''m personally developing a open source language that has many aspects of lua; is smaller has C-like syntax is as fast and IMO solves some real-time related issues I had with lua. Is still in alpha but is already stable(I''m just tring to make it rock solid )

already a couple of commecial engines are using it(one company hired me ) take a look here : http://squirrel.sourceforge.net

if not i''d go for lua.

Alberto

Share this post


Link to post
Share on other sites
i used lua in a realtime 3d engine and got performance problems with the garbage collector.
when i write scripts that are called once per frame and has some local variables the game pauses regularly for about 1/10s when gargabe is collected. not very nice...

Share this post


Link to post
Share on other sites
quote:

i used lua in a realtime 3d engine and got performance problems with the garbage collector.



I had the same experience in my past project.
That''s why I''ve started working on squirrel.

Alberto

Share this post


Link to post
Share on other sites
i currently have written a rtD, a runtime D compiler, wich allows me to compile code written in D into dll''s at runtime, and use those dll''s then.. works like a charm so far..:D

and yes, i use d for the maincode, too, and now even for scripting, i can stay with d. nice, not?:D




If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net

Share this post


Link to post
Share on other sites
quote:
Original post by cody
i used lua in a realtime 3d engine and got performance problems with the garbage collector.
when i write scripts that are called once per frame and has some local variables the game pauses regularly for about 1/10s when gargabe is collected. not very nice...



It is possible to disable the gc by setting the threshold to something very high. Then you can call the gc manually at a convenient time. And don''t run scripts every frame; load them once and then call functions each frame. It''s faster.

Share this post


Link to post
Share on other sites
oh i didnt mean that i load the script every frame, i call lua functions every frame i wanted to say.

i tried different settings for the garbage collector but nothing really solved the problem.
there is no time to run a huge gc process in a fast game. it is better to collect often but fast, but this didnt work for lua either.
so i removed local variables and added them to the class scope.
i will try that squirrel thing now.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I used Python as a script language for a couple (real time games, including a FPS) gameprojects where all the logical parts where done in Python.
I never see any performance issue, and coding was real FAST...

Share this post


Link to post
Share on other sites
We used Python with our latest real-time 3D game. Although you don''t want to call Python methods for *every* frame, there is no performance problem if you merely use Python to trigger behaviors following events. For example, we have a Python callback that happens whenever an AI character reaches a destination along a path. But the character''s locomotion along that path is handled by the compiled, C++ game engine.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I am in agreement with grhodes: we''re doing exactly the same thing. If you''re finding Python too slow for your needs you''re probably not using the correct balance of Python and C++ code.

A small point of reference, Blade 2 used Python on all platforms... including PS2.

Alberto, while you''re on the thread, could you comment on the usability of Squirrel''s generators for micro-threads? Do they compare favourably with Stackless Python (used in Eve, btw). I really like the external simplicity of Squirrel...

Share this post


Link to post
Share on other sites
Well, squirrel''s generators are not really comparable with stackless python microthreads.
Stackless python micro-threads are a full featured coroutines system based on continuations AFAIK. This mean that you can yield the execution of a thread at any point of the program.
Squirrel''s generators are more comparable with python 2.3 generators, basically every function that contains a ''yield'' statement becomes automatically a generator function, so the program can yield only in the generator body and not in any other function called by the generator.

From Squirrel''s manual:
A function that contains a yield statement is called ‘generator function’.
When a generator function is called, it does not execute the function body, instead it returns a new suspended generator.
The returned generator can be resumed through the resume statement while it is alive.
The yield keyword, suspends the execution of a generator and optionally returns the result of an expression to the function that resumed the generator.
The generator dies when it returns, this can happen through an explicit return statement or by exiting the function body; If an unhandled exception (or runtime error) occurs while a generator is running, the generator will automatically die. A dead generator cannot be resumed anymore.


function geny(n)
{
for(local i=0; i yield i;

return null;
}

local gtor=geny(10);
local x;

while(x=resume gtor)
:rint(x+”\n”);



the output of this program will be


0
1
2
3
4
5
6
7
8
9


BTW I was planning to have coroutines in Squirrel 1.0 but I dropped the idea because would have been too many features to consolidate for a ''first release''.
I plan to add full coroutines in Squirrel 2.

I hope this helps.
ciao

-----------------------------
The programming language Squirrel
http://squirrel.sourceforge.net

Share this post


Link to post
Share on other sites
I''ve messed up the code tags
The snippet was supposed to be like this:


function geny(n)
{
for(local i=0; i<n; i++)
yield i;

return null;
}

local gtor=geny(10);
local x;

while(x=resume gtor)
::print(x+”\n”);




-----------------------------
The programming language Squirrel
http://squirrel.sourceforge.net

Share this post


Link to post
Share on other sites