The world's most advanced programming language. Simpler than Python, more powerful than all. Zero external dependencies.
Every design decision serves a purpose. Nexus rethinks programming from the ground up.
Reversible computing for minimal energy dissipation. Every operation can be undone, approaching the thermodynamic limit of computation.
Code moves to data, not data to code. Computation happens where the information lives, eliminating unnecessary data transfer.
No threads, no async, no await. The interaction net VM automatically parallelizes computations across all available cores.
Every function has a gradient. Automatic differentiation is built into the IR, making machine learning a first-class citizen.
Write and run Nexus code instantly. No installation required.
Natural English-like syntax. No colons, no parentheses clutter, no boilerplate.
-- The simplest Nexus program say "Hello, Nexus!" -- Variables with type inference let x = 42 let name = "World" let active = yes -- Functions are natural greet person say "Hello, " + person + "!" greet "Alice"
-- Create tensors with explicit shapes let weights = Tensor.random[784, 256] let bias = Tensor.zeros[256] -- Matrix multiplication with @ operator let hidden = input @ weights + bias -- Automatic differentiation let dW = grad loss over weights weights = weights - learning_rate * dW
struct Dense weights: Tensor[In, Out] bias: Tensor[Out] forward x x @ weights + bias let model = create_mlp 784, [512, 256], 10 train model, data, epochs optimizer = Adam.create 0.001 for epoch in 1 to epochs for batch in data.batches 32 loss = cross_entropy predictions, batch.y for param in model.params g = grad loss over param param = optimizer.step param, g
-- Parallelism is automatic parallel for x in data process x -- Reversible computing reversible swap a, b temp = a a = b b = temp undo swap -- reverses it
A complete language ecosystem built from the ground up.
Based on Lafont's Interaction Combinators. Six fundamental rules govern all computation.
Every IR operation has forward and backward computation. Gradients are generated automatically.
Matrix multiplication, convolutions, and activations are native primitives.
Lock-free parallel scheduling across all CPU cores with zero manual thread management.
Operations can be undone at any time. An undo stack tracks state changes.
The compiler compiles itself. A 4-stage bootstrap from raw machine code.
No Rust. No C. No Node.js. Nexus bootstraps itself from raw x86-64 machine code.
Everything you need to write Nexus programs. Click any topic to expand.
Nexus has two kinds of variables. Use let to declare immutable variables --
once assigned, they cannot be changed. Use var for mutable variables that
you intend to update later. This distinction helps catch bugs early: if a value should stay constant (a
name, a config, a computed result), let ensures it is never accidentally overwritten.
-- IMMUTABLE: once you set it, it stays forever let pi = 3.14159 let greeting = "Hello, Nexus!" let is_ready = yes let nothing_here = nothing -- MUTABLE: you can reassign as many times as needed var score = 0 score = score + 10 -- score is now 10 score = score * 2 -- score is now 20 -- Trying to reassign a let variable will cause an error -- pi = 3.0 ERROR: cannot reassign immutable variable
Nexus is dynamically typed -- you never write type annotations. The interpreter determines the type from the value you assign. Every value in Nexus belongs to one of these seven types:
| Type | What It Is | Examples | Notes |
|---|---|---|---|
| Int | Whole numbers (positive, negative, or zero) | 42, -7, 0, 1000 | No size limit |
| Float | Decimal numbers with fractional parts | 3.14, -0.5, 2.0 | Double precision |
| Text | Strings of characters, always in double quotes | "Hello", "abc" | Supports concatenation with + |
| Bool | Boolean true/false. Written as yes / no |
yes, no | NOT true/false |
| Nothing | Absence of a value (like null in other languages) | nothing | NOT null/None |
| List | Ordered, mutable collection of any values | [1, "a", yes] | Mixed types allowed |
| Table | Key-value pairs (dictionary/map/object) | {name: "Alice"} | Keys are strings |
Use type(value) to check the type of any value at runtime. It returns the type name as a
string. Use string(), int(), and float() to convert between
types:
say type(42) -- "Int" say type(3.14) -- "Float" say type("Hello") -- "Text" say type(yes) -- "Bool" say type([1,2,3]) -- "List" say type(nothing) -- "Nothing" -- Converting between types let num = int("42") -- text to integer: 42 let dec = float("3.14") -- text to float: 3.14 let txt = string(100) -- number to text: "100" -- String concatenation auto-converts numbers say "Score: " + 42 -- "Score: 42"
If you are coming from Python, JavaScript, or other languages, watch out for these differences:
yes / no instead of true / falsenothing instead of null, None, or undefined
is / isnt instead of == / !="..." -- single quotes are not supportedFunctions in Nexus are defined by writing the function name followed by its parameters, with the body
indented below (4 spaces). There is no def, func, or function
keyword -- just the name. Functions must be defined before they are called.
-- Define a function: name, then parameters, then indented body greet name say "Hello, " + name + "!" -- Call it (two styles -- both work) greet("Alice") -- parentheses style greet "Bob" -- bare call style (no parens) -- Function with multiple parameters add x, y return x + y say add(10, 20) -- 30
Use return to send a value back to the caller. If you forget return, the
function returns nothing by default. This is a common mistake -- always include
return when you need a result.
-- WRONG: computes but does not return bad_add x, y x + y -- this value is lost! -- CORRECT: explicitly returns the result good_add x, y return x + y -- caller receives the value say bad_add(2, 3) -- nothing say good_add(2, 3) -- 5
Functions can call themselves. This is useful for problems that have a naturally recursive structure, like computing factorials, traversing trees, or generating Fibonacci numbers.
factorial n if n <= 1 return 1 return n * factorial(n - 1) say factorial(5) -- 120 (5*4*3*2*1) say factorial(10) -- 3628800 fib n if n <= 1 return n return fib(n - 1) + fib(n - 2) say fib(10) -- 55
Nexus provides several ways to make decisions in your code. All block structures use 4-space
indentation to define the body -- there are no curly braces or end keywords.
The basic conditional. elif (short for "else if") lets you chain multiple conditions. The
else block runs when no preceding condition was true.
let score = 85 if score >= 90 say "Grade: A" elif score >= 80 say "Grade: B" -- this runs (85 >= 80) elif score >= 70 say "Grade: C" else say "Grade: F"
The opposite of if. The block runs only when the condition is false. Useful
for guard clauses and negative checks.
let logged_in = no unless logged_in say "Please log in first" -- runs because logged_in is no
Like switch in other languages, but cleaner. Compares a value against multiple patterns. Use
_ as the default/wildcard case that matches anything.
let status = 404 match status 200 -> say "OK - Request succeeded" 301 -> say "Moved permanently" 404 -> say "Not Found" -- this matches 500 -> say "Server Error" _ -> say "Unknown status: " + status -- Works with strings too let fruit = "apple" match fruit "apple" -> say "Red or green" "banana" -> say "Yellow" _ -> say "Unknown fruit"
Nexus uses English words for equality: is (equals), isnt (not equals). Standard
symbols work for ordering: <, >, <=, >=.
Logical operators: and, or, not.
if x is 42 -- equality (NOT ==) if x isnt 0 -- inequality (NOT !=) if x > 10 and x < 100 -- logical AND if x is 0 or x is 1 -- logical OR if not done -- logical NOT
Nexus offers four loop types, each suited to different situations. All loops use 4-space indentation for the body. Nexus includes a safety limit of 100,000 iterations to prevent infinite loops from freezing your program.
Iterates over a numeric range. The range is inclusive on both ends (unlike Python). Use
by to set a custom step.
-- Counts 1, 2, 3, 4, 5 (inclusive on both ends) for i in 1 to 5 say i -- With a step: 0, 10, 20, 30, ..., 100 for i in 0 to 100 by 10 say i
Iterates over every element in a list, string, or other collection. The variable takes each value in order.
let colors = ["crimson", "gold", "ivory"] for color in colors say "Color: " + color -- Iterate over characters in a string for ch in "Nexus".chars say ch -- N, e, x, u, s
Repeats as long as a condition is true. Make sure the condition eventually becomes false, otherwise you will hit the 100,000 iteration safety limit.
var n = 1 while n < 1000 say n -- 1, 2, 4, 8, 16, ... n = n * 2
Runs a block exactly N times. Simpler than a for loop when you do not need the counter variable.
repeat 3 times say "Hip hip hooray!"
Use skip to jump to the next iteration (like continue in other languages). Use
stop to exit the loop entirely (like break).
-- Print only odd numbers up to 10 for i in 1 to 20 if i mod 2 is 0 skip -- skip even numbers if i > 10 stop -- stop at 10 say i -- 1, 3, 5, 7, 9
Nexus strings (type Text) support a rich set of properties and methods.
Properties are accessed without parentheses and return a computed value.
Methods take arguments and require parentheses. This distinction matters -- forgetting
parentheses on a method will not call it.
| Property | Returns | Example | Result |
|---|---|---|---|
| .length | Number of characters | "hello".length | 5 |
| .upper | Uppercase copy | "hello".upper | "HELLO" |
| .lower | Lowercase copy | "HELLO".lower | "hello" |
| .trim | Removes leading/trailing spaces | " hi ".trim | "hi" |
| .reverse | Reversed string | "abc".reverse | "cba" |
| .chars | List of individual characters | "hi".chars | ["h","i"] |
| .words | List split by whitespace | "hi there".words | ["hi","there"] |
| .lines | List split by newlines | "a\nb".lines | ["a","b"] |
| .is_empty | yes if length is zero | "".is_empty | yes |
| .is_digit | yes if all chars are digits | "123".is_digit | yes |
| .is_alpha | yes if all chars are letters | "abc".is_alpha | yes |
| Method | What It Does | Example | Result |
|---|---|---|---|
| .split(sep) | Splits string into list by separator | "a-b-c".split("-") | ["a","b","c"] |
| .replace(old,new) | Replaces all occurrences | "hello".replace("l","r") | "herro" |
| .contains(sub) | Checks if substring exists | "hello".contains("ell") | yes |
| .starts_with(pre) | Checks prefix | "hello".starts_with("he") | yes |
| .ends_with(suf) | Checks suffix | "hello".ends_with("lo") | yes |
| .find(sub) | Index of first occurrence (-1 if not found) | "hello".find("ll") | 2 |
| .count(sub) | Number of occurrences | "hello".count("l") | 2 |
| .repeat(n) | Repeats string n times | "ha".repeat(3) | "hahaha" |
| .slice(start,end) | Substring from start to end | "hello".slice(1,3) | "ell" |
Access individual characters by index (0-based). Negative indices count from the end: -1 is
the last character, -2 is second to last, etc.
let s = "Nexus" say s[0] -- "N" (first character) say s[-1] -- "s" (last character) say s[-2] -- "u" (second from end)
Use + to join strings. Numbers are auto-converted when concatenated with a string:
let first = "Hello" let last = "World" say first + ", " + last + "!" -- "Hello, World!" say "Age: " + 25 -- "Age: 25" (auto-converts)
Lists are ordered, mutable collections that can hold values of any type. They are created with square
brackets [] and support indexing, slicing, and a wide range of built-in methods. Lists are
zero-indexed (the first element is at index 0).
let nums = [10, 20, 30, 40, 50] let mixed = [1, "two", yes, [3, 4]] -- mixed types, nested lists let empty = [] -- empty list -- Access by index (0-based) say nums[0] -- 10 (first element) say nums[2] -- 30 (third element) -- Negative indexing (count from end) say nums[-1] -- 50 (last element) say nums[-2] -- 40 (second from end) -- Properties say nums.length -- 5 say nums.first -- 10 say nums.last -- 50 say nums.is_empty -- no
These methods modify the list in place. Use var (not let) if you plan to mutate
the list.
| Method | What It Does | Example |
|---|---|---|
| .append(val) | Adds value to the end of the list | list.append(42) |
| .pop() | Removes and returns the last element | list.pop() |
| .insert(idx, val) | Inserts value at the given index | list.insert(0, "first") |
| .remove(val) | Removes the first occurrence of value | list.remove(42) |
| .sort() | Sorts the list in ascending order | list.sort() |
| .reverse() | Reverses the list in place | list.reverse() |
These return a new list/value without changing the original:
| Function | Returns | Example | Result |
|---|---|---|---|
| sorted(list) | New sorted list | sorted([3,1,2]) | [1,2,3] |
| reversed(list) | New reversed list | reversed([1,2,3]) | [3,2,1] |
| unique(list) | List with duplicates removed | unique([1,1,2,3]) | [1,2,3] |
| flatten(list) | Flattens nested lists | flatten([[1],[2,3]]) | [1,2,3] |
| sum(list) | Sum of all elements | sum([1,2,3,4]) | 10 |
| min(list) | Smallest element | min([5,3,8]) | 3 |
| max(list) | Largest element | max([5,3,8]) | 8 |
| mean(list) | Average of elements | mean([2,4,6]) | 4 |
| zip(a, b) | Pairs elements from two lists | zip([1,2],["a","b"]) | [[1,"a"],[2,"b"]] |
| enumerate(list) | Adds index to each element | enumerate(["a","b"]) | [[0,"a"],[1,"b"]] |
Pass functions to map, filter, and reduce for functional-style
list processing:
double x return x * 2 say map(double, [1,2,3]) -- [2, 4, 6] is_even x return x mod 2 is 0 say filter(is_even, [1,2,3,4]) -- [2, 4]
Tables are key-value collections, similar to dictionaries in Python, objects in JavaScript, or hashmaps in Java. Keys are always strings. Values can be any type, including other tables or lists.
let user = { name: "Alice", age: 30, role: "Engineer", active: yes } -- Access with dot notation say user.name -- "Alice" say user.age -- 30
| Property/Method | Returns | Example |
|---|---|---|
| .keys | List of all keys | user.keys --> ["name","age","role","active"] |
| .values | List of all values | user.values --> ["Alice",30,"Engineer",yes] |
| .count | Number of key-value pairs | user.count --> 4 |
| .has(key) | Checks if key exists | user.has("name") --> yes |
| .remove(key) | Removes a key-value pair | user.remove("role") |
| .merge(other) | Combines two tables | user.merge({city: "NYC"}) |
let config = { app: "Nexus", version: 1, settings: { theme: "dark", font_size: 14 } } say config.settings.theme -- "dark"
Structs let you define custom data types with named fields and methods. They are like lightweight
classes. Define a struct with the struct keyword, list its fields with type annotations,
and optionally add methods.
struct Point x: Float y: Float magnitude return sqrt(x * x + y * y) distance other let dx = x - other.x let dy = y - other.y return sqrt(dx * dx + dy * dy) -- Create instances by calling the struct like a function let a = Point(3, 4) let b = Point(0, 0) say a.x -- 3 say a.y -- 4 say a.magnitude() -- 5.0 say a.distance(b) -- 5.0
struct Rectangle width: Float height: Float area return width * height perimeter return 2 * (width + height) is_square return width is height let r = Rectangle(10, 5) say "Area: " + r.area() -- 50 say "Perimeter: " + r.perimeter() -- 30 say "Square? " + r.is_square() -- no
Nexus ships with 60+ built-in functions organized into categories. These are available everywhere without imports. Each function is listed below with its purpose and signature.
| Function | Description | Example | Result |
|---|---|---|---|
| sqrt(x) | Square root | sqrt(144) | 12 |
| abs(x) | Absolute value | abs(-42) | 42 |
| sin(x), cos(x), tan(x) | Trigonometric functions (radians) | sin(pi/2) | 1.0 |
| exp(x) | e raised to the power x | exp(1) | 2.718... |
| log(x) | Natural logarithm | log(e) | 1.0 |
| floor(x) | Round down to nearest integer | floor(3.7) | 3 |
| ceil(x) | Round up to nearest integer | ceil(3.2) | 4 |
| round(x) | Round to nearest integer (or precision) | round(3.456, 2) | 3.46 |
| pow(x, y) | x raised to the power y | pow(2, 10) | 1024 |
| factorial(n) | n! = n * (n-1) * ... * 1 | factorial(5) | 120 |
| gcd(a, b) | Greatest common divisor | gcd(12, 8) | 4 |
| clamp(x, lo, hi) | Constrain x between lo and hi | clamp(15, 0, 10) | 10 |
| relu(x) | max(0, x) -- used in neural networks | relu(-5) | 0 |
| sigmoid(x) | 1/(1+e^-x) -- logistic function | sigmoid(0) | 0.5 |
Constants: pi = 3.14159... and e = 2.71828... are available as
global constants.
| Function | Description | Example | Result |
|---|---|---|---|
| sum(list) | Sum of all numbers in a list | sum([1,2,3,4]) | 10 |
| mean(list) | Arithmetic average | mean([2,4,6]) | 4 |
| min(list) / min(a,b) | Smallest value | min([5,3,8]) | 3 |
| max(list) / max(a,b) | Largest value | max([5,3,8]) | 8 |
| count(list) | Number of elements | count([1,2,3]) | 3 |
| any(list) | yes if any element is truthy | any([no,yes,no]) | yes |
| all(list) | yes only if all elements are truthy | all([yes,yes,no]) | no |
| Function | Description | Example |
|---|---|---|
| say value | Print a value followed by a newline | say "Hello" |
| print(a, b, ...) | Print multiple values space-separated | print("x =", 42) |
| input(prompt) | Read a line of text from the user | let name = input("Name: ") |
| read_file(path) | Read entire file contents as text | let data = read_file("data.txt") |
| write_file(path, text) | Write text to a file (overwrites) | write_file("out.txt", "hello") |
| file_exists(path) | Check if a file exists | if file_exists("config.nx") |
| Function | Description | Example |
|---|---|---|
| random() | Random float between 0.0 and 1.0 | let r = random() |
| random_int(min, max) | Random integer in range [min, max] | random_int(1, 6) |
| random_choice(list) | Pick a random element from a list | random_choice(["a","b","c"]) |
| Function | Description | Example |
|---|---|---|
| now() | Current date and time as text | say now() |
| timestamp() | Unix timestamp in seconds | let t = timestamp() |
| hash(value) | Hash a value to a string | hash("password") |
| sleep(ms) | Pause execution for N milliseconds | sleep(1000) |
| exit(code) | Stop the program with exit code | exit(0) |
A complete reference of all operators in Nexus, from arithmetic to logic. Nexus uses English words for equality and boolean logic, making code read more naturally.
| Category | Operators | Example | Notes |
|---|---|---|---|
| Arithmetic | + - * / ^ mod | 2 ^ 10 is 1024 | ^ is power, mod is remainder |
| Matrix Multiply | @ | A @ B | For tensor/matrix operations |
| Equality | is isnt | x is 42, x isnt 0 | NOT == or != (those are errors) |
| Ordering | < > <= >= | x >= 10 | Standard comparison |
| Logical | and or not | a and b, not done | Short-circuit evaluation |
| String | + | "Hi " + name | Concatenation (auto-converts numbers) |
| Assignment | = | x = 42 | Used with var (mutable) only |
When multiple operators appear in one expression, higher-precedence operators bind first. Use parentheses to override:
-- ^ binds before * say 2 + 3 * 4 -- 14 (not 20) say (2 + 3) * 4 -- 20 (parentheses override) say 2 ^ 3 ^ 2 -- 512 (2^(3^2) = 2^9)
You can download Nexus directly from this website using the buttons at the top of the page, or follow these platform-specific instructions. Nexus requires PowerShell (included on Windows, installable on Mac/Linux). No other dependencies are needed.
Click the Download Nexus (Universal) button in the
header. Extract the downloaded `nexus.zip` folder. Open a terminal inside the extracted nexus
folder, and run your .nx programs:
-- Windows (PowerShell) .\nexus-lang.ps1 run examples\hello.nx -- macOS / Linux (Bash) chmod +x nexus.sh ./nexus.sh run examples/hello.nx
-- All platforms:
git clone https://github.com/nexus-lang/nexus.git
cd nexus
Windows comes with PowerShell pre-installed. Just open PowerShell or Terminal and run:
.\nexus-lang.ps1 run examples\hello.nx
.\nexus-lang.ps1 repl -- interactive mode
Install PowerShell via Homebrew, then run:
brew install powershell/tap/powershell chmod +x nexus.sh ./nexus.sh run examples/hello.nx
sudo snap install powershell --classic chmod +x nexus.sh ./nexus.sh run examples/hello.nx
sudo dnf install powershell chmod +x nexus.sh ./nexus.sh run examples/hello.nx
yay -S powershell-bin chmod +x nexus.sh ./nexus.sh run examples/hello.nx
Create files with the .nx extension in any text editor. For the best experience, install the
official Nexus VS Code Extension included in your download:
Ctrl+Shift+X (or Cmd+Shift+X) to open the Extensions panel.... menu at the top right of the Extensions panel and select "Install
from VSIX..."nexus-lang-1.0.0.vsix file located inside your downloaded
nexus-vscode folder!This provides syntax highlighting, auto-indentation, and bracket matching for Nexus. Run programs from your
terminal using the repl command for an
interactive prompt.
Click any error to see the explanation and fix. Playground errors link here.
-- Wrong: say x -- Fix: let x = 42 say x
-- Wrong: let x 42 -- Fix: let x = 42 -- Wrong: let a = [1, 2 -- Fix: let a = [1, 2]
-- Wrong: if x > 0 say "yes" -- not indented! -- Fix: if x > 0 say "yes"
-- Wrong: while yes say "forever" -- Fix: var i = 0 while i < 100 say i i = i + 1
-- Wrong: if x == 42 -- Fix: if x is 42 if x isnt 0
-- Wrong: let active = true -- Fix: let active = yes let done = no
-- Wrong: add x, y x + y -- Fix: add x, y return x + y
-- Properties (no parens): "hi".upper "hi".length -- Methods (need parens): "a-b".split("-") "hi".replace("i","o")
-- Nexus style: say "Hello" -- Also works: print("Hello", "World")
let x = nothing if x is nothing say "no value"
Build the toolchain from scratch or just run a program.
Generate the native assembler from raw machine code.
Compile the VM, compiler, and link everything.
Execute a Nexus program or start the REPL.
Every contribution matters. Join the Nexus community and help shape the language.
Whether you are fixing a bug, adding a feature, writing documentation, or creating examples -- every contribution is recorded and credited to you.
Read the CONTRIBUTING.md file in the repository for detailed guidelines on code style, pull request process, and community standards.
Submit your
.nx library to the Nexus registry. Once approved, users can install it via
nexus install <name>.