🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

javascript

Started by
5 comments, last by stpg 20 years, 2 months ago
hi i have several simple question: 1. can javascript be used for game scripting? (Mozila''s SpiderMonkey) 2. is Lua the best scripting language (i use lua in my engine and want to know if there are something better then it) and which good c-style scripting languages do you know? if script support oop - can i integrate my classes with script classes(any examples) - it was very difficult to link my OOP engine with not OOP Lua(i use somthing like Call("Class1::MethodA",param1,param2); ). PS. Sorry for my bad english Thanks
STupidPiG
Advertisement
I evaluated SpiderMonkey when I started working on farcy about 3 years ago. I personally do not like this implementation, is kinda slow and not as compact as lua, plus the api is tricky and
you got too many pointers to deal with. Is fine for a browser or some desktop app but for a game I wouldn''t use it(at least not for an FPS or similar).
The main issue is that Javascript is as OOP as lua; the difference is that JS pretends to be OOP calling "Objects" what lua calls tables and with some syntactic sugar like ''new''. With lua you can archieve the same kind of OOP you got with JS, that is prototype based OOP(no inheritance but delegation). The cooler thing of lua is that provides a very powerful reflexivity system(look for metatables) so you can define your ''object'' behaviour in a much more flexyble way.

just my 0.2 cents

ciao
Alberto

-----------------------------
The programming language Squirrel
http://squirrel.sourceforge.net
-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org
quote: Original post by stpg
1. can javascript be used for game scripting? (Mozila''s SpiderMonkey)

Yeah, I''ve heard of people making good use of it. The performance is limited, though, and a lot of people grow to dislike the syntax.
quote: 2. is Lua the best scripting language (i use lua in my engine and want to know if there are something better then it)

It''s all relative. By most accounts, Lua is a really really good language. Its prime weakness is that there aren''t quite as many 3rd party library bindings as some other languages have, but this is unlikely to be much of a problem in embedded scripting.
quote: and which good c-style scripting languages do you know?

What do you mean c-style? Lua will let you end every line with a semicolon, if you like.
quote: if script support oop - can i integrate my classes with script classes(any examples)
- it was very difficult to link my OOP engine with not OOP Lua(i use somthing like
Call("Class1::MethodA",param1,param2);
).

Google for "LuaBind". That''s pretty much the best binding generator out there.

"Sneftel is correct, if rather vulgar." --Flarelocke
thank u for answers

i understoond what i use only 15% of Lua power and i needn''t nothing else.



-=1=-
STupidPiG
How about speed of luabind glue functions (and speed of calling class methods)?


-=1=-
STupidPiG
UnrealEngine uses "UnrealScript" as a major facility, which is very similar to Java.

Personally I think that Java is a fantastic idea for scripting.
I''m using javascript for my current project. It seemed easier to get running quicker than Lua, but must admit I didn''t take such a good look at Lua though... also I want to expose parts of the scripting to players and hoping since javascript is already well known that it is the best one to do that with.
As for speed so far I am only using it for non-speed-critical areas (defining actions and layout of menus) so I can''t comment yet. Scripts can be compiled into bytcode and reused though, that should improve speed somewhat.
I think since you are already using Lua, stick with it...

This topic is closed to new replies.

Advertisement