What Javascript engine do you embed in your application?

I want to embed Javascript in my hobby. Now that we have the 5th generation of Javascript engines (everything is fast and fast), I'm curious what engine you want to implement in C ++ - a framework (which includes the actual ease of embedding it)?

Note. To make this clear, I'm not interested in writing a DOM or writing Javascript in a browser.

Here is a compilation of links so far and some tips from the stream

Just for the record, I love Lua and have already built it into game engines about 5 times at work.

However, now this is a hobby project, and I think that most web developers know Javascript and because its developers ECMA, Flash and Flex, the game engine that uses Javascript and XML for scripting will be more convenient and convenient for a larger user base (and one that still hasn’t been able to use their skills for games) than one with Lua (and there are many!).

Also for the record, I will go with V8 on this, mainly because I like the C ++ style.

+59
c ++ javascript embed
Sep 18 '08 at 15:40
source share
10 answers

Mozilla SpiderMonkey is pretty simple and well documented. It is a C API, but it is easy to wrap it in C ++. It can be compiled as thread safe, which is useful for games, since you probably want your main logic in one thread and user interface logic in a second thread.

Google V8 might be a good choice as you use C ++, but I don't have any experience yet. According to the documentation (thanks to Daniel James ), the V8 is not a thread - but this may change in the future.

There is also a WebKit SquirrelFish , but I could not find a separate version of this when I looked earlier.

+15
Sep 18 '08 at 15:41
source share

I tried both SpiderMonkey and V8. With SpiderMonkey, I could not get to work. I could not even compile examples on mozilla.org to compile.

V8 worked out of the box, and I got some basic interaction with C ++ ↔ Javascript pretty quickly. There are google lists for people using V8, and I found answers to most of my questions.

+16
Oct 10 '08 at 4:17
source share

Is Java Script the right language for your game? Many of the games use the Lua scripting language. It integrates easily, it is very small, it compiles on almost every platform and is easy to learn.

This is somewhat off topic, but thinking outside the box may be important to fix it.

+8
Sep 18 '08 at 17:26
source share

I believe v8 only works on x86, x64 and arm processors. What could be a disadvantage.

Regarding thread safety, from include / v8.h :

* Multiple threads in V8 are allowed, but only one thread at a time * is allowed to use V8. The definition of 'using V8' includes * accessing handles or holding onto object pointers obtained from V8 * handles. It is up to the user of V8 to ensure (perhaps with * locking) that this constraint is not violated. 

You can read more in the source file (this is similar to the doxygen documentation, but they don't seem to have pasted it anywhere).

Update: This comment was probably deleted some time ago. It looks like v8 now has an Isolate object that represents an instance of the engine. One Isolate instance can be used in only one thread at a time, but other Isolate instances can be used in other threads at the same time.

+7
Sep 18 '08 at 21:29
source share

Speaking of the scripting engine and C ++, you can also consider chaiscript . It is close to ecma script (~ Javascript) and is very easy to integrate into C ++.

Seller from the web page:

... ChaiScript, on the other hand, was designed from the ground up with integration with C ++ .... ChaiScript has no meta compiler, no library dependency, no build system requirements and no old baggage of any kind. It can work easily with any C ++ functions that you open for it. He does not have to explicitly talk about any type, he is central in function.

With ChaiScript, you can literally start writing application scripts by adding three lines of code to your program and not follow the steps at all.

+4
Nov 30 '11 at 5:21
source share

I would wait for TraceMonkey, the next evolution of SpiderMonkey, to exit. Faster and better. (Uses code donated from Adobe Flash).

Tracemonkey prides itself on making repetitive actions much faster, aggressively optimizing its runtime structure based on actual usage, which should be convenient for the game.

+3
Sep 18 '08 at 15:52
source share

Try Javascript.NET:

http://javascriptdotnet.codeplex.com/

It implements Google V8. You can compile and run Javascript directly from the .NET code with it and provide CLI objects that will be used by Javascript code. And V8 is probably the best engine ever created in terms of performance, it generates native code from Javascript.

+2
Jul 08 '10 at 12:02
source share

You can also watch Google's V8 . This is fairly new, however.

+1
Sep 18 '08 at 15:57
source share

I would follow v8 as it screams quickly javascript engine, and I am sure that it will develop cross-platform support as it grows to maturity.

+1
Sep 18 '08 at 21:43
source share



All Articles