Python-style syntax meets powerful pipelines. Minimal ceremony, maximum productivity. Build scripts, automate tasks, and integrate with C and Python seamlessly.
# Simple and expressive
import fs
import proc
def greet(name):
return "Hello, " + name + "!"
# Pipeline operator for clean data flow
files = fs.list(".") |> filter(fn(f): f.endswith(".nx"))
print(greet("World"))
Designed for developers who value simplicity without sacrificing power.
Stack-based VM with optimized bytecode. Compile once, run fast with versioned bytecode format.
Python-style indentation with colons. No boilerplate, no ceremony. Just write your logic.
Chain operations elegantly with |>. Transform data with functional composition.
Load C libraries directly. Call Python scripts and get JSON results. Best of all worlds.
Static analysis with strict mode. Catch errors before runtime. Warnings for unused code.
Editor integration with diagnostics and document symbols. Works with VS Code, Neovim, and more.
Get Nexo running on your system in seconds.
curl -fsSL https://nexo.dev/install.sh | sh
irm https://nexo.dev/install.ps1 | iex
cargo install nexo
Familiar and intuitive syntax inspired by Python.
# Primitives
num = 42 # Number (f64)
text = "hello" # String
flag = true # Bool
empty = null # Null
# Collections
arr = [1, 2, 3]
map = {"key": "value", "n": 10}
if x > 10:
print("big")
else:
print("small")
while i < 5:
print(i)
i = i + 1
try:
risky_operation()
catch err:
print("Error: " + err)
def add(a, b):
return a + b
def greet(name):
print("Hello, " + name)
# Closures capture by value
def make_counter():
count = 0
return fn():
count = count + 1
return count
# Import modules
import fs
import proc as p
# Export functions
export my_function
# Resolution order:
# 1. Relative path
# 2. nexo_modules/
# 3. Parent nexo_modules/
+ - * / %
== != > >= < <=
and or not
|>
Real-world examples showing Nexo's power and simplicity.
Read, write, and list files
import fs
# Read file contents
content = fs.read("config.json")
# Write to file
fs.write("output.txt", "Hello, Nexo!")
# List directory
files = fs.list("./src")
for file in files:
print(file)
Run shell commands
import proc
# Run a command
result = proc.run("ls -la")
# Access output
print(result.out)
print("Exit code: " + str(result.code))
# Check for errors
if result.code != 0:
print("Error: " + result.err)
Chain operations elegantly
# Transform data with pipelines
numbers = [1, 2, 3, 4, 5]
result = numbers
|> filter(fn(x): x > 2)
|> map(fn(x): x * 2)
|> reduce(fn(a, b): a + b, 0)
print(result) # 24
Call C libraries directly
# Load a C library
lib = ffi_load("mymath.dll")
# Call C functions
result = ffi_call(lib, "add", [10, 20])
print("10 + 20 = " + str(result))
# Supports up to 4 arguments
# extern "C" fn(f64...) -> f64
Run Python scripts
import py
# Run Python script with input
data = py.run("process.py", "input data")
# Python returns JSON via stdout
# Nexo converts to map/array
print(data.result)
print(data.items)
Parse and stringify JSON
# Parse JSON string
data = json_parse('{"name": "Nexo", "version": 9}')
print(data.name) # Nexo
# Create JSON string
obj = {"status": "ok", "count": 42}
json_str = json_stringify(obj)
print(json_str)
Powerful command-line interface for development.
nexo run
Execute a .nx source file or .nxbc bytecode
nexo --emit
Compile to bytecode (.nxbc) without executing
nexo lint
Static analysis with optional --strict mode
nexo repl
Interactive REPL with multiline support
nexo lsp
Language Server Protocol for editor integration