pear-lang
v0.2.7
Published
Pear scripting language - now with Discord/HTTP
Maintainers
Readme
Pear
Status
Pear is now archived and will no longer receive updates.
This project was an early-stage prototype exploring a custom scripting language and runtime. It reached a natural stopping point as the design scope expanded beyond its original intent.
Pear is a lightweight scripting language designed for clarity, flexibility, and fast automation.
It is not based on JavaScript or Lua, but it supports similar capabilities such as functions, tables, arrays, and modules while using its own syntax and execution model.
Pear is built for scripting, bots, tools, and extensible automation systems.
Current Features
Pear currently supports:
Core language
letvariables (declaration)setassignments (update values)- Numbers, strings, booleans, and null
- Expressions (math + logic operators)
if / elseconditionalswhileloopsreturnstatements in functions
Functions
- First-class functions (
fn) - Function parameters
- Closures (functions can capture variables)
- Return values
Data structures
- Arrays:
[] - Tables (maps / objects):
{ key: value } - Nested structures supported
Modules
import "file.pear"for file-based module loading
Standard runtime
Built-in global functions:
print(...)→ output to consolesleep(ms)→ async delaylength(value)→ get size of arrays/strings
Developer tools
Pear includes a full CLI toolchain:
pear run <file>→ execute a scriptpear repl→ interactive shellpear eval "<code>"→ execute inline codepear version→ show version
Error system
- Runtime errors include line and column numbers
- Parser errors show descriptive messages
- Stack-safe execution model (no raw JS traces exposed to user code)
Runtime
Pear runs on a custom interpreter built in Node.js.
The execution pipeline is:
Source Code ↓ Tokenizer ↓ Parser (AST) ↓ Pear VM (Evaluator) ↓ Runtime Environment (JS bridge)
Installation
Prerequisite
- Node.js 16+
Install globally via npm:
npm install -g pear-langUsage
Run a file
pear run script.pearStart REPL
pear replEvaluate inline code
pear eval "print('hello')"Example
let x = 10
fn add(a, b):
return a + b
end
let result = add(5, 7)
print(result)Philosophy
Pear is designed around three principles:
- Clarity over complexity
- Control over abstraction
- Predictable execution
It aims to give scripting power similar to Lua and JavaScript without copying their syntax or runtime behavior.
Future roadmap
Planned features:
- Bytecode VM (performance upgrade)
- Package manager (
pear install) - Module exports (
export) - Async/await system
- Better debugging tools (stack traces, breakpoints)
- Standard library expansion
