Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking into scripting languages to embed in my game.

I've always assumed Lua was the best choice, but I've read some recent news about embedding V8 as was considering using it instead.

My question is two fold:

Does anyone with experience embedding v8 (or another javascript engine) recommend it?

How does it compare with embedding Lua?

I like that v8 has a c++ embedding API. However Lua API has had lots of time to be refined (newer isn't always better and all that).

Note: At this point I'm not too concerned with which is better language or which library has better performance. I'm only asking about ease of embedding.

share|improve this question
    
All I can speak to is Lua, so no official answer for me. But Lua's ease of extension has kept me using it time and again. –  James Jun 11 '11 at 6:20
    
@James: if you've got the time look at the embedding V8 overview. Then post an answer with your impressions comparing the v8 API with Lua API. The overview isn't large, and it's always a good idea to sample other options to combat fanboi-ism. –  deft_code Jun 11 '11 at 15:31
1  
Its also worth noting that there are other JavaScript runtimes out there that might be easier/harder than v8. I embedded Spidermonkey in a project a few years ago, and my memory is that it was trivial and I was not an experienced programmer at the time. –  Robert Norris Jun 12 '11 at 0:10
add comment

2 Answers

I use JINT with my C# MUD. I have looked into V8, but found JINT to be much easier in my case. I'm not so sure what the best option for C++ would be. I simply enjoy Javascript as a language because I know it better than Lua. I'm sure Lua is much more refined and has been widely used for a long time now. My guess is if your looking for the easiest thing to embed, Lua would be the way to go just because I would think it be much better than documented than anything else. However if you are going to have a lot of scripters later on, javascript programmers are probably much more widespread at this point than Lua programmers.

In my case JINT was just as easy if not easier to embed than Lua. However the actual time embedding the script should be trivial compared to the time it will take to write said scripts. I would go with whatever you think your programmers or you are most comfortable programming with later on. Unfortunately I don't really know what the performance kicks are from either. I do know for sure that V8 is by far the fastest Javascript engine.

share|improve this answer
add comment

you should maybe look into nodeJS

Its a V8 wrapped with some excellent base modules. Its fast, has a huge community and tens of a universe of modules available via the NPM package manager.

share|improve this answer
    
Be aware the Node.js Windows port is not ready; it's under development: stackoverflow.com/questions/6061053/… –  Leftium Jun 11 '11 at 6:34
4  
How exactly is nodeJS related to embedding a script engine in a game? –  deft_code Jun 11 '11 at 14:51
    
You can write your game using nodeJS. Just get it to start child processes that run your C/C++ low level code. But that's not useful for embedding it into an existing game. –  Raynos Jun 13 '11 at 11:51
1  
@deft_code It brings JavaScript via V8 to the table, as well as a collection for useful core modules. NodeJS is not just for servers. –  Robert Hurst May 7 '13 at 5:08
    
@RobertHurst, you indirectly make a good point. The limitations of Node.js reflect the limitations of embedded V8. One example is no multi-threaded execution. –  deft_code May 9 '13 at 23:09
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.