Archived

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

Choosing a Scripting Language

This topic is 4990 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 been looking for a good scripting language to adopt for some projects I''m working on, and I''d appreciate some input. In particular, I''m looking for an easy-to-use language with a C-like syntax, but that is object oriented. I''d also like to use a language with a more streamlined, elegant feel.. garbage collection, no weird syntax, etc. I guess I''d almost like a JavaScript-esque language. GameMonkey looks pretty close to what I''m seeking, but it doesn''t appear to support OOP, and sounds as if its got a bit of maturing to do yet. So, any recommendations? **************************************** Brian Lacy ForeverDream Studios Comments? Questions? Curious? "I create. Therefore I am."

Share this post


Link to post
Share on other sites
Considered using JavaScript itself?

SpiderMonkey (JavaScript-C) Engine

It''s under the Mozilla Public License, which you can peruse here.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
id say ''go for Python'' but recently i may be a lil biased cuz i got crazy about that language it just rox.

just take a look @ what Bruce Eckel has 2 say about Python:
http://www.mindview.net/Etc/About/InformITRaw_html

Share this post


Link to post
Share on other sites
Aside from native support for OOP, Lua 5 is awesome.

I''ve also used SpiderMonkey, and was satisfied with the results for the most part, but I found that it handles exceptions poorly. Exceptions would handle fine before my engine started, but if the code was incorrect and tried to fire during the main application loop, things would hang. There''s probably some way to set the cooperative level of SpiderMonkey, but I haven''t bothered to look into it yet.

~Graham

----
while (your_engine >= my_engine)
my_engine++;

Share this post


Link to post
Share on other sites
According to my understanding, neither Python nor Lua has C-like syntax.

SpiderMonkey sounds promising.. still looking for tutorial and reference content though. I mean, I realize its JavaScript, but I'm not totally clear on how JavaScript would be used as a general purpose scripting language yet.

[edited by - irbrian on April 5, 2004 1:04:44 PM]

Share this post


Link to post
Share on other sites
As far as I can tell, SpiderMonkey seems to have the syntax and capabilities I need. But I cannot seem to find straightforward information on actually using it, although there are plenty of references on embedding it.

Are there any good, introductory-level tutorials out there for using it as an application scripting language -- especially for using it to develop game logic modules? Or can someone write one?

Share this post


Link to post
Share on other sites
You may find this useful:
http://users.skynet.be/saw/SpiderMonkey.htm

You''re right in that Python and Lua aren''t particularly C-like, but they''re popular for a reason. They may be easier to embed and work with and are problably better documented. How to create entire game logic modules is probably well beyond the scope of any tutorial, which is possibly why the more popular languages are the ones that are easier to embed in the first place.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
I''ll never understand why people esteem "C-like syntax" so highly. Is there really that much of a difference between

int bar()
{
    if(i == 3)
    {
        foo(i);
        return 2;
    }
    else
    {
        return 1;
    }
}

and

function bar()
    if i == 3 then
        foo(i)
        return 2
    else
        return 1
    end
end

?


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
I''ll never understand why people esteem "C-like syntax" so highly. Is there really that much of a difference between...
In the end, no, of course not.

I like C syntax because, among other things, I like knowing exactly where things begin and end. There are subtle benefits like the ability to wrap statements without using any special characters.

For me, C-based syntax is clear and concise, easy to read, easy to understand. Of course I realize that this is not the case for everyone. It is a personal preference, nothing more... but that''s a perfectly fine reason to desire it.

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
I'll never understand why people esteem "C-like syntax" so highly. Is there really that much of a difference between
....



Not really - but I can imagine that writing a script in a similar language to the engine will save headaches (eg: syntax errors) and allow people to more easily conceptualise how the two work together.

