Skip to content
/ zxl Public

Zx Language – Interpreted scripting language for web development. Features built-in HTTP server and HTML template literals. 🚀

License

Notifications You must be signed in to change notification settings

bndrmrtn/zxl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zx (/ziː.ɛks/) Language

Zx is a simple programming language that is designed to be easy to use and understand.

About

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.

Features

  • Weakly-typed
  • Interpreted
  • Zx Blocks

Installation

To install Zx, you need to have Go installed on your system.

go install github.com/bndrmrtn/zxl@latest

Usage

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

Examples

Basic Hello World program:

println("Hello, World!");

Define a variable and print it:

let x = 10;
println(x);

Define a function and call it:

fn add(a, b) {
  return a + b;
}

let result = add(10, 20);
println(result);

Define a block and use it:

define MyBlock {
  let x = 10;

  fn construct(value) {
    this.x = value;
  }
}

let block = MyBlock(20);
println(block.x);

Using namespaces:

File main.zx:

namespace main;

import("other.zx");
other.printHello();

File other.zx:

namespace other;

fn printHello() {
  println("Hello from other.zx!");
}

Loops

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;
}

Arrays

let myArr = array {
  name: "John",
  "age": 30,
  city: "New York"
};

for key in myArr.keys {
    println(string(key) + ": " + string(myObj[key]));
}

Support

Support my work by giving this project a star.

About

Zx Language – Interpreted scripting language for web development. Features built-in HTTP server and HTML template literals. 🚀

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published