Xeno Language β a compact, safe interpreted language and virtual machine for the ESP32 (Arduino) ecosystem.
Implemented as: compiler β bytecode β VM with built-in commands for numbers, strings, branching, loops and basic GPIO control.
Developed by VL_PLAY Games
β¨ Highlights
- Execute code from
.xenofiles or embedded source strings. - Lightweight and easy to embed into nearly any ESP32 project.
- Designed for hobbyists, education, and small automation tasks.
β‘οΈ Performance
- Benchmarks show Xeno is roughly ~26Γ slower than equivalent native C++, depending on workload (see
benchmark.ino). - Compared to other interpreted MCU languages (MicroPython, Lua), Xeno's performance is in the same ballpark β exact differences depend heavily on the type of code and usage patterns. Use
benchmark.inofor workload-specific comparisons.
| Feature / Language | Xeno π§ | MicroPython π | Lua (NodeMCU) π | C++ (Native) βοΈ |
|---|---|---|---|---|
| Execution Speed (vs C++) | ~26Γ slower | ~18Γ slower (approx.) | ~20Γ slower (approx.) | π₯ Baseline |
| Memory Usage (RAM) | Low (~20 KB) | Medium (~30 KB) | Medium (~25 KB) | High control (manual) |
| File-based Execution | β
.xeno files |
β
.py files |
β
.lua files |
|
| Hardware Access (GPIO, etc.) | β Rich | β Rich | β Full | |
| Ease of Embedding | βοΈβοΈβοΈβοΈβοΈ | βοΈβοΈβοΈβοΈ | βοΈβοΈβοΈβοΈ | βοΈβοΈ |
| Language Simplicity | Moderately easy | Easy | Moderate | Complex |
| Embeddable in C++ Projects | β Fully embeddable | β | ||
| Ideal Use Cases | Teaching, quick logic, in-app scripting | Prototyping, IoT | Scripting automation | Performance-critical |
β‘ Notes:
- Speed ratios for Xeno were measured on ESP32-C3 @160 MHz. Values for MicroPython and Lua are approximate comparisons against C++ and will vary by workload and firmware. See
benchmark.inofor full details.- Xeno advantage: Unlike MicroPython or Lua on many ESP32 workflows, Xeno can be embedded directly inside an existing C++ firmware β no separate interpreter firmware required.
- GPIO note: Hardware access in Xeno is currently limited to LED control, with broader GPIO and peripheral support planned for future updates.
- Any ESP32-class microcontroller (ESP32, ESP32-S2, etc.)
- Recommended free Flash: β₯ 60 KB
- Recommended free RAM: β₯ 20 KB
- ESP32 Arduino core: 3.2.0+
- Arduino IDE: 2.0+
Note: actual memory usage depends on enabled features, strings, and included examples. If your project is tight on RAM/Flash, strip unused features and reduce
MAX_*values in config headers.
Method 1: Library Manager (Recommended)
- In Arduino IDE: Tools β Manage Libraries...
- Search for "Xeno Language"
- Click "Install"
Method 2: Manual Installation
- Download the latest library version from Releases section
- In Arduino IDE: Sketch β Include Library β Add .ZIP Library...
- Select the downloaded
Xeno-Language-vX.X.X.zipfile
Usage examples can be found in: File β Examples β Xeno Language
#include <XenoLanguage.h>
XenoLanguage xeno;
void setup() {
Serial.begin(115200);
String program = R"(
print "Hello from Xeno!"
halt
)";
xeno.compile(program);
xeno.run();
}
void loop() {
// Optionally use xeno.step() for single-step execution or poll status
}print "text"β print a literal string.print $varβ print variable value.set var exprβ assign variable (supports expressions).input varβ request input via Serial (stored as string, number or boolean).haltβ stop program execution.led <pin> on|offβ toggle an allowed GPIO pin.delay <ms>β delay in milliseconds (bounded).- Arithmetic operators:
+,-,*,/,%,^(power). - Functions:
abs(),sqrt(),sin(),cos(),tan(),max(),min(). - Constants:
M_PI,M_E,M_TAU,M_SQRT2,M_SQRT3,P_LIGHT_SPEED. - Control flow:
if ... then ... else ... endif,for var = start to end ... endfor. - Boolean values:
true,false. - Single-line comments use
//.
// Comments
print "Hello World"
led 13 on
delay 1000
// Variables
set x 10
set name "Xeno"
set flag true
print $x
print $flag
// Arithmetic
set result (x + 5) * 2
// Conditionals
if x > 5 then
print "Larger than 5"
endif
// Loops
for i = 1 to 10
print $i
endfor
// Boolean operations
set a true
set b false
if a == true then
print "a is true"
endif
- Arithmetic:
+ - * / % ^,abs(),sqrt(),sin(),cos(),tan(),max(),min() - Constants:
M_PI,M_E,M_TAU,M_SQRT2,M_SQRT3,P_LIGHT_SPEED - Comparisons:
== != < > <= >= - Control:
if/then/else/endif,for/endfor - Peripherals:
print,led on/off,delay - Data types: integers, floats, strings, booleans
-
Executes compiled bytecode using a runtime stack, variable table, and string table.
-
Built-in safety checks: stack overflow, invalid opcode, divide-by-zero, bounds checking.
-
API highlights (
class XenoLanguage):-
bool compile(const String& source)β compile source to bytecode. -
bool run()β execute compiled bytecode. -
void step()β execute a single VM instruction. -
void stop()β stop execution. -
bool isRunning() constβ check running state. -
void printCompiledCode()β print bytecode + string table / debug info. -
void setMaxInstructions(uint32_t max_instr)β raise instruction limit. -
setStringLimit(256)// Max string length -
setVariableNameLimit(32)// Max variable name length -
setExpressionDepth(32)// Max expression nesting -
setLoopDepth(16)// Max loop nesting -
setIfDepth(16)// Max if/else nesting -
setStackSize(256)// Stack memory size -
setAllowedPins({2,3,13})// Configure allowed pins -
addAllowedPin(5)// Add pin -
removeAllowedPin(13)// Remove pin -
compile_and_run("print 'Hello World'")β convenience wrapper. -
Version getters:
getLanguageVersion().
-
max_string_length = 256max_variable_name_length = 32max_expression_depth = 32max_loop_depth = 16max_if_depth = 16max_stack_size = 256current_max_instructions = 10000allowed_pins = { LED_BUILTIN }
MIN_STRING_LENGTH = 1,MAX_STRING_LENGTH_LIMIT = 4096MIN_VARIABLE_NAME_LENGTH = 1,MAX_VARIABLE_NAME_LENGTH_LIMIT = 256MIN_EXPRESSION_DEPTH = 1,MAX_EXPRESSION_DEPTH_LIMIT = 256MIN_LOOP_DEPTH = 1,MAX_LOOP_DEPTH_LIMIT = 64MIN_IF_DEPTH = 1,MAX_IF_DEPTH_LIMIT = 64MIN_STACK_SIZE = 16,MAX_STACK_SIZE_LIMIT = 2048MIN_INSTRUCTIONS_LIMIT = 1000,MAX_INSTRUCTIONS_LIMIT = 1000000MIN_PIN_NUMBER = 0,MAX_PIN_NUMBER = 255
All setters validate values; out-of-range values are rejected.
Common VM opcodes include:
OP_NOP, OP_PRINT, OP_PRINT_NUM, OP_PUSH, OP_POP,
OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD,
OP_POW, OP_ABS, OP_SQRT, OP_MAX, OP_MIN,
OP_SIN, OP_COS, OP_TAN,
OP_STORE, OP_LOAD,
OP_JUMP, OP_JUMP_IF,
OP_INPUT, OP_DELAY, OP_LED_ON, OP_LED_OFF,
OP_PUSH_FLOAT, OP_PUSH_STRING, OP_PUSH_BOOL,
OP_EQ, OP_NEQ, OP_LT, OP_GT, OP_LTE, OP_GTE,
OP_HALT
See examples/ in the repository:
comparison.inoβ if/else + comparisons.float_string.inoβ floats and string handling.for_loop.inoβ for loops and blinking examples.input_max_min.inoβ input handling + math functions.math.ino,math2.inoβ math tests and benchmarks.benchmark.inoβ performance comparison between native C++ and Xeno VM.bool.inoβ boolean variables and operations.
- Always open Serial (115200) for logs and input prompts.
- If you see
CRITICAL ERROR: Stack overflow, reduce expression complexity or increaseMAX_STACK_SIZEcarefully. - If GPIO commands fail, check the allowed pin list in
xeno_security.h. - Use
printCompiledCode()to debug compiled bytecode.
π― Planned next steps:
- Continue actively developing core functionality.
- Improve optimization and reduce VM overhead.
- Add integration with XenoOS and better tooling for editing
.xenofiles. - Add more examples, CI pipelines, and PlatformIO templates.
Contributions, issues and pull requests are welcome. If you contribute, please:
- Respect the Apache 2.0 license and include clear commit messages.
- Add small, focused PRs with tests/examples when possible.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Xeno Language β developed by VL_PLAY Games.