Est. 2003 Intermediate

Squirrel

A lightweight, dynamically-typed object-oriented scripting language with C-like syntax, designed for embedding in real-time applications such as video games.

Created by Alberto Demichelis

Paradigm Multi-paradigm: Object-Oriented, Imperative, Functional, Scripting
Typing Dynamic, Strong
First Appeared 2003
Latest Version 3.2 (2022)

Squirrel is a high-level, dynamically-typed, object-oriented scripting language created by Alberto Demichelis and first released in 2003. It was designed to be lightweight enough to fit within the size, memory-bandwidth, and real-time constraints of applications such as video games, while offering a familiar C-like syntax. Squirrel borrows several core ideas from Lua — notably its table-based data model and lightweight C API — but wraps them in curly-brace syntax closer to C, JavaScript, and C++. The language found its most prominent home in game development, where it powers scripting in titles from Valve’s Source engine games to Gaijin Entertainment’s War Thunder.

History & Origins

Background and Motivation

Alberto Demichelis, an Italian programmer, created Squirrel out of his practical experience embedding scripting languages in game engines. Having worked with Lua as an embedded scripting language, he encountered friction with some of Lua’s characteristics: its syntax was unfamiliar to programmers coming from a C or C++ background (a recurring pain point was colleagues repeatedly asking how to write a simple for-loop), and its feature set felt small for the object-oriented patterns common in game code. Rather than continue to patch Lua for these needs, Demichelis started fresh with a new language that preserved Lua’s lightweight, embeddable design philosophy while adopting a more conventional C-family syntax and richer built-in support for classes.

First Release (2003)

Squirrel was made public on September 6, 2003, under the permissive zlib/libpng license. From the outset the language was structured around a compact implementation — the compiler and virtual machine together comprise only a few thousand lines of C++ — reflecting the goal of embedding into memory- and performance-constrained environments. Scripts use the .nut file extension, a playful nod to the language’s name.

Evolution and Licensing (2005–2022)

Version 2.0 arrived on April 3, 2005, broadening the language and its standard library. In November 2010, Demichelis relicensed the project from zlib/libpng to the MIT license, which allowed the source to be hosted on Google Code. Version 3.0 followed in 2011, and the current stable release, version 3.2, was published on February 10, 2022. Over its lifetime the project has migrated its hosting from its original site to Google Code and ultimately to GitHub, where it continues to be maintained.

Forks and Variants

Squirrel’s small, embeddable design made it attractive to game studios that then customized it for their own engines. Valve integrated a modified variant known as VScript into the Source engine, using it for map and gameplay scripting across several of its games; the Source implementation has historically tracked the 3.x line of the language. Gaijin Entertainment used a modified Squirrel in its Dagor Engine from around 2006 and, around 2019, forked its dialect into a separate language called Quirrel, describing it as a version of Squirrel made safer, stricter, and faster.

Design Philosophy

Lightweight and Embeddable

Squirrel’s central design goal is to be small and easy to embed. The reference implementation keeps the compiler and virtual machine deliberately compact so that the whole runtime can be dropped into a host application — typically a C++ game engine — without significant footprint. Like Lua, it exposes a C API through which the host registers native functions and types, controls script execution, and exchanges data with scripts. This makes the host application, not the script, the ultimate authority over what capabilities scripts can access.

Familiar C-Family Syntax

A defining decision was to present a syntax that C, C++, and JavaScript programmers would recognize immediately. Blocks use curly braces, control-flow statements follow conventional C forms, and the language reads more like a scripting-oriented C than an entirely novel notation. This lowered the learning curve for the game programmers who were Squirrel’s primary audience.

Table-Based Data Model with Delegation

Squirrel inherits Lua’s idea of the table as a fundamental, flexible container, and builds an object model on top of it using delegation. Objects can delegate to other objects, allowing behavior and attributes to be shared and overridden in a prototype-like fashion. On top of this foundation, Squirrel also provides a more conventional class construct with inheritance, giving developers both dynamic delegation and structured class-based programming.

Key Features

Dynamic Typing

Squirrel is dynamically typed: variables hold values whose types are determined at runtime. Its core types include integers, floats, strings, booleans, tables, arrays, functions, classes, class instances, and generators, along with null.

Classes and Inheritance

Beyond delegation, Squirrel offers first-class classes with single inheritance, instance construction, and metamethods for operator behavior:

class Entity {
    name = "unnamed"
    x = 0.0
    y = 0.0

    constructor(entityName) {
        name = entityName
    }

    function update(dt) {
        // base update logic
    }
}

class Player extends Entity {
    constructor() {
        base.constructor("Player")
    }

    function update(dt) {
        // player-specific update
    }
}

local p = Player()
print(p.name + "\n")   // prints: Player

Higher-Order Functions and Closures

Functions are first-class values in Squirrel and support closures, enabling functional programming patterns such as passing behavior as arguments and building callbacks.

Generators and Coroutines

Squirrel provides generators (functions that can yield a sequence of values) and cooperative threads (coroutines). These allow scripts to model long-running or step-wise behaviors — common in game AI and event sequencing — without blocking the host application.

Tail Recursion and Exceptions

