Skip to main content
GameDev.net gamedev.net
🔒 Locked

New game dev scripting language

Started by chinnyreckon Oct 5, 2008 at 4:20 AM 15 replies 1.9k views
Original Post
chinnyreckon
chinnyreckon
Ive written an embedded extensible scripting language compiler and VM which I intend to open source (by 1st of Jan). It is designed with real time agent systems in mind, and so is ideal for game development. It is fast and memory efficient and out performs all the non commercial scripting languages benchmarked on http://shootout.alioth.debian.org/ (haven’t tried the commercial ones). I am looking for people to test it before release. If you are interested in testing or just want to take a look at it please respond to this thread. Here is a review of features: • Ability to script in any LALR parsable language given a grammer and rules file for the language. This implies the ability to design your own scripting language for use with the compiler and VM. Presently comes with C/C++ definitions. • Link time type checking and function call resolution. • Ability to run script in different languages on same VM and process. • Function visability privileges allowing for inter-script/inter-function restricted access. • Seamless extendibility and integration of VM into c++ engine allowing for; c++ engine functions and object member functions to be called from scripts, scripts and functions to be called from c++, c++ engine classes to be used in scripts, c++ engine member variables to be accessable in scripts, and c++ class data variables to be exchanged between the engine and scripts with ability to integrate with engine reference counting garbage collection. • Scriptable classes with single inheritance, public and protected interfaces, and virtual functions. • Integral single dimension array data type for all soft and hard data types. • Pointers to objects (no pointer arithmetic). • Function pointers. • User definable integral number data type optimised for speed. Define int, double or even a class as your integral data type so it performs faster than ordinary data types registered with the vm. • Variant data type. • Explicit casting between c++ engine types used in script. • Explicit data passing in function calls as well as pointer passing. • Type registering to allow consistent exchange of data between VMs and engines. • Uses VM processes to run script function call threads so can have multiple processes operating on the same code and data. • Optional time slicing of processes to manage time allocation spent on each process. • Ability to perform pre-emptive multi tasking. • Yeilding feature to halt a VM process update until a callback is received. • Optional instruction count overflow catching to stop infinite loops. • Thread safe VM so can distribute updating of VM processes on different threads and processors. • Relative addressing of all data so data can be moved or resized at runtime. • Uses true stack so garbage collection only required for heap newed data. • Reference counted garbage collection so no garbage collection phase. • Self regulating memory manager cache.
bullno1
bullno1
Sound nice. How about a download link?
chinnyreckon
chinnyreckon
sure:

http://code.google.com/p/shharc/

it currently compiles on windows, i am gonna do the linux port in the next couple of weeks.

check out the shharc\Code\TestHarness\Integration\Win32 directory for a test solution/project that illistrates how to use the different features. I have yet to write a manual. Sorry.

and

shharc\Code\TestHarness\Spritely\Win32 for a solution/project that uses the multi process stuff with some simple 2d sdl graphics that may mate is writing to in order for us to write some mini test games. He has only done a little bit on the sprite library but hopefully shall have input and animantion in in the next two weeks. He is a busy man and I can only ask so much of him.

Also check out D:\WORK\shharc\Code\Core\VM\Config.h which has the hash defines and stuff in it to turn on thread safety, choose the intergal number data type etc.

You may find it compiles slower than most script compilers cos it is a generic compiler that can compile multiple languages and so does more work. However it saves out the object code so you only need to compile once, and just link every other time. The VM is really where it wins over competators.

I hope you enjoy it and would love your feed back.
greenhybrid
greenhybrid
I doubt it outperforms llvm-backed code, neither in native- nor in vm-mode.

Nothing against you, but then there's years and a plethora of different optimization passes in it.

To quote toxie from ompf.org: Source, or it didn't happen. (It's a good thing you make it open source, will the license be compatible to GPL?)

