About ChaiScript

ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility and modern design in mind. It is an ECMAScript-inspired, embedded functional-like language.

ChaiScript is licensed under the BSD license.

Download

Due to an increased release schedule, and the nature of ChaiScript being a header-only library, binary releases will be made less often. Previous releases can be found on github.

Version: 4.2.0 Released: 12/1/2012
(Requires Boost)
Source (tar.bz2)
Source (zip)

Version: 5.2.0 Released: 12/1/2012
(Requires C++11 Compiler)
Source (tar.bz2)
Source (zip)

Frequently Asked Questions

C++ API (1)
C++ API

Use the "constructor" function that implicitly creates a function for adding to the runtime.

The "constructor" function is a template function that takes a signature for what you want your constructor to do.

struct MyStruct
{
  //Default constructor
  MyStruct();
 
  //Copy constructor
  MyStruct(const MyStruct &);
 
  //int constructor
  MyStruct(int i);
}
 
ChaiScript chai;
 
//Add the default constructor
chai.add(constructor<MyStruct ()>(), "MyStruct");
 
//Add the copy constructor
chai.add(constructor<MyStruct (const MyStruct &)>(), "MyStruct");
 
//Add the int constructor
chai.add(constructor<MyStruct (int)>(), "MyStruct");

ChaiScript's runtime dispatch capatilibties makes it perfectly legitimate and reasonable to add each constructor with the same name.

Also, notice that the name of the constructor is arbitrary, ChaiScript does not care what it is called, it becomes a regular function to the ChaiScript interpreter.

General (1)
General

The current defacto-standard of embedded scripting is Lua. Lua is a great, simple language that serves its purpose well. However, it is written in pure ANSI C. While this gives it outstanding portability, it greatly limits its ability to interact well with C++.

ChaiScript, on the other hand, was designed from the ground up with integration with C++ in mind.

To effectively use Lua, a language designed for embedding, with C++, you must use a preprocessor or meta compiler such as toLua++ or SWIG. While these tools are helpful, they do add unnecessary complexity to your application when you did not specifically need Lua and instead were searching for a simple way to provide scripting capabilities to your application.

Similarly, boost::python, while avoiding the meta-compiler, adds the complexity and size of libpython and python module system.

ChaiScript has no meta-compiler, no library dependencies, no build system requirements and no legacy baggage of any kind. At can work seamlessly with any C++ functions you expose to it. It does not have to be told explicitly about any type, it is function centric.

With ChaiScript you can literally begin scripting your application by adding three lines of code to your program and not modifying your build steps at all.

Support ChaiScript by sharing it with your friends: