Quantix Documentation
Quantix is a friendly, beginner-first scripting language with clean English-like syntax, case-insensitive commands and instant feedback. It runs on Node.js and Bun with zero dependencies, and a full-featured playground lives right in the browser.
What makes Quantix different?
Reads like English
Terminal.Echo("Hello") is the whole language surface at its simplest β no ceremony, no boilerplate.
Case-insensitive
terminal.echo, Terminal.Echo and TERMINAL.ECHO are all the same command.
Real windows, real turtles
On the desktop, GUI dialogs and Kachua graphics open as true native windows via PyQt5 β no HTML page tricks.
Installation
Quantix has zero runtime dependencies. You need only Node.js 20+ or Bun. To enjoy the optional native desktop GUI and Kachua windows, install PyQt5 (or PySide6) as well β everything gracefully falls back to web rendering without it.
Option 1 β Run online (zero install)
Open the Playground. The entire language runs inside your browser tab on a Cloudflare Worker. Nothing to download.
Option 2 β From the GitHub repo
git clone https://github.com/Sanskriti-Studios/Quantix.git cd Quantix node bin/quantix # interactive shell node bin/quantix examples/demo.qtx # run a program file
Option 3 β Via npm
npm install -g quantix-js quantix help
Optional: native GUI & turtle (desktop)
The desktop interpreter can open real desktop windows for GUI dialogs and the Kachua turtle. This requires Python 3 with Qt:
pip install PyQt5 # recommended (use PySide6 as an alternative) # or, if you prefer the classic turtle module: sudo apt install python3-tk # Debian/Ubuntu
When Python/Qt isn't available, Quantix silently renders GUI and
turtle output as HTML/SVG in your browser instead. You can force the
web renderer with the environment variable
QX_DISABLE_NATIVE=1.
Your first program
Create a file called hello.qtx:
Program.Main {
Variables.Name = Terminal.Ask("What's your name? ")
Terminal.Echo("")
Terminal.Echo("Hello, " + Variables.Name + "! Welcome to Quantix.")
Terminal.Style("green")
Terminal.Echo("You just wrote your first line of code.")
Terminal.Style("reset")
}
Run it:
node bin/quantix hello.qtx
Program.Main { ... } block. Terminal.Echo
prints, Terminal.Ask reads a line from the user,
Variables.Name = ... stores a value, and
+ joins text together.
A slightly bigger example
Program.Main {
# Roll a dice and make a decision
Variables.Dice = Math.Random(1, 6)
Terminal.Echo("You rolled a " + Variables.Dice)
Program.If(Math.Compare(Variables.Dice, ">=", 4)) {
Terminal.Echo("Nice roll! You win.")
}
Program.Else {
Terminal.Echo("Better luck next time.")
}
# Loop with a Kachua square, five times
Variables.I = 1
Program.Loop(4) {
Kachua.Forward(80)
Kachua.Right(90)
}
Kachua.Show()
}
Language fundamentals
Comments
Anything after # is ignored until the end of the line.
Program.Main {
# This line does nothing at runtime
Terminal.Echo("Hi") # inline comments work too
}
Blocks
Quantix is block-structured. Program.Main, conditionals,
loops and Kheers all open with { and close with
}. Blocks can be nested at any depth.
Case insensitivity
Commands, keywords and variable lookups are all case-insensitive:
Program.Main {
terminal.echo("lowercase works")
TERMINAL.ECHO("UPPERCASE works too")
Variables.X = 5
Terminal.Echo(variables.x) # identical to Variables.X
}
Kheers β your own procedures
A Kheer is a reusable procedure. Define one with
Program.Kheer(Name) { ... } and run it with
Program.ExecuteKheer(Name). Button handlers in
GUI.Window also fire Kheers.
Program.Main {
Program.Kheer(Greet) {
Terminal.Echo("Greetings from my custom Kheer!")
}
Program.ExecuteKheer(Greet)
Program.ExecuteKheer(Greet)
}
Good to know
- Booleans are written
TrueandFalse. - Built-in variables (
Variables.X) hold numbers, text, booleans and lists. - Everything is synchronous β programs execute top to bottom like a recipe.
- Use
Math.Eval(...)to compute arithmetic inside expressions.
How the interpreter works
Quantix is a small, dependency-free interpreter written in modern JavaScript. Understanding its pipeline helps you contribute and debug.
1. Lexer & parser
Source text is scanned into tokens, then parsed into a tree of blocks (Main, If/Else, Loop, ForeverLoop, Kheer) and statement lines (commands and assignments).
2. Evaluator
src/runtime.js walks each block, evaluates
expressions and dispatches commands to the matching
handler (src/handlers/).
3. Builtins
Handlers delegate to small modules in
src/builtins/ β terminal I/O, time, GUI and Kachua β
keeping each concern isolated.
4. Native bridge
GUI and Kachua prefer the native Python backend
(src/native/) for real desktop windows, and fall back
to HTML/SVG rendering for the web and headless use.
Project layout
bin/quantix # executable entry point src/main.js # CLI entry (shell or file mode) src/shell.js # interactive REPL src/runtime.js # evaluator, expression engine, block execution src/parser.js # block parser src/error_handler.js # QuantixError family src/handlers/ # per-category command handlers src/builtins/ # terminal, time, gui, turtle_graphics, stringify src/native/ # Python/Qt bridge (real desktop windows) cloudflare/ # web playground worker (runs Quantix in the browser) tests/ # Node test suite (Node & Bun)
The Cloudflare copy in cloudflare/src/interp/ is a
browser-safe build that replaces desktop sinks (files, processes) with
WebSocket and in-tab output β the desktop interpreter in
src/ stays the canonical one.
Values, types & variables
Quantix values are plain: numbers, text,
booleans (True/False) and
lists. Everything is visible to the same case-insensitive
variable store.
Program.Main {
Variables.Name = "Abhinu" # text
Variables.Age = 25 # number
Variables.Ok = True # boolean
Variables.Scores = [10, 20, 30] # list
Terminal.Echo("Type of Name is " + Data.TypeOf(Variables.Name))
Terminal.Echo("Type of Age is " + Data.TypeOf(Variables.Age))
}
Check the Data reference for comparison and conversion commands, and Lists for working with collections.
Reference β Terminal
| Command | Description |
|---|---|
Terminal.Echo(value) | Print a value (any type) to the terminal. |
Terminal.Ask(prompt) | Print a prompt and return one line of user input. |
Terminal.Style(color) | Set text colour. One of reset, red, green, yellow, blue, magenta, cyan, bold. |
Terminal.Clear() | Clear the terminal screen. |
Note: Terminal.Style and Terminal.Clear are
handled by the shell/CLI; the core evaluator dispatches
Echo and Ask through the terminal builtin.
Reference β Lists
| Command | Description |
|---|---|
Lists.Name = [a, b, c] | Create and initialise a list in one step. |
Lists.Create(Name) | Create an empty list. |
Lists.Set(Name, a, b) | Create a list and add several initial items. |
Lists.Get(Name, index) | Get the item at index. Negative indexes count from the end (-1 = last). |
Lists.Push(Name, value) | Append a value (alias: Lists.Add). |
Lists.Pop(Name) | Remove and return the last item. |
Lists.Length(Name) | Return the number of items. |
Lists.Contains(Name, value) | Return True if the list contains the value. |
Lists.Clear(Name) | Remove all items. |
Lists.Delete(Name) | Drop the list entirely. |
Reference β Math
| Command | Description |
|---|---|
Math.Eval(expr) | Evaluate an arithmetic expression with full precedence: Math.Eval(2 + 3 * 4) β 14. |
Math.Compare(a, op, b) | Compare numbers with >, <, >=, <=, ==, !=. |
Math.Random(min, max) | Return a random (integer) number between min and max inclusive. |
Math.SymPy(expr) | Evaluate a symbolic-style expression supporting sqrt(...), powers and more. |
Math.NumPy(expr) | Evaluate with implicit multiplication, e.g. Math.NumPy(2(3 + 4)) β 14. |
Inside expressions you can also use sqrt(x), the power
operator ^, parentheses and the usual + - * /.
Reference β Data
| Command | Description |
|---|---|
Data.Compare(a, b) | Strict comparison β 123 vs "123" is False. |
Data.LooseCompare(a, b) | Loose comparison β 123 vs "123" is True. |
Data.ToInt(value) | Convert to an integer ("42.9" β 42). |
Data.ToFloat(value) | Convert to a floating-point number. |
Data.ToString(value) | Convert to text. |
Data.TypeOf(value) | Return the value's type name. |
Reference β Time
| Command | Description |
|---|---|
Time.Current(format) | Return the current date/time formatted with tokens, e.g. "YYYY-MM-DD hh:mm:ss tt". |
Time.Wait(seconds) | Pause execution for the given number of seconds (accepts fractions). |
Format tokens
YYYY YY MM M
DD D HH (24h) hh
(12h) mm m ss s
tt (AM/PM).
Reference β Program & Kheers
| Command / block | Description |
|---|---|
Program.Main { ... } | The entry-point block of every file. |
Program.If(cond) { ... } | Conditional block (use Math.Compare inside). |
Program.Else { ... } | Runs when the preceding If was false. May chain another If. |
Program.Loop(n) { ... } | Repeat the block n times. |
Program.ForeverLoop { ... } | Repeat forever until Program.BreakLoop. |
Program.BreakLoop | Exit the innermost loop. |
Program.Continue | Skip to the next iteration. |
Program.Not(value) | Logical NOT (inverts a truthiness or boolean). |
Program.Kheer(Name) { ... } | Define a reusable procedure. |
Program.ExecuteKheer(Name) | Run a previously defined Kheer. |
Reference β GUI
GUI commands open real desktop windows when the native backend is available; otherwise they render as browser pages. Every command is case-insensitive.
| Command | Description |
|---|---|
GUI.MessageBox(title, msg) | Info message box. |
GUI.NewDialogBox(title, msg) | Dialog box. |
GUI.InputBox(prompt, title?) | Prompt for a single line of text. |
GUI.ChoiceBox(title, msg, a, b, ...) | Pick one option from a list. |
GUI.Window(title?, width?, height?) | Create a window to fill with widgets. |
GUI.Label(text) | Add a label to the current window. |
GUI.Button(label, kheer) | Add a button that runs a Kheer on click. |
GUI.Image(pathOrUrl) | Add an image (local file or URL). |
GUI.Spacing(px?) | Add vertical space. |
GUI.Separator | Add a divider line. |
GUI.SetTheme("Dark" | "Light") | Switch window theme. |
GUI.TextField(placeholder?, label?) | Add a text input, returns its field id. |
GUI.GetTextField(id) | Read the current text of a field. |
GUI.ShowWindow | Display the window and wait until it closes (buttons fire Kheers). |
GUI.ColorPicker(label?) | Pick a colour, returns a hex value. |
GUI.ColorPalette(...colors?) | Pick one of the given colour names. |
GUI.ColorMap | Pick from a built-in colour map. |
GUI.DatePicker(label?) | Pick a date, returns YYYY-MM-DD. |
GUI.InfoDialog(title, msg) | Info dialog, returns "OK". |
GUI.WarningDialog(title, msg) | Warning dialog. |
GUI.ErrorDialog(title, msg) | Error dialog. |
GUI.ConfirmDialog(title, msg) | Yes/No, returns "Yes" or "No". |
GUI.OkCancelDialog(title, msg) | OK/Cancel. |
GUI.InputDialog(title, msg, default?) | Prompt with a default value. |
GUI.MultiChoiceDialog(title, msg, a, b, ...) | Select any subset of choices. |
GUI.NumberDialog(title, msg, default?, min?, max?) | Number spinner. |
GUI.FileOpenDialog(title?, filter?) | Native "open file" picker. |
GUI.FileSaveDialog(title?, filter?) | Native "save file" picker. |
GUI.FolderDialog(title?) | Native folder picker. |
Window example
Program.Main {
GUI.Window("My App", 420, 260)
GUI.Label("What is your name?")
Variables.Id = GUI.TextField("Type here...", "")
GUI.Button("Say hello", Greet)
GUI.ShowWindow()
Kheer: Greet
Program.Kheer(Greet) {
Variables.Name = GUI.GetTextField(Variables.Id)
GUI.MessageBox("Hi", "Hello, " + Variables.Name + "!")
}
# Note: Kheers used by buttons may be defined anywhere in the block.
}
Reference β Kachua (turtle graphics)
Kachua β kachuΔ means turtle β is Quantix's Logo-style graphics turtle. On the desktop it draws into a real Qt window; on the web it renders an SVG.
| Command | Description |
|---|---|
Kachua.Forward(distance) | Move forward, drawing if the pen is down. |
Kachua.Backward(distance) | Move backward. |
Kachua.Right(angle) | Turn clockwise (degrees). |
Kachua.Left(angle) | Turn counter-clockwise. |
Kachua.PenUp | Stop drawing while moving. |
Kachua.PenDown | Resume drawing. |
Kachua.SetColor(color) | Set pen colour (name or hex). |
Kachua.SetPenWidth(width) | Set pen thickness. |
Kachua.SetSpeed(speed) | Set drawing speed. |
Kachua.GoTo(x, y) | Move to an absolute coordinate. |
Kachua.Home | Return to centre, facing east. |
Kachua.Clear | Erase the drawing. |
Kachua.Reset | Clear and reset turtle state. |
Kachua.Show / Kachua.Hide | Show/hide the turtle cursor. |
Kachua.Stamp | Stamp the turtle shape, returns a stamp id. |
Kachua.FillStart / Kachua.FillEnd | Outline an area to fill with the current colour. |
Kachua.Circle(radius) | Draw a circle of the given radius. |
Kachua.Heading | Return the current heading (degrees). |
Kachua.SetHeading(angle) | Set heading directly. |
Kachua.ShowTurtle | Show the turtle cursor (same as Show). |
Debug harness
The repo ships a ready-made test drawing in
examples/kachua_test.qtx that draws a square β run it
with node bin/quantix examples/kachua_test.qtx.
Reference β Interactive shell commands
Type these inside node bin/quantix with no file:
| Command | Description |
|---|---|
exit | Quit the shell. |
help | Show the shell quick reference. |
history | Show command history. |
vars | Show all defined variables. |
clear / cls | Clear the screen. |
load <file.qtx> | Run a full Quantix program file. |
warranty | Show the warranty disclaimer. |
license | Show the GPL v3 license. |
Error handling
Quantix wraps runtime failures in a typed error family so problems are always identified clearly:
| Error | Raised when |
|---|---|
SyntaxErrorQuantix | The source text can't be parsed (missing }, malformed expression, β¦). |
RuntimeErrorQuantix | A command fails β wrong arguments, missing window, unknown command, β¦. |
VariableErrorQuantix | A variable that hasn't been defined is read. |
MathErrorQuantix | A math expression is malformed or uses an invalid operator/number. |
In the interactive shell, the offending line is printed with a marker (β β βΊ) pointing at the problem, and the interpreter safely continues to the next command.
Native desktop GUI & turtle
Quantix's original Python edition used real windows. The JavaScript port restores that on desktop through a small native bridge:
-
Python backend (
src/native/quantix_native.py) picks PyQt5, then PySide6, then falls back to tkinter. Kachua uses a real Qt graphics view (or the stdlibturtle) and opens an actual window. -
JS client (
src/native/bridge.js) talks to it over a tiny file protocol, so the interpreter stays fully synchronous. - When Python/Qt or a display is unavailable, GUI and Kachua render as HTML dialogs / SVG drawings instead β the same code path the web playground uses.
# Use native windows by default (recommended for a real desktop): node bin/quantix examples/kachua_test.qtx # Force the web/HTML/SVG renderer: QX_DISABLE_NATIVE=1 node bin/quantix examples/kachua_test.qtx
The web playground
The Playground is powered by a Cloudflare Worker that embeds Quantix's interpreter and runs your code in your browser via WebSocket. It brings:
- A syntax-highlighted editor with example starter scripts.
- A live output terminal, so
Terminal.EchoandTerminal.Askfeel just like the desktop. - Kachua drawings rendered directly in the page as SVG.
- Automatic saving of your code as you type.
Contributing
Quantix is free software made with passion, and contributions are warmly welcome β code, docs, issues, examples, or just a GitHub star.
Where everything lives
- Handlers for new commands:
src/handlers/*.js(register new names in the dispatch map). - Behaviour behind commands:
src/builtins/*.js. - Native GUI/turtle:
src/native/quantix_native.py(PyQt5) andsrc/native/bridge.js. - Web playground:
cloudflare/(worker + interp). - Site/docs:
website/.
Workflow
- Fork
Sanskriti-Studios/Quantixand clone your fork. - Create a branch, make your change, and keep it dependency-free.
- Add or update tests in
tests/. - Run the suite and a syntax pass:
npm test # Node test suite make check # syntax-check all sources
- Push and open a Pull Request. Every check must pass before merge.
License
Quantix is distributed under the terms of the
GNU General Public License v3.
You are free to use, study, share and modify it, provided derivative
works stay under the same license. The full text ships in the
repository as LICENSE and is printed by the shell with
the license command.