[edited by - downgraded on April 5, 2004 11:17:56 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Kylotan
You may find this useful:
http://users.skynet.be/saw/SpiderMonkey.htm

You''re right in that Python and Lua aren''t particularly C-like, but they''re popular for a reason. They may be easier to embed and work with and are problably better documented.
Certainly, ease of embedding and availability of documentation is big a factor to consider. I like Python alright, it just doesn''t feel as natural to me (possibly because I''ve been programming in C-like languages for so long now).
quote:
How to create entire game logic modules is probably well beyond the scope of any tutorial, which is possibly why the more popular languages are the ones that are easier to embed in the first place.
I''m not sure I''d agree that anything is completely beyond the scope of ANY tutorial. Nuclear physics could, theoretically, be explained through a series of tutorials. But I certainly don''t expect anyone to write a 100-page discourse on scripting Game Logic Modules, nor do I expect the full message to come across in a two paragraph overview.

Anyway I''m not really looking for tutorials in this area so much as general guidelines, tidbits of wisdom from those who have gone before, etc -- I don''t mind figuring the bulk of it out on my own.

Share this post


Link to post
Share on other sites
quote:
Original post by Kylotan
You may find this useful:
http://users.skynet.be/saw/SpiderMonkey.htm
After checking this one out I discovered that I''ve already seen it. It appears to be geared more toward embedding the scripting language in C++, i.e. weaving the two together, than using it to separate the core application and the component logic.

Share this post


Link to post
Share on other sites
I think it means lots of braces and semicolons and no "then" or "end". Hell, maybe I''ll rewrite the lua parser to look more like C. It really wouldn''t be much of a task.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
quote:
Original post by downgraded
Not really - but I can imagine that writing a script in a similar language to the engine will save headaches (eg: syntax errors) and allow people to more easily conceptualise how the two work together.


I strongly disagree with that statement. Unless you do reproduce faithfully the syntax and semantics of C (or C++), the subtle differences between C and your scripting language will cause unending headaches. People used to C will expect their C idioms to work correctly in script. If you can''t guarantee that, in particular if your feature set is markedly different, you should offer an obviously different syntax.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan

Share this post


Link to post
Share on other sites
well, screw C syntax. it isnt particularly fast to parse and compared to e.g. Python syntax, it has lots of ''{'' and '';'' overhead sometimes. and no, i dont like pascal-like syntax :> so dont eat me alive yet, hehe.
imo, looking for a scripting lang with a C-like syntax comes out of laziness for learning another lang ;P
yet, i like D syntax :]

"open your eyes, open your mind (...)"

Share this post


Link to post
Share on other sites
quote:
Original post by h3r3tic
well, screw C syntax. it isnt particularly fast to parse and compared to e.g. Python syntax, it has lots of ''{'' and '';'' overhead sometimes. and no, i dont like pascal-like syntax :> so dont eat me alive yet, hehe.
imo, looking for a scripting lang with a C-like syntax comes out of laziness for learning another lang ;P
yet, i like D syntax :]
If there was no interest in catering to laziness, it seems to me more programmers would just write the code in C/C++ and not worry about scripting languages at all, just make the user learn C++. Half the reason for separate scripting languages is so the user feels more comfortable with it.

Well, my scripters will likely have some coding experience in C/++, Java, JavaScript, ActionScript, and/or PHP. So I want something that''s natural and easy for them (and me) to use, which means C-like syntax, but quicker and more streamlined for ongoing development than actually using C or C++.

On the topic parsing speed: Since I''m having so little luck finding what I want, I''ve been slowly designing my own scripting language; and my hope is to design it such that it actually compiles the script to bytecode the first time it''s run and caches it, so that it runs faster but you don''t lose the ability to script-and-go. Granted the first execution after modification of the script would be pretty slow, but that''s no big deal for what I''m doing.

Of course, if I can find a scripting interpreter that has most of what I want, I''ll happily go with that. After all, I''m not interested in reinventing the wheel. I''m just talking about getting the right type of wheel to fit the axle.

Share this post


Link to post
Share on other sites
sure, its ! 2 bad 2 B lazy

again, my best shot here is Python, cuz it has actually very C-like syntax, aside from dropping the ''{'' and '';''. moreover, its extended to make it more coder-friendly, by introducing things like lambda expressions or built-in array slicing operators.

if you are concerned about efficiency of the code, you may take a look at this: http://psyco.sourceforge.net/introduction.html
Psyco lets you combine already-quite-fast-Python-bytecode with machine code.

Share this post


Link to post
Share on other sites
If you are looking for a luscious turing tarpit of programmability you can try out my script language project, be warned it is still in heavy development though.

It has ''C'' syntax, Scheme Syntax, Basic Syntax, Python Syntax without whitespace, Perl syntax..

http://xano.sourceforge.net

The best part is it is quite a bit faster than most other script languages because of how simple the VM is designed.

And you are free to take what I have started and hack it however you see fit :-)

See yah

Share this post


Link to post
Share on other sites
If you wanted Python syntax, you could just add some sort of white space counter in the scanner. And you would have to change things here and there. It would only be a day or two of work to change it to parse python code. C and Scheme were on the fore-front of my design but I use the word ''basic'' mostly so it doesn''t scare newbies away too much :-) It really is not that much harder than Basic.

I have plans eventually to either translate code to C++ and compile them into DLLs or use SoftWire as a JIT. This requires a change in the parser to parse to Parse Tree structures, it could be possible to unwind the assembler code stack and reconstruct native code too but a parse tree would be much simpler to translate.

Good luck

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Who is going to be writing your scripts? Where I work most of the scripts are written by non-programmers. A C-like interface is a negative.

Share this post


Link to post
Share on other sites
A Dylan-like interface might be more acceptable among non-system programmers. I believe AppleScript is based on Dylan and is supposed to be quite nice.

Dylan is like Scheme without all the parentheses -so there''s no excuse not to like it!

Share this post


Link to post
Share on other sites
That is another alternative.. tiny scheme! It is very good.
You can also find mini-scheme around somewhere.. and some small lisp interpreters.

Scheme is quite nice, clean, simple, to the point.

There is also guile, gauche, scheme48, scsh...

I think mostly what he is looking for is an algebraic syntax similar to C minus the things that make C C :-) A script language with pointers is probably a bad idea.

Share this post


Link to post
Share on other sites