"Grow mighty worlds from little acorns."
Acorn is a flexible, powerful, lightweight, embeddable programming language. Although it is a general-purpose language, its design decisions were driven by one clear objective:
Make it easy to rapidly assemble rich, interactive, Internet-shareable, three-dimensional worlds.
To serve that goal well, Acorn is:
- a modelling language, as it enables specification of complex systems that can be simulated via real-time high-quality rendering, timely interactions between people and parts, and rule-driven changes of state.
- an event-driven language, to ensure worlds stay calm and responsive even while juggling a blur of competing workload demands.
- an object-oriented language, as snapping together flexibly typed, modular parts, each with its own content and behavior, is ideally suited to the object-oriented paradigm.
- a dynamic language, to minimize how much language-and-tool-wrestling one must endure to quickly and incrementally bring a world to life.
Features
For a lightweight language, Acorn offers a surprisingly rich set of features (see the Showcase for code examples):
- Readable, modular content handling:
- 'this' blocks and operators for in-code content assembly (static and procedurally-generated)
- @ operator for url-based, snap-together inclusion of Internet-hosted content
- Content iterators and 'each' control block
- Url-based resource handling:
- Dynamic, asynchronous-capable resource loading and link-edit
- Automatic resource unzip and de-compression
- Acorn programs are treated as dynamically loadable resources
- Relative url addressing
- Extensible url schemes and content type de-serialization
- Comprehensive object-oriented, mutable, higher order types:
- Classical and protypical dynamic inheritance
- Multiple inheritance via constructor-capable mixins
- Method overloading for arithmetic, comparison, indexing operators
- Inheritable, and computable (get/set) properties
- Singleton objects with custom behavior and properties
- No automatic type coercion
- Stateless and stateful, higher-order methods:
- Explicit, Implicit and Get/set Closures
- Yielders (co-routines)
- Variable-sized parameter lists
- Multiple return values
- Tail-call optimization
- Extensible pattern matching:
- Type-defined '~~' match operator
- 'match' blocks using custom match methods
- Content extraction during matching
- 'do' block for context management
- Concise, readable code:
- Off-side rule
- 'this'-implied prefix operators for method cascading, etc.
- Implicit return
- Control clauses for 'if', 'while', 'each'
- Parallel assignment
- Distinguishes immutable, atomic symbols ('a') from mutable text strings ("a")
- Unicode-aware text strings and variable names
Many of Acorn's features are gathered from other scripting languages, particularly Lua, Javascript and Ruby.
The Acorn implementation:
- Is an embeddable re-entrant library written in C-89-compliant, well-documented code
- provides a built-in core type library
- Has no external dependencies beyond a few standard C functions in stdio and stdlib.
- Is lightweight. Its C code is just a few thousand LOC. Its executable footprint is typically smaller than 400K.
- Offers a C API, useful for creating high-performance types using C code and libraries
- Manages memory use via a low impact, built-in generational and incremental mark-and-sweep garbage collector
- Compiles Acorn programs on the fly into quickly interpreted byte-code
Reference Sections
As should be obvious by now, this Acorn Language Reference is written for people comfortable and familiar with programming concepts and code. It contains the following sections:
- Showcase. A few selected examples that demonstrate Acorn's visual style and idioms.
- Language Reference. Comprehensive explanation (with examples) of Acorn's features.
- Syntax. Formal grammar using railroad diagrams and EBNF notation.
- Design Rationale. Explains the objectives and inspirations that guided the design decisions for Acorn.