Home » Community » Forums » Scripting Languages and Game Mods » JavaScript as game script
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 JavaScript as game script
Post New Topic  Post Reply 
Being a professional web developer and hobby C++ game programmer, I'm trying to incorporate SpiderMonkey (netscape/mozilla implementation of javascript) into my game engine (simple engine that makes it easy to do clones of arcade type games - tetris, asteroid, etc...).

Now I know that JS for my purposes - simple games - will work fine because speed is not a huge issue, but when I do something I tend to want to do it the "right way." What are your thoughts on JS's performance. It was built to handle small document-centric tasks but could it be used for a larger scale, 3D game.

I've heard pretty much nothing but good things about LUA, and the word is performance is great, but I'm not a big fan of the syntax.

To complicate matters, I've heard people say that for scripting, syntax is the main feature to choose a language -- that they'll run at about the same speed. So is JS valid? Or should I go with LUA (or a more game specific script language)?

Long post, but what are your thoughts/experiences with javascript in applications other than Web oriented tasks?

 User Rating: 1029   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I expect it would be fine. Performance is hard to gauge because Spidermonkey is being tweaked for performance all the time, and really there isn't much in the way of data for it being used in games. I think the only definitive answer is to try it and see. I doubt it is likely to be a problem unless you do all your logic in it.

 User Rating: 1905   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

OP, Evolutional has done some great work with spider monkey and his game engine...
Last time I talked to him, he said he wrote a pretty nice wrapper to make it easier to use spider monkey in your games. ttyl.

~Jay

 User Rating: 1016   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

It's been knocked down the priority queue due to an important in-progress projec, but I'm still working on an article which discusses using SpiderMonkey in your games.

 User Rating: 1902   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

I tried my hand at it, but found that it was a bit tricky to understand. I would deffentially love to see your article evo!

 User Rating: 1016   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

There is somewhere, a project to enable easy wrapping of classes in C++ into JS in SpiderMonkey - like luabind and tolua

But it might be somewhat wonky.

Getting Spidermonkey itself going is pretty straightforward though and I agree that javascript is a much nicer syntax than lua. But I like coroutines :)

Mark

 User Rating: 1682   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

Quote:
Original post by markr
There is somewhere, a project to enable easy wrapping of classes in C++ into JS in SpiderMonkey - like luabind and tolua


Any idea what it was called? The closest thing I found was a binding wrapper for wxWindows called wxJs. The author used the template mechanism which I actually adopted for version 1 of my GameMonkey wrapper, gmBind. I was unable to find anything else though :/

Quote:

Getting Spidermonkey itself going is pretty straightforward though and I agree that javascript is a much nicer syntax than lua. But I like coroutines :)


That's one 'criticsm' I have with SpiderMonkey; it definitely works better as an event-driven scripting language which gets called from the application. It's not really a problem to me as I prefer to work this way, but for others it will definitely be an issue.

 User Rating: 1902   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

I'm working on spidermonkey integration at the moment and did some hunting for easy wrapping, all I came across was references to swigJS, but all the links I found were dead (including the one on the swig.org site). Fortunately, I don't have a lot of functions to wrap, and almost no classes, so I'm not in for too much of a headache.

In my case, I'm using javascript as scripting for event-driven dynamic forms, but was planning on doing some game work with it later on, I'd be curious how it performs there.

 User Rating: 1097   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Have you tried Squirrel? It's supposed to be basically a C/C++ looking Lua (at least from my understanding).

Squirrel Homepage

daerid@gmail.com

 User Rating: 1168   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Well, maybe Squirrel 1.0 was not so far from Lua but since version 2.0 is really not comparable anymore. Has classes etc... It kinda took is own path. However if you like JScript, Squirrel looks very close to it(at least syntax wise).

ciao
Alberto

-----------------------------
The programming language Squirrel
http://www.squirrel-lang.org

 User Rating: 1138   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: