Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Javascript engine would you embed in your application? [closed]

I want to embed Javascript in a hobby game engine of mine. Now that we have the 5th generation of Javascript engines out (all blazing fast) I'm curious what engine would you choose to embed in a C++ framework (that includes actual ease of embeding it)?

Note: Just to make it clear, I'm not interested in DOM scripting or writing Javascript in a browser.

Here's a compilation of links so far and some tips from the thread

  • SpiderMonkey
  • tracemonkey (note:backwards compatible with spidermonkey):
  • V8
  • Squirrelfish

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

However now this is a hobby project, and I think that Javascript being known by most web developers and because its ECMA, Flash and Flex developers, a game engine that uses Javascript and XML for scripting would be more user-friendly and cater to a larger user base (and one that so far has not had a chance to use their skills for games) than one with Lua (and there are plenty of those around!).

Also for the record I'll go with V8 on this one, mostly because I like it's C++ style.

like image 740
Robert Gould Avatar asked Sep 18 '08 15:09

Robert Gould


People also ask

What engine does JavaScript run on?

JavaScript Engine 101 The JavaScript engine executes and compiles JavaScript into native machine code. Every major browser has developed its own JS engine: Google's Chrome uses V8, Safari uses JavaScriptCore, and Firefox uses SpiderMonkey. We'll work particularly with V8 because of its use in Node.

Can JavaScript be embedded?

An embedded device using JavaScript can choose to enable scripting by end-users. Because JavaScript is a managed execution environment, end-user scriptability can be secure by safely sandboxing scripts.

What is Firefox JavaScript engine?

SpiderMonkey is the JavaScript engine used in the Firefox web browser. With Warp (also called WarpBuilder) we're making big changes to our JIT (just-in-time) compilers, resulting in improved responsiveness, faster page loads and better memory usage.

How JavaScript engine works in browser?

JS code has to run in an environment, the most common ones are browsers and Node. js. The environment needs to have an engine, which takes the JS code that's written in human-readable syntax and turns it into machine code. The engine uses a parser to go through the code line by line and check if the syntax is correct.


1 Answers

I've tried both SpiderMonkey and V8. With SpiderMonkey, I couldn't get anything to work. I couldn't even get the examples on mozilla.org to compile.

V8 worked out-of-the-box and I got some basic C++ <-> Javascript interaction going pretty quickly. There are some google lists for people using V8, and I found most of my questions answered there already.

like image 151
postfuturist Avatar answered Oct 01 '22 10:10

postfuturist