Vix REPL
The Vix REPL is the interactive shell built into the vix binary.
Running vix without a command starts the REPL by default:
vixYou can also start it explicitly:
vix replThe REPL gives you a fast scratchpad for experimenting with expressions, variables, JSON values, filesystem helpers, environment values, and Vix CLI commands.
What the REPL is for
Use the REPL when you want to:
- test small expressions
- evaluate math quickly
- create and inspect variables
- validate JSON data
- inspect the current environment
- call simple Vix runtime helpers
- run Vix commands without leaving the shell
- prototype logic before moving it into a real C++ file
It is inspired by interactive shells from tools like Python, Node.js, and Deno, but adapted to the Vix.cpp workflow.
Start the REPL
vixExample startup:
Vix.cpp v1.x (CLI) — Modern C++ backend runtime
[GCC 13.3.0] on linux
Exit: Ctrl+C / Ctrl+D | Clear: Ctrl+L | Type help for help
vix>You can also use:
vix replTo pass arguments into the REPL session:
vix repl -- --port 8080 --mode devInside the REPL, those arguments are available with:
Vix.args()Basic expressions
You can type expressions directly:
1 + 2
10 * (3 + 4)
100 / 5The REPL evaluates the expression and prints the result.
Variables
Assign a value:
x = 42Read it back:
xUse it in another expression:
x + 1
x * 10String values are supported:
name = "Gaspard"
nameJSON values
The REPL supports strict JSON values.
Objects
user = {"name":"Gaspard","age":10}
userArrays
nums = [1,2,3,4]
numsNested JSON
profile = {
"name": "Gaspard",
"meta": {"country": "UG", "verified": true},
"tags": ["cpp", "vix", "repl"]
}
profileJSON must be valid.
Wrong:
{ "name", "Gaspard" }Correct:
{ "name": "Gaspard" }Printing output
Use print() to print without forcing a new line:
print("Hello")Use println() for line-oriented output:
println("Hello world")You can mix strings and expressions:
x = 3
println("x =", x)
println("x+1 =", x+1)Built-in helpers
The REPL exposes simple helpers directly and through the built-in Vix object.
Current working directory
cwd()or:
Vix.cwd()Change directory
Vix.cd("..")Process id
pid()or:
Vix.pid()Environment variables
Vix.env("HOME")
Vix.env("PATH")REPL arguments
Vix.args()Filesystem helpers
Create a directory:
Vix.mkdir("tmp")Create nested directories:
Vix.mkdir("tmp/logs", true)Run Vix commands from the REPL
You can run CLI commands without leaving the REPL:
Vix.run("version")
Vix.run("help")
Vix.run("check", "--help")This is useful when you want to inspect a command while staying inside an interactive session.
Clear the screen
Use:
clearor press Ctrl + L.
Exit the REPL
Use:
exitYou can also exit with Ctrl + D or Ctrl + C.
Common workflow
Start the REPL:
vixTry simple values:
x = 10
x * 2Inspect the environment:
Vix.cwd()
Vix.env("HOME")Check JSON:
user = {"name":"Ada","role":"developer"}
userRun a Vix command:
Vix.run("version")Exit:
exitCommon mistakes
Invalid JSON syntax
JSON objects require key: value pairs.
Wrong:
user = {"name","Gaspard"}Correct:
user = {"name":"Gaspard"}Forgetting quotes around strings
Wrong:
name = GaspardCorrect:
name = "Gaspard"Passing REPL arguments without --
Wrong:
vix repl --port 8080Correct:
vix repl -- --port 8080Everything after -- is passed to the REPL session and becomes available through Vix.args().
Best practices
- Use the REPL as a scratchpad.
- Use it to validate small ideas before creating a full C++ file.
- Use it to inspect environment variables when debugging CLI behavior.
- Use it to test JSON values before using them in configuration files or APIs.
- Use
Vix.run()to quickly inspect CLI command help from inside the session.
Roadmap
Planned improvements include:
- [ ] Property access for JSON objects
- [ ] Function definitions
- [ ] History persistence
- [ ] Autocomplete for variables
- [ ] Structured error hints
- [ ] Module imports
Next step
Continue with project creation.