July 18, 2000 - SpiderMonkey and Rhino
When we talk about JavaScript, we usually refer to the JavaScript interpreter that is provided with Internet Explorer and Netscape Navigator. But what if we want to use JavaScript scripts from within a stand-alone application written in C or Java? Netscape developed the concept of JavaScript engine. This is a piece of compiled code that knows how to interprets JavaScript. It is a shared resource, implemented differently for each platform. On Windows, for example, it is a DLL, while on Unix it is a shared library. You link your application with it and then embed JavaScript engine application programming interface (API) calls in your application. The JavaScript engine's API provides functions of the following types:
- Data Type Manipulation
- Run Time Control
- Class and Object Creation and Maintenance
- Function and Script Execution
- String Handling
- Error Handling
- Security Control
- Debugging Support
Before you can make any JS calls, you must create and initialize the JS engine with a call to JS_NewRuntime
function.
Netscape developed two dialects of the JavaScript engine: a C-based engine (called SpiderMonkey) and a Java-based engine (called Rhino). Obviously, you would link your C applications with SpiderMonkey and your Java applications with Rhino.