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
/private
members andconstructor
s.
- Variables (
- Rich Data Types: Includes
Number
,String
,Boolean
,Nil
,Object
, andArray
. - Control Flow:
if/else if/else
,while
loops,break
,continue
. - Error Handling:
try/catch
blocks. - Module System: Simple
import
andexports
for code organization.
Runtime (Xel):
- Script Execution: Run
.xel
script 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 | sh
This 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 | sh
To remove Xel from your system:
curl -fsSL https://raw.githubusercontent.com/dev-kas/xel/master/scripts/uninstall.sh | sh
To 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.exe
on Windows). - Make it executable (on Unix-like systems):
chmod +x xel
. - Move it to a directory in your PATH (e.g.,
/usr/local/bin
on 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 --help
Create 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:
xel
Welcome 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" 42
Expected 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 test
Contributions 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
master
branch 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.