The virtual machine performs tail-call optimization, so properly tail-recursive functions run in constant stack space. Squirrel also includes structured exception handling with try/catch/throw for error propagation.

Automatic Memory Management

Memory is managed automatically. The primary mechanism is reference counting, backed up by a garbage collector that reclaims cyclic references that reference counting alone cannot free. Squirrel additionally supports weak references, letting programs hold references to objects without preventing their collection.

Optional Wide-Character Strings

The implementation can be compiled with optional wide-character (UCS-2) string support, accommodating applications that need Unicode-capable string handling.

Technical Architecture

Squirrel follows an embed-and-register model similar to Lua:

  1. Embedding: The host C++ application creates a Squirrel virtual machine instance and configures it.
  2. Registration: The host registers native C++ functions, classes, and constants that scripts are permitted to call.
  3. Compilation: Squirrel source (.nut) is compiled to bytecode, which the virtual machine executes; bytecode can also be serialized.
  4. Execution: The VM runs scripts, invoking registered native functions when scripts call into host-provided APIs, and exchanging values through the stack-based C API.
  5. Memory reclamation: Reference counting frees objects as they go out of scope, with the backup garbage collector handling cycles.

Because the host controls exactly which functions and types are exposed, Squirrel provides a natural sandboxing boundary — scripts can only reach the capabilities the host chooses to register.

Current Relevance

Squirrel occupies a stable niche as an embeddable game-scripting language. Its most visible footprint is through the variants that major studios built on top of it: Valve’s VScript keeps Squirrel in the hands of Source-engine modders and level designers, while Gaijin Entertainment’s War Thunder ecosystem carried a Squirrel-derived language to a very large player base before that dialect diverged into Quirrel around 2019. The reference implementation itself continues to be maintained on GitHub, with version 3.2 (2022) as the current stable release.

Beyond games, Squirrel has appeared in other embedding contexts, including the Electric Imp IoT platform, where it served as the application programming language for connected hardware, and the Code::Blocks IDE, which uses it as an internal scripting language.

Why It Matters

Squirrel’s significance lies in how it refined the embeddable-scripting formula pioneered by Lua for a specific audience — C++ game programmers — and in the influence it exercised through the engines that adopted it:

  1. A C-syntax alternative to Lua for game scripting: Squirrel demonstrated that a lightweight, table-based, embeddable language could keep Lua’s runtime virtues while offering syntax and class semantics more familiar to C++ developers, easing adoption in game studios.

  2. Reach through host variants: Rather than spreading primarily as a standalone language, Squirrel propagated through customized engine dialects — Valve’s VScript and Gaijin’s Squirrel/Quirrel lineage among them — putting the language in front of large modding and player communities.

  3. A case study in embeddable design trade-offs: Its combination of reference counting with a cyclic garbage-collection backup, delegation alongside classes, and generators plus coroutines makes Squirrel a compact illustration of the design decisions that embeddable scripting languages must balance for real-time use.

Timeline

2003
Alberto Demichelis releases the first public version of Squirrel on September 6, under the zlib/libpng license, motivated by his experience embedding Lua in game engines
2005
Version 2.0 released on April 3, expanding the language and standard library
2006
Gaijin Entertainment adopts Squirrel (with in-house modifications) for its Dagor Engine, later powering titles such as War Thunder
2009
Left 4 Dead 2 becomes the first Valve game to feature VScript, a modified Squirrel variant embedded in the Source engine for level and event scripting
2010
In November, the license is changed from zlib/libpng to the MIT license to allow the project to be hosted on Google Code
2011
Version 3.0 released in 2011, adding features and refinements over the 2.x line
2019
Gaijin Entertainment forks its internal dialect as Quirrel, a separate language reportedly modified to be safer, stricter, and faster (Gaijin's copyright on the fork dates to around this period)
2022
Version 3.2 released on February 10, the current stable release, with the project maintained on GitHub

Notable Uses & Legacy

Valve (Source engine VScript)

Valve embeds a modified Squirrel variant called VScript in the Source engine for map and gameplay scripting, used in Left 4 Dead 2, Portal 2, Team Fortress 2, and Counter-Strike: Global Offensive.

Gaijin Entertainment (War Thunder)

Uses a Squirrel-derived scripting language in its Dagor Engine for user interface and in-game event logic; the dialect was formally forked as Quirrel in 2019.

Thimbleweed Park

Ron Gilbert and Gary Winnick's point-and-click adventure game uses Squirrel for its game logic, echoing the SCUMM-style scripting tradition of classic LucasArts adventures.

NewDark (Thief 2: The Metal Age)

The unofficial NewDark engine update for Thief 2 exposes Squirrel as a simplified means of scripting mission events alongside the original C-based scripting.

Electric Imp

The Electric Imp IoT platform uses Squirrel as the programming language for both device-side and agent-side application code on connected hardware.

Code::Blocks

The open-source Code::Blocks C/C++ IDE embeds Squirrel as its scripting language for automating build tasks and extending the environment.

Language Influence

Influenced By

Influenced

Quirrel

Running Today

Run examples using the official Docker image:

docker pull
Last updated: