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.

  • \$\begingroup\$ 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. \$\endgroup\$
    – James
    Jun 11 '11 at 6:20
  • \$\begingroup\$ @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. \$\endgroup\$
    – deft_code
    Jun 11 '11 at 15:31
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Rob N
    Jun 12 '11 at 0:10

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.


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.

  • \$\begingroup\$ Be aware the Node.js Windows port is not ready; it's under development: stackoverflow.com/questions/6061053/… \$\endgroup\$
    – Leftium
    Jun 11 '11 at 6:34
  • 4
    \$\begingroup\$ How exactly is nodeJS related to embedding a script engine in a game? \$\endgroup\$
    – deft_code
    Jun 11 '11 at 14:51
  • \$\begingroup\$ 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. \$\endgroup\$
    – Raynos
    Jun 13 '11 at 11:51
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ May 7 '13 at 5:08
  • \$\begingroup\$ @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. \$\endgroup\$
    – deft_code
    May 9 '13 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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