What is Arc?
Arc executes JavaScript code as BEAM processes, giving you:- Actor-based concurrency — Spawn thousands of isolated processes, each running JavaScript
- Fault tolerance — Process crashes are isolated and recoverable
- ES modules — Modern import/export syntax with compile-time bundling
- REPL — Interactive development environment with live code evaluation
Architecture overview
Arc implements a complete JavaScript execution pipeline:Key components
Parser
Parses JavaScript source into an Abstract Syntax Tree (AST). Supports both Script and Module modes.
Compiler
Three-phase bytecode compiler: emit symbolic operations, resolve variable scopes, then resolve jump addresses.
VM
Stack-based bytecode interpreter with heap-allocated objects. Executes compiled templates on the BEAM.
Builtins
Standard JavaScript globals (Array, Object, Promise, etc.) plus Arc-specific functions for concurrency.
Compilation pipeline
The compiler transforms AST into executable bytecode through three phases:
The result is a
FuncTemplate containing:
- Bytecode operations (array of
Op) - Constant pool (literals, strings, numbers)
- Nested function templates (closures, arrow functions)
- Metadata (parameter count, strict mode, async/generator flags)
All compilation happens ahead-of-time. The VM never sees source code or AST — only bytecode.
JavaScript on Erlang
Arc bridges two worlds:Heap management
All JavaScript objects live on Arc’s heap — an immutable dictionary arena with garbage collection:Ref(id)) and retrieved via heap.read(). The heap is immutable — every mutation returns a new heap instance.
REPL and module execution
Arc supports two execution modes:REPL mode
Interactive evaluation with persistent state:var/let/const declarations create global bindings that persist across evaluations.
Module execution
Run ES modules from files:- Compile bundle — Parse and compile all dependencies into a
ModuleBundle - Evaluate bundle — Execute modules in dependency order, link imports/exports
Arc namespace
TheArc global provides concurrency primitives:
Next steps
JavaScript on BEAM
Deep dive into the execution model and compilation pipeline
Actor model
Learn actor-based concurrency with Arc.spawn, send, and receive
Modules
ES module system and import/export mechanics