If this what you say is true, and if it beats llvm, then count me in :)
chinnyreckon
chinnyreckon
I havent tried it against llvm. As I said I profiled it against the languages benchmarked on http://shootout.alioth.debian.org/ llvm isnt listed there. However it is faster than the likes of lua etc.
bubu LV
bubu LV
I seriously doubt that GPL licensed scripting language would be useful for game development. As general scripting language - yes, it could be. But for game dev...
Sneftel
Sneftel
Quote:
Original post by bubu LV
I seriously doubt that GPL licensed scripting language would be useful for game development. As general scripting language - yes, it could be. But for game dev...

Well, it'd be fine for GPLed games, of course, and there are a few of them out there. LGPL would increase its usefulness to some degree.
chinnyreckon
chinnyreckon
It is not as yet officially released as it needs testing. I am however open to suggestions for licencing
dmail
dmail
I wanted to confirm your results that it is faster then Lua, so I checked it out of svn compiled it in release mode and ran it only for it to have a runtime error triggered in Base_type::Add_member function at the line 151
myNamespacedMembers[myName+"::"+name] = ln;

Having a quick look the member varaible myName has one million entries, which surly can not be correct!

here is the call stack
Quote:

Integration.exe!Parser::Parse() + 0x1b bytes C++
> Integration.exe!BaseType::AddMember(const std::basic_string,std::allocator > & name="Â", const GCPtr & type={...}, int indirection=-1, bool publicAccess=true, int size=11335924, int offset=11335924, bool engineMember=true) Line 152 + 0x14 bytes C++
Integration.exe!Class::FunctionPointerInitializer::FunctionPointerInitializer(const Class::FunctionPointerInitializer & __that={...}) + 0x60 bytes C++
Integration.exe!std::basic_string,std::allocator >::compare(unsigned int _Off=10616832, unsigned int _N0=0, const char * _Ptr=0x00000004, unsigned int _Count=1) Line 2051 + 0x28 bytes C++
Integration.exe!malloc(unsigned int size=11393624) Line 163 + 0x5f bytes C
Integration.exe!std::vector,std::allocator > >::_Ufill(GCPtr * _Ptr=0x7c9180ff, unsigned int _Count=4294967295, const GCPtr & _Val={...}) Line 1252 + 0x26 bytes C++
ntdll.dll!7c90d4ea()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7c9105c8()
ntdll.dll!7c910551()
ntdll.dll!7c91056d()
ntdll.dll!7c91056d()
Integration.exe!malloc(unsigned int size=10616832) Line 163 + 0x5f bytes C
Integration.exe!_msize(void * pblock=0xe04b2bb6) Line 88 + 0xe bytes C
e0b43336()
Integration.exe!_unlock(int locknum=) Line 376 C


Sneftel
Sneftel
Personally, I release all my code as public domain... I'm more a fan of freedom for developers--even those who want to make money--than a fan of freedom for code, whatever that means. The MIT license is similar, but more codified. The BSD license is about the most restrictive license I would ever willingly use.

I haven't been able to play around with it yet, but I poked through the code... looks very clean and nice.
greenhybrid
greenhybrid
Yay, I really said GPL without provoking yet another flâme-wâr.

Quote:
Original post by Sneftel
Quote:
Original post by bubu LV
I seriously doubt that GPL licensed scripting language would be useful for game development. As general scripting language - yes, it could be. But for game dev...

Well, it'd be fine for GPLed games, of course, and there are a few of them out there. LGPL would increase its usefulness to some degree.



