Est. 2009 Intermediate

ChaiScript

An embedded scripting language designed from the ground up for seamless integration with C++, created by Jason Turner and Jonathan Turner.

Created by Jason Turner and Jonathan Turner

Paradigm Multi-paradigm: Procedural, Object-Oriented, Functional
Typing Dynamic
First Appeared 2009
Latest Version 6.1.0 (2018)

ChaiScript is an embedded scripting language designed from the ground up for seamless integration with C++. Co-created by Jason Turner and Jonathan Turner in 2009, ChaiScript distinguishes itself from other embeddable scripting languages by requiring no external dependencies, no special build tools, and no preprocessing steps—it is a header-only C++ library that can be added to a project with a single #include. Its syntax draws heavily from ECMAScript (JavaScript) while incorporating design decisions that feel natural to C++ developers.

History & Origins

ChaiScript was born out of frustration with the existing approaches to embedding scripting in C++ applications. Jason Turner, a C++ consultant and trainer who has been developing portable C++ since 2002, found that tools like SWIG (Simplified Wrapper and Interface Generator) imposed significant build process overhead for small projects. His cousin Jonathan Turner, described by Jason in his CppCon 2015 presentation as “a language geek,” was interested in collaborating on a new language, and ChaiScript was the result.

The project began in 2009 with both Turners as co-creators. Jonathan Turner contributed actively through approximately 2012 (as reflected in the project’s copyright dates: “Copyright 2009-2017 Jason Turner, Copyright 2009-2012 Jonathan Turner”). After leaving the ChaiScript project, Jonathan Turner (now Sophia J. Turner) went on to work on TypeScript at Microsoft, contributed to the Rust project at Mozilla—including designing Rust’s error message format—and later created Nushell, a modern shell written in Rust.

Jason Turner continued as ChaiScript’s primary maintainer and became widely known in the C++ community as the host of the C++ Weekly YouTube channel, co-host of the CppCast podcast, and a frequent speaker at CppCon and C++Now conferences. He presented “Crazy Easy Scripting with ChaiScript” at CppCon 2015, introducing the language to a wider audience.

Design Philosophy

ChaiScript’s design is guided by five core principles documented in the project’s official design goals:

  1. Trivially easy to embed in C++: No special build tools, no preprocessing, no code generation—just include the header and start scripting
  2. Zero external dependencies: The library requires nothing beyond a standards-compliant C++ compiler
  3. Seamless C++ interoperability: Direct object mapping, direct function mapping, and direct exception mapping between ChaiScript and C++ code
  4. No surprises for C++ developers: Stack-based object lifetime management and familiar syntax patterns that C++ developers can read naturally
  5. Adequate performance: Designed to be fast enough to avoid becoming a bottleneck, without claiming to be the fastest scripting language available

The official project documentation states: “ChaiScript does not intend to be the perfect tool for every situation, but it does intend to be a good general purpose tool for most situations.”

This philosophy sets ChaiScript apart from languages like Lua or Python, which were designed as standalone languages first and adapted for C++ embedding afterward. ChaiScript was built with C++ as its sole target host environment from day one.

Key Features

Header-Only Integration

ChaiScript’s most distinctive practical feature is its header-only design. Adding scripting to a C++ application requires only including the ChaiScript header file—no linking against separate libraries, no running code generators, and no modifying the build system. This makes it particularly attractive for smaller projects or rapid prototyping where build complexity is a concern.

Direct C++ Binding

C++ classes, functions, and objects can be registered with the ChaiScript engine and called directly from scripts without intermediate binding layers:

1
2
3
4
5
6
7
// Register a C++ function
chai.add(chaiscript::fun(&my_function), "my_function");

// Register a class with methods
chai.add(chaiscript::user_type<MyClass>(), "MyClass");
chai.add(chaiscript::constructor<MyClass()>(), "MyClass");
chai.add(chaiscript::fun(&MyClass::method), "method");

ChaiScript functions can also be captured as std::function objects and called from C++ code, enabling bidirectional integration.

Dynamic Typing with Guard-Based Dispatch

ChaiScript is dynamically typed but supports function overloading based on type and arity—an unusual feature among scripting languages. Functions can also use guard expressions that act as runtime preconditions:

