Vix Reply
Interactive REPL engine for Vix.
Vix Reply powers the vix and vix repl interactive experience. It provides a fast shell for testing expressions, variables, JSON values, runtime helpers, and real C++ snippets powered by the Vix run pipeline.
Start the REPL
Running vix without a command starts the REPL by default:
vixYou can also start it explicitly:
vix replTo pass arguments into the REPL session, use --:
vix repl -- --port 8080 --mode devInside the REPL, those arguments are available with:
Vix.args()Example startup
Vix Reply v2.5.6 REPL
gcc 13.3 linux
exit: Ctrl+D | clear: Ctrl+L | help
>>>2
3
4
5
What the REPL is for
Use Vix Reply when you want to:
- test small expressions
- evaluate math quickly
- create and inspect variables
- validate JSON values
- inspect environment values
- call simple Vix runtime helpers
- run real C++ snippets from an interactive session
- prototype small ideas before moving them into a C++ file
Vix Reply is inspired by interactive shells from tools like Python, Node.js, and Deno, but adapted to the Vix.cpp workflow.
Basic commands
help
version
pwd
cd <dir>
clear
history
history clear
exit2
3
4
5
6
7
8
You can also clear the screen with:
Ctrl+LTo exit, use:
exitor:
Ctrl+DExpressions
You can type expressions directly:
>>> 1 + 2
3
>>> 10 * (3 + 4)
70
>>> 100 / 5
202
3
4
5
6
7
8
You can also use calc explicitly:
>>> calc 10 * (2 + 3)
502
Variables
Assign a value:
>>> x = 42
422
Read it back:
>>> x
422
Use it in another expression:
>>> x + 1
43
>>> x * 10
4202
3
4
5
String values are supported:
>>> name = "Gaspard"
name = "Gaspard"
>>> name
Gaspard2
3
4
5
Other simple values are supported too:
>>> age = 25
age = 25
>>> price = 19.99
price = 19.99
>>> active = true
active = true2
3
4
5
6
7
8
JSON values
Vix Reply supports strict JSON values.
Objects
>>> user = {"name":"Gaspard","age":25}
user = {"age":25,"name":"Gaspard"}
>>> user
{"age":25,"name":"Gaspard"}2
3
4
5
Arrays
>>> nums = [10,20,30]
nums = [10,20,30]
>>> nums
[10,20,30]2
3
4
5
Nested JSON
>>> profile = {"name":"Gaspard","meta":{"country":"UG","verified":true},"tags":["cpp","vix","reply"]}
profile = {"meta":{"country":"UG","verified":true},"name":"Gaspard","tags":["cpp","vix","reply"]}2
Access object properties:
>>> user.name
Gaspard
>>> user["name"]
Gaspard2
3
4
5
Access arrays:
>>> nums[0]
10
>>> profile.tags[1]
vix2
3
4
5
JSON must be valid.
Wrong:
{"name","Gaspard"}Correct:
{ "name": "Gaspard" }Printing output
Use print():
>>> print("Hello")
Hello2
Use println():
>>> println("Hello world")
Hello world2
You can mix strings and values:
>>> x = 3
x = 3
>>> println("x =", x)
x = 3
>>> println("x + 1 =", x + 1)
x + 1 = 42
3
4
5
6
7
8
Supported examples:
print("hello")
println("hello", "world")
println(42)
println(-42)
println(3.14)
println(true)
println(null)2
3
4
5
6
7
Built-in helpers
Vix Reply exposes simple helpers directly and through the built-in Vix object.
Current working directory
>>> cwd()
/home/user/project2
or:
>>> Vix.cwd()
/home/user/project2
Change directory
>>> Vix.cd("..")Process id
>>> pid()
123452
or:
>>> Vix.pid()
123452
Environment variables
>>> Vix.env("HOME")
/home/user
>>> Vix.env("PATH")
/usr/local/bin:/usr/bin:/bin2
3
4
5
REPL arguments
>>> Vix.args()
["--port","8080","--mode","dev"]2
Create directories
>>> Vix.mkdir("tmp")Create nested directories:
>>> Vix.mkdir("tmp/logs", true)Exit with a code
>>> Vix.exit(0)Value helpers
Length
>>> name = "Gaspard"
name = "Gaspard"
>>> len(name)
72
3
4
5
>>> nums = [10,20,30]
nums = [10,20,30]
>>> len(nums)
32
3
4
5
>>> user = {"name":"Gaspard","age":25}
user = {"age":25,"name":"Gaspard"}
>>> len(user)
22
3
4
5
Convert values
>>> int("42")
42
>>> int(42.0)
42
>>> float("3.14")
3.140000
>>> float(10)
10.000000
>>> str(25)
252
3
4
5
6
7
8
9
10
11
12
13
14
Inspect types
>>> type(user)
object
>>> type(nums)
array
>>> type(user.name)
string
>>> type(nums[0])
int2
3
4
5
6
7
8
9
10
11
C++ snippet mode
Vix Reply can run real C++ snippets through the normal Vix run pipeline.
Enter C++ mode:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp>2
3
Example:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp> #include <vector>
... #include <vix/print.hpp>
... int main() {
... vix::print("Hello, world", 2, true, std::vector<int>{1,2,3});
... }
Hello, world 2 true [1, 2, 3]2
3
4
5
6
7
8
Run a Vix HTTP server from the REPL
You can also start a small Vix HTTP server from C++ snippet mode:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp> #include <vix.hpp>
... using namespace vix;
...
... int main() {
... App app;
...
... app.get("/", [](Request&, Response& res) {
... res.send("Hello, world");
... });
...
... app.run(8080);
... }2
3
4
5
6
7
8
9
10
11
12
13
14
Then test it from another terminal:
curl http://localhost:8080Expected output:
Hello, worldC++ mode commands
:cpp Enter C++ snippet mode
:run Run the current C++ snippet
:cancel Cancel C++ snippet mode2
3
Important note about C++ mode
Vix Reply is not a full C++ interpreter.
C++ snippet mode writes the snippet to a temporary .cpp file and runs it through vix run. This means the code is validated by the real C++ compiler and uses the normal Vix build, diagnostics, and runtime behavior.
The snippet must be valid C++ code.
For example, callbacks must use valid C++ lambda syntax:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
});2
3
Common mistakes
Invalid JSON syntax
JSON objects require key: value pairs.
Wrong:
{"name","Gaspard"}Correct:
{ "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().
Forgetting to close a C++ function call
Wrong:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
}2
3
Correct:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
});2
3
Common workflow
Start the REPL:
vixTry simple values:
>>> x = 10
10
>>> x * 2
202
3
4
5
Inspect the environment:
>>> Vix.cwd()
/home/user/project
>>> Vix.env("HOME")
/home/user2
3
4
5
Check JSON:
>>> user = {"name":"Ada","role":"developer"}
user = {"name":"Ada","role":"developer"}
>>> user.role
developer2
3
4
5
Run C++:
>>> :cpp
cpp> #include <vix/print.hpp>
... int main() {
... vix::print("Hello from C++");
... }
Hello from C++2
3
4
5
6
Exit:
>>> exitBest practices
- Use the REPL as a scratchpad.
- Use it to validate small expressions.
- Use it to inspect environment values.
- Use it to test JSON values before using them in config files or APIs.
- Use C++ snippet mode to quickly test real C++ code through the Vix pipeline.
- Move larger code into a real
.cppfile or project once the idea is validated.
Module layout
include/vix/reply/
api/
console/
core/
src/
api/
console/
core/2
3
4
5
6
7
8
9
Public entry point
The main entry point is:
#include <vix/reply/core/ReplFlow.hpp>
int repl_flow_run(const std::vector<std::string>& replArgs);2
3
The Vix CLI uses this entry point to implement:
vix replNext step
Continue with project creation.