Indeed there are tons of them, and some of them with *really* great graphics.
Remember that there is still the option of double-licensing (the *copyright owners* of the code-files have to agree; you can't just grab some gpl-code and re-release it under a gpl-incompatible license), like (imho) Ogre does (where you can get the engine under a allow-use-in-proprietary-software-license, for some cents).

And sorry that I always overuse my parentheses, may have to do with some LISP'ish coding I do atm for picogen :|
Sneftel
Sneftel
Quote:
Original post by greenhybrid
Remember that there is still the option of double-licensing (the *copyright owners* of the code-files have to agree; you can't just grab some gpl-code and re-release it under a gpl-incompatible license), like (imho) Ogre does (where you can get the engine under a allow-use-in-proprietary-software-license, for some cents).
That's a good point. If you're thinking about doing this, plan for it from the very beginning. Ogre had huge troubles transitioning to the dual-license model because it wasn't planned for and they had to get all their copyright assignation ducks in order.
Quote:
And sorry that I always overuse my parentheses, may have to do with some LISP'ish coding I do atm for picogen :|
That'd explain the dashes too.
dylski
dylski
Quote:
Original post by dmail
I wanted to confirm your results that it is faster then Lua, so I checked it out of svn compiled it in release mode and ran it only for it to have a runtime error triggered in Base_type::Add_member function at the line 151
myNamespacedMembers[myName+"::"+name] = ln;


I had a different error when I tried to run the benchmark project Integration.

Turns out that I needed to set the working directory to '..\Runtime' and I had to run the release version under Visual Studio's debugger (i.e. by hitting F5) as Ctrl-F5 resulted in one of the final tests being aborted by Windows' Data Execution Prevention system. FYI, I'm using VS2008 on Vista.

The results I got on a Quad core Q6600 @ 2.4GHz are:

variant.gcc, Time: 0.000208
local.gcc, Time: 0.108426
new.gcc, Time: 0.234763
hardfunc.gcc, Time: 0.014282
while.gcc, Time: 0.008132
whileloop.gcc, Time: 0.010780
ary.gcc, Time: 0.001217
binarytrees.gcc-2.gcc, Time: 3.778466
getmember.gcc, Time: 0.001502
fibo.gcc, Time: 0.000577
nestedloop.gcc, Time: 0.054141

alloc.gcc is missing from the runtime directory so that test fails.

Don't know how these compare to other scripting languages though.
chinnyreckon
chinnyreckon
Sorry for the instability dmail. I wasnt intending to let anyone have it for a few weeks yet, but bullno1 was so polite in asking I couldnt refuse :).

Yes dylski you do have to set the runtime directory as the compiler looks for the productionrules grammer, the C grammer and the C production rules before it can compile any C code. It also has to find the script files it needs to run(i have checked in the alloc script now so you can update ).

The sprite test app needs to have its runtime directory set aswell (shharc\Code\TestHarness\Spritely\Runtime) and also need some command line args to set; the language, script file to run, number of threads for processes to be distributed amongst (remember to turn thread safty on in the config file), and the time out for each process. Eg: CshhArc test.cpp 1 1000. I have also fixed a bug in the test script file and production rules so please update.

If you continue to have any probelms dmail, please email me. I am the project owner listed on google code. It seems you may have unwittingly become my first tester :)
Extrarius
Extrarius
If you're writing native code into memory and executing it, you'll need to make sure that memory has execution permission using VirtualAlloc to allocate the memory with one of the executable options for the last argument. Otherwise, windows will do it's best to prevent that code from executing (which is not much 32-bit XP, but it's much better on 64-bit OSes).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
dylski
dylski
Here are some comparisons with Lua...

Faster in every respect and more than an order of magnitude faster on some tests:

hardfunc.lua, Time: 0.027431
hardfunc.gcc, Time: 0.014678

binarytrees.lua-3.lua, Time: 55.036312
binarytrees.gcc-2.gcc, Time: 5.887491

getmember.lua, Time: 0.010643
getmember.gcc, Time: 0.001391

nestedloop.lua, Time: 0.097187
nestedloop.gcc, Time: 0.054401

new.lua, Time: 0.709698
new.gcc, Time: 0.280017
local.gcc, Time: 0.107735

fibo.lua, Time: 0.004601
fibo.gcc, Time: 0.000595

whileloop.lua, Time: 0.017551
whileloop.gcc, Time: 0.011396 (this one uses n=n+1 like in Lua)
while.gcc, Time: 0.007624 (this one uses a prefix-increment in while loop because it can)

ary.lua, Time: 0.001458
ary.gcc, Time: 0.001230

These were run on a single core of a quad core Q6600 @ 2.4GHz.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.