1
2
def factorial(n) : n == 0 { return 1; }
def factorial(n) { return n * factorial(n - 1); }

Object-Oriented Features

ChaiScript supports user-defined types with constructors, member functions, and inheritance. It also provides dynamic objects with a method_missing mechanism, enabling flexible metaprogramming patterns.

Functional Programming Support

The language includes first-class functions, lambda expressions with captures, and higher-order functions. Operators can be used as callable function objects, and functions can be composed and passed as values.

Thread Safety

ChaiScript is thread-safe by default, with the option to disable thread safety for performance-sensitive applications that do not require concurrent script execution.

Evolution

ChaiScript’s development progressed through several significant phases:

Early Versions (2009–2012)

The initial versions of ChaiScript established the core language semantics and C++ integration model. During this period, the language required Boost as a dependency for compiler compatibility across different C++ implementations. Version 4.0.0, released in June 2012, marked a significant milestone by dropping the Boost dependency entirely in favor of C++11, aligning with the project’s philosophy of minimal dependencies.

Version 5.x (2012–2016)

The 5.x series, which began shortly after 4.0.0 in June 2012, continued development on the Boost-free, C++11-based codebase through version 5.8.6 in late 2016. This series introduced JSON support (in version 5.8.0) and benefited from fuzz testing that uncovered and fixed crash bugs.

Version 6.x (2018)

Version 6.0.0, released in February 2018, raised the minimum C++ standard to C++14 and introduced range-based for loops along with modular optimization improvements. Version 6.1.0 followed in May 2018, adding namespace support, UTF-8 parsing, and C++17 compatibility. This was the last official release. The current development branch requires a C++17 compiler.

Current Relevance

ChaiScript’s last official release was version 6.1.0 on May 29, 2018. The GitHub repository remains available with approximately 3,000 stars and around 360 forks as of early 2025, but development activity has been minimal since 2018. Some work toward a 6.1.1 release exists on the development branch—including C++20 compatibility fixes—but no formal release has been made. The project is best described as dormant: it has not been formally deprecated, but it is not actively maintained.

The language remains a notable example of how to design an embedded scripting language specifically for C++, and its header-only, zero-dependency approach continues to influence how developers think about scripting integration in C++ applications.

Why It Matters

ChaiScript demonstrated that embedded scripting for C++ did not have to involve complex binding generators, external dependencies, or multi-step build processes. By designing a language from scratch with C++ as its only target host, ChaiScript achieved a level of integration simplicity that adapter-based approaches for languages like Lua or Python could not easily match. While the project is no longer actively developed, its design principles—particularly the emphasis on zero-dependency, header-only integration and seamless bidirectional C++ interoperability—remain relevant to anyone designing embeddable scripting solutions for C++ applications.

The project also represents a collaboration between two developers who both went on to significant contributions in the programming language community, with Jason Turner becoming a prominent C++ educator and Sophia J. Turner contributing to TypeScript, Rust, and Nushell.

Timeline

2009
ChaiScript created by Jason Turner and Jonathan Turner as an embedded scripting language purpose-built for C++
2012
Jonathan Turner steps away from active ChaiScript development to pursue other language projects
2012
Version 4.0.0 released in June, dropping the Boost dependency entirely in favor of C++11
2015
Jason Turner presents 'Crazy Easy Scripting with ChaiScript' at CppCon 2015
2016
Version 5.8.0 released, adding JSON support and parser improvements to the C++11-based codebase
2018
Version 6.0.0 released in February, requiring C++14 with range-based for loops and modular optimization
2018
Version 6.1.0 released on May 29, adding namespace support, UTF-8 parsing, and C++17 compatibility — the last official release

Notable Uses & Legacy

ChaiLove

A 2D game framework built on the libretro/RetroArch platform that uses ChaiScript as its scripting language, targeting Windows, macOS, Linux, Android, and ARM devices

Spiced

An official reference game engine from the ChaiScript project demonstrating tile-based game development with ChaiScript scripting

C++ Application Embedding

Used as an embedded scripting layer in various C++ applications and game engines where developers need runtime scriptability without external build tool dependencies

Language Influence

Influenced By

ECMAScript C++

Running Today

Run examples using the official Docker image:

docker pull
Last updated: