Zx is a simple programming language that is designed to be easy to use and understand.
Zx is a weakly-typed, interpreted language that is designed to be easy to use and understand. Zx is built in Go as a learning project and is not intended to be used in production.
- Weakly-typed
- Interpreted
- Zx Blocks
To install Zx, you need to have Go installed on your system.
go install github.com/bndrmrtn/zxl@latest
To run a Zx program, you can use the zxl
command.
zxl run <file>
Flags can be used to cache or debug the program.
zxl run <file> --cache --debug
println("Hello, World!");
let x = 10;
println(x);
fn add(a, b) {
return a + b;
}
let result = add(10, 20);
println(result);
define MyBlock {
let x = 10;
fn construct(value) {
this.x = value;
}
}
let block = MyBlock(20);
println(block.x);
File main.zx
:
namespace main;
import("other.zx");
other.printHello();
File other.zx
:
namespace other;
fn printHello() {
println("Hello from other.zx!");
}
for i in range(10) {
println(i);
}
for i in range([10, 20]) {
println(i);
}
for i in range([10, 20, 2]) {
println(i);
}
for letter in "Hello" {
println(letter);
}
for i in 7 {
println(i);
}
for i in [5, 6, 7] {
println(i);
}
let i = 0;
while i < 10 {
println(i);
i = i + 1;
}
let myArr = array {
name: "John",
"age": 30,
city: "New York"
};
for key in myArr.keys {
println(string(key) + ": " + string(myObj[key]));
}
Support my work by giving this project a star.