Xel is a runtime environment for VirtLang, a dynamic, modern scripting language designed for simplicity, power, and extensibility. Xel provides the tools to write, execute, and manage VirtLang code, complete with a REPL, a standard library, and a module system.
Language (VirtLang via Xel):
- Dynamic Typing: Flexible type system.
- Modern Syntax: Familiar C-like syntax with support for:
- Variables (
let) and Constants (const). - Functions (named, anonymous, closures).
- Classes with
public/privatemembers andconstructors.
- Variables (
- Rich Data Types: Includes
Number,String,Boolean,Nil,Object, andArray. - Control Flow:
if/else if/else,whileloops,break,continue. - Error Handling:
try/catchblocks. - Module System: Simple
importandexportsfor code organization.
Runtime (Xel):
- Script Execution: Run
.xelscript files directly from the command line. - Interactive REPL: Experiment with VirtLang code in real-time.
- Standard Library: Built-in modules for math (
xel:math), strings (xel:strings), and arrays (xel:array). - CLI Tools: Intuitive command-line interface for running scripts and managing projects.
- Informative Error Reporting: Errors include line and column numbers for easier debugging.
- Environment Variables: Access script path (
__filename__,__dirname__) and command-line arguments (proc.args). - Automatic Version Checking: Get notified of new Xel releases.
- Cross-Platform: Available for macOS, Linux, and Windows.
- Lightweight: Minimal dependencies and fast startup time.
You can install Xel with a single command:
curl -fsSL https://raw.githubusercontent.com/dev-kas/xel/master/scripts/install.sh | shThis will automatically detect your operating system and architecture, download the appropriate binary, and install it to your system.
To update to the latest version:
curl -fsSL https://raw.githubusercontent.com/dev-kas/xel/master/scripts/update.sh | shTo remove Xel from your system:
curl -fsSL https://raw.githubusercontent.com/dev-kas/xel/master/scripts/uninstall.sh | shTo uninstall without confirmation (useful for automated scripts):
curl -fsSL https://raw.githubusercontent.com/dev-kas/xel/master/scripts/uninstall.sh | sh -s -- -y- Download the appropriate binary for your platform from the releases page.
- Rename it to
xel(orxel.exeon Windows). - Make it executable (on Unix-like systems):
chmod +x xel. - Move it to a directory in your PATH (e.g.,
/usr/local/binon Linux/macOS).
# Clone the repository
git clone https://github.com/dev-kas/xel.git
cd xel
# Build for your platform
make build
# Or build for a specific platform
make build-mac # macOS (arm64)
make build-linux # Linux (amd64)
make build-windows # Windows (amd64)The compiled binaries will be available in the bin directory.
# Check version
xel --version
# Show help
xel --helpCreate a file with a .xel extension (e.g., myscript.xel).
# Basic usage
xel run myscript.xel
# With command-line arguments
xel run myscript.xel arg1 "another argument"Arguments are accessible within the script via the proc.args array.
Run xel without any arguments to start the REPL:
xelWelcome to Xel vX.Y.Z REPL (VirtLang vA.B.C)!
Type '!exit' to exit the REPL.
> let message = "Hello from REPL!"
< "Hello from REPL!"
> print(message)
Hello from REPL!
< nil
> 10 + 20
< 30
Create a file named example.xel:
// example.xel
// Import the strings module from the standard library
const strings = import("xel:strings")
// Define a function
fn greet(name) {
return "Hello, " + name + "!"
}
let personName = "Xel User"
let greeting = greet(personName)
print(strings.upper(greeting))
if (len(proc.args) > 0) {
print("You passed these arguments:")
array.forEach(proc.args, fn(arg, index) {
print(strings.format("Arg %v: %v", index + 1, arg))
})
} else {
print("Try running with arguments: xel run example.xel test1 test2")
}
Run it with:
xel run example.xel "first arg" 42Expected Output:
HELLO, XEL USER!
You passed these arguments:
Arg 1: first arg
Arg 2: 42
For detailed documentation on the Xel runtime and the VirtLang language features, syntax, and standard library, please refer to: DOCS.md
Xel comes with a useful set of built-in native modules:
xel:math: For mathematical operations likesqrt,random,sin,cos,PI,E, aggregation functions (sum,mean,median), and more.xel:strings: For string manipulation liketrim,split,upper,lower,includes,format,slice, and more.xel:array: For array operations likemap,filter,reduce,push,pop,sort,slice, and more.
See DOCS.md for full details on available functions.
Ensure you have Go installed. Then, from the project root:
make testContributions are welcome and highly appreciated! Whether it's bug fixes, feature enhancements, documentation improvements, or new standard library modules, please feel free to submit a Pull Request.
Please see our CONTRIBUTING.md for detailed guidelines on how to contribute.
Xel uses GitHub Actions for continuous integration and automated releases:
- Every push to the
masterbranch and pull requests are automatically built and tested. - To create a new release:
- Create and push a new tag with the version number (e.g.,
git tag v1.0.0 && git push origin v1.0.0). - GitHub Actions will automatically build the binaries for all supported platforms.
- A new GitHub Release will be drafted with the binaries attached.
- Once the release is published, the installation scripts will automatically use the latest release.
- Create and push a new tag with the version number (e.g.,
Xel builds upon the VirtLang-Go v2 engine. Special thanks to @dev-kas for creating and maintaining the VirtLang project, which serves as the core foundation for this runtime environment.
This project is licensed under the MIT License - see the LICENSE file for details.