Starlight Programming Language

Starlight Documentation

Official documentation for the Starlight programming language.

Starlight-logo

Starlight Programming Language

Starlight is a lightweight, modern scripting language designed for server-side scripting, CLI tools, and automation.
It focuses on simplicity, readable syntax, and practical features for everyday programming. starlight-cli was officially released on December 14 2025.


Features


Installation

Install the Starlight CLI via npm:

npm install -g starlight-cli

Verify installation:

starlight --version

Running a Program

Create a file:

program.sl

Run it:

starlight program.sl

Example

let nums = range(0, 12, 2);

sldeploy nums;

if (len(nums) > 5) {
  sldeploy "Array has more than 5 elements";
}

Output:

[ 2, 4, 6, 8, 10 ]
Array has more than 5 elements

Documentation

Full documentation is organized in the docs/ folder:


Use Cases


Philosophy

Starlight is built to be:


License

MIT License © Dominex Macedon


Links


Developer / Maintainer Biography

Dominex Macedon Name: Dominex Macedon Date of Birth: March 21, 2006 (the same day as the first tweet) Mother: Daw Thet Thet Maw Father: U Kyaw Moe


Early Inspiration

From an early age, I was fascinated by technology and problem-solving. My journey started with a simple goal: to make my father's job easier. Observing his work, I realized that customers often had to meet him in person to submit items, which was time-consuming. I wanted to create a solution that would allow customers to communicate and submit requests without physically visiting him.

This led me to develop a local chat system using MySQL, PHP, HTML, and CSS. The project was small but significant. I immediately understood that if a group of people could contact a single person, I could build a one-to-one chat interface. I implemented it, and it worked, marking my first success in building functional communication systems.


Web Development and GitHub

After creating the local chat system, I expanded my skills into web development. Using GitHub, I hosted projects and began experimenting with website creation and deployment. These early experiences helped me understand version control, collaboration, and project management in real-world software development.


Android Development: Falcon S

Later, I ventured into Android development and built a messaging app called Falcon S. This project used Android Studio, Firebase Auth, Realtime DB, Firestore, and Storage. The journey was challenging:

Through persistence, I successfully built the app, gaining deep experience in mobile application architecture, authentication, and real-time data management.


Desktop and Video Call Applications

To expand communication tools, I developed a video call room similar to Zoom:

This project tested my ability to integrate cross-platform systems and manage real-time communication at scale.


Rendering Engine and React Native

Next, I attempted to create a rendering engine to render views directly from JSON. Though this project ultimately failed, it taught me valuable lessons about design systems, parsing, and dynamic UI rendering.

Afterwards, I moved to React Native and Expo, successfully rebuilding a messaging app with a CSS-like stylesheet design. This solidified my understanding of cross-platform mobile development and modern UI frameworks.


Starlight Programming Language

Finally, my experiences led me to develop the Starlight Programming Language. Starlight is based on the rendering engine concept I had explored earlier, combining ideas from my web, mobile, and desktop projects to create a language that is flexible, interactive, and user-friendly.

My work with Starlight continues to evolve, reflecting my passion for communication systems, rendering engines, and innovative programming tools.


Summary

Throughout my journey:

I am Dominex Macedon, a developer, innovator, and creator, dedicated to building tools that make communication seamless and intuitive.


Introduction to Starlight

Starlight is a high-level scripting language designed to be simple, expressive, and versatile. It combines the flexibility of dynamic typing with familiar programming structures.

Basic Principles

Declaring Variables

Use let to declare a variable:

let name = "Alice"
let age = 25
let isStudent = true

Variables can hold any type of value, and the type can change dynamically:

let data = 10
data = "Now I'm a string"

Data Types

Starlight has several core types:

Operators

Control Flow

if age >= 18 {
  let status = "Adult"
} else {
  let status = "Minor"
}
for let i = 0; i < 5; i++ {
  # do something
}

let numbers = [1, 2, 3]
for num in numbers {
  # iterate over array
}
let count = 0
while count < 5 {
  count += 1
}

Functions

Functions can be declared or assigned to variables:

let greet = (name) => "Hello " + name

let result = greet("Alice")  # "Hello Alice"

Named function declaration:

define sayHi(name) {
  "Hi " + name
}

Built-in Utilities


Starlight is designed to be readable, flexible, and powerful, while keeping syntax simple and natural.


getting started with starlight

starlight is a simple programming language designed to be easy to learn and fun to use.

running starlight

to run a file, use:


starlight filename.sl

to view a markdown file:

starlight filename.md

basic syntax

variables

let name = "alice"
let age = 16
let is_student = true

sldeploy name
sldeploy age
sldeploy is_student

data types

starlight supports:

operators

let a = 10
let b = 5

sldeploy a + b
sldeploy a - b
sldeploy a * b
sldeploy a / b
sldeploy a % b

let t = true
let f = false

control flow

# if statement
if a > b {
    sldeploy "a is greater"
} else {
    sldeploy "b is greater or equal"
}

# while loop
let i = 0
while i < 3 {
    sldeploy i
    i += 1
}

# for loop
for let j = 0; j < 3; j += 1 {
    sldeploy j
}

functions

func greet(name) {
    sldeploy "hello " + name
}

greet("bob")

# arrow functions
let square = (x) => x * x
sldeploy square(5)

async / await

func getData(url) async {
    let res = await fetch(url)
    let data = await res.json()
    return data
}

let info = await getData("https://jsonplaceholder.typicode.com/todos/1")
sldeploy info

sldeploy

use sldeploy to output values:

let message = "hello world"
sldeploy message

it can display numbers, strings, booleans, arrays, objects, and functions.


installation

this guide will help you get starlight up and running on your system.

requirements

installing via npm (recommended)

to install starlight globally so you can run it from anywhere:

npm install -g starlight-cli@latest

after installation, check the version:

starlight --version

you should see something like:

starlight cli v1.1.7
developed by macedon

running starlight

once installed, you can run a starlight file like this:

starlight myprogram.sl

or view a markdown file directly:

starlight guide.md

uninstalling

if you ever need to remove starlight:

npm uninstall -g starlight-cli

Syntax Overview

This is a quick reference for the core syntax and constructs of your language.


1. Variables

Declaration

let x = 10;
let name = "Alice";

Definition (global or constant-like)

define PI = 3.14159;
define greeting = "Hello!";

2. Data Types


3. Operators

Arithmetic

a + b
a - b
a * b
a / b
a % b

Assignment

x = 5;
x += 3;  // x = x + 3
x -= 2;
x *= 2;
x /= 4;
x %= 2;

Comparison

a == b
a != b
a < b
a <= b
a > b
a >= b

Logical

a && b   // AND
a || b   // OR
a ?? b   // Nullish coalescing
!a       // NOT

4. Control Flow

If / Else

if (x > 0) {
  sldeploy("Positive");
} else if (x < 0) {
  sldeploy("Negative");
} else {
  sldeploy("Zero");
}

While Loop

while (x < 5) {
  sldeploy(x);
  x += 1;
}

For Loop

for (let i = 0; i < 5; i += 1) {
  sldeploy(i);
}

For-In Loop

for (let key in obj) {
  sldeploy(key);
}

Do-Track (try-catch-like)

do {
  sldeploy(10 / 0);
} track {
  sldeploy(error); // error contains the exception
}

5. Functions

Regular Function

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

sldeploy(add(2, 3)); // 5

Async Function

async func fetchData(url) {
  let response = await get(url);
  return response;
}

Arrow Function

let square = x => x * x;
sldeploy(square(5)); // 25

6. Start Statement (switch-like)

start score {
  race 100 {
    sldeploy("Perfect!");
  }
  race 50 {
    sldeploy("Halfway there!");
  }
  race 0 {
    sldeploy("Try again!");
  }
}

7. Arrays & Objects

Arrays

let nums = [1, 2, 3];
sldeploy(nums[0]); // 1

Objects

let person = { name: "Alice", age: 20 };
sldeploy(person.name); // Alice

8. Importing Modules

import { func1, func2 } from "utils.sl";
import * as utils from "utils.sl";
import defaultFunc from "utils.sl";

9. Built-in Functions


10. Miscellaneous

obj.key
obj["key"]
myFunc(1, 2);
let obj = new MyClass(arg1, arg2);
x++;
--y;
obj.value++;
arr[0]--;

This document covers all major syntax elements in your language, with sldeploy as the primary output mechanism.


Variables

Variables are containers for storing data. They can hold numbers, strings, arrays, objects, or functions.


1. Declaring Variables

let – block-scoped variable

let x = 10;
let name = "Alice";
x = 20;
name = "Bob";

define – global or constant-like variable

define PI = 3.14159;
define greeting = "Hello!";

2. Variable Types

Variables can hold different types of values:

Type Example
Number let age = 25;
String let name = "Alice";
Boolean let isActive = true;
Null let empty = null;
Array let arr = [1, 2, 3];
Object let obj = { key: "value" };

3. Variable Scope

if (true) {
  let x = 5;
}
sldeploy(x); // Error: undefined variable
define y = 10;
if (true) {
  sldeploy(y); // 10
}
func test() {
  let localVar = 42;
  sldeploy(localVar); // 42
}
sldeploy(localVar); // Error: undefined variable

4. Dynamic Typing

Variables can change types after assignment:

let x = 10;
sldeploy(x); // 10

x = "hello";
sldeploy(x); // "hello"

5. Accessing Variables

let a = 5;
sldeploy(a); // 5
let person = { "name": "Alice", "age": 20 };
sldeploy(person.name); // "Alice"
let nums = [1, 2, 3];
sldeploy(nums[0]); // 1

6. Best Practices


This covers everything about variables: declaration, types, scope, and access.


starlight data types

starlight supports standard data types including numbers, strings, booleans, arrays, objects, functions, and null (none).


numbers

let a = 10
let b = 3.14
let c = -5

sldeploy a
sldeploy b
sldeploy c

strings

let str1 = "hello"
let str2 = 'world'
let str3 = str1 + " " + str2

sldeploy str1
sldeploy str3

booleans

let t = true
let f = false

sldeploy t
sldeploy f

null / none / undefined

let n = null
let u = undefined

sldeploy n
sldeploy u

arrays

let arr = [1, 2, 3]
let empty = []

sldeploy arr
sldeploy arr[0]
sldeploy len(arr)

objects

let obj = {name: "alice", age: 20}

sldeploy obj.name
sldeploy obj["age"]
sldeploy keys(obj)
sldeploy values(obj)

functions

func add(a, b) {
    return a + b
}

let result = add(5, 7)
sldeploy result

let arrow = (x, y) => x * y
sldeploy arrow(3, 4)

type checks

sldeploy type(10)
sldeploy type("hello")
sldeploy type([1,2,3])
sldeploy type({"a":1})
sldeploy type(add)
sldeploy type(null)

tips


starlight control flow

starlight provides standard control flow statements like if, else, while, for, for-in, break, continue, and custom start/race/do and track for advanced flow control.


if / else

let x = 10

if x > 5 {
    sldeploy "x is greater than 5"
} else {
    sldeploy "x is 5 or less"
}

while

let count = 0

while count < 3 {
    sldeploy count
    count += 1
}

for

for let i = 0; i < 3; i += 1 {
    sldeploy i
}

for-in

let arr = [10, 20, 30]

for val in arr {
    sldeploy val
}

let obj = {a: 1, b: 2}

for key in obj {
    sldeploy key
}

break / continue

let i = 0

while true {
    i += 1
    if i == 3 {
        break
    }
    if i == 1 {
        continue
    }
    sldeploy i
}

start / race

let choice = "b"

start choice {
    race "a" {
        sldeploy "you chose a"
    }
    race "b" {
        sldeploy "you chose b"
    }
    race "c" {
        sldeploy "you chose c"
    }
}

doTrack

do {
    let x = 10 / 0
} track {
    sldeploy "error caught"
}

tips


# functions in starlight

# defining a function
func greet(name) {
    sldeploy "hello " + name
}

# calling a function
greet("alice")

# function returning a value
func add(a, b) {
    return a + b
}

let sum = add(5, 7)
sldeploy sum

# arrow functions (inline)
let multiply = (x, y) => x * y
sldeploy multiply(3, 4)

# arrow function with block
let divide = (a, b) => {
    if b == 0 {
        return "cannot divide by zero"
    }
    return a / b
}

sldeploy divide(10, 2)
sldeploy divide(10, 0)

# functions can be assigned to variables
let fn = greet
fn("bob")

# functions can be passed as arguments
func applyFn(fn, value) {
    return fn(value)
}

let result = applyFn((x) => x * 2, 8)
sldeploy result

# async functions
func asyncFetch(url) async {
    let response = await fetch(url)
    let data = await response.json()
    return data
}

# calling async function
let data = await asyncFetch("https://jsonplaceholder.typicode.com/todos/1")
sldeploy data

✅ key points:


Arrays in SL

Arrays in SL are ordered collections of values. They can contain any type, including numbers, strings, booleans, objects, other arrays, and even functions.

1. Creating Arrays

let nums = [1, 2, 3, 4, 5];
let names = ["Alice", "Bob", "Charlie"];
let mixed = [1, "two", true, null];
let nested = [[1, 2], [3, 4]];

2. Accessing Elements

Array elements are accessed using zero-based indices:

sldeploy nums[0];    # 1
sldeploy names[1];   # "Bob"
sldeploy nested[1][0]; # 3

If the index is out of bounds, SL returns undefined:

sldeploy nums[10]; # undefined

3. Modifying Arrays

You can assign new values to existing indices:

nums[0] = 42;
names[2] = "Charlie Brown";

sldeploy nums;   # [42, 2, 3, 4, 5]
sldeploy names;  # ["Alice", "Bob", "Charlie Brown"]

Arrays can grow dynamically by assigning to new indices:

nums[5] = 6;
sldeploy nums; # [42, 2, 3, 4, 5, 6]

4. Array Operations

SL supports iteration and higher-order functions:

let nums = [1, 2, 3, 4];

# Map: apply a function to each element
let squared = await map(nums, (x) => x * x);
sldeploy squared; # [1, 4, 9, 16]

# Filter: select elements
let evens = await filter(nums, (x) => x % 2 == 0);
sldeploy evens; # [2, 4]

# Reduce: accumulate values
let sum = await reduce(nums, (a, b) => a + b, 0);
sldeploy sum; # 10

5. Iterating Over Arrays

Using for loops

for (let i = 0; i < nums.length; i++) {
  sldeploy nums[i];
}

Using for-in loops

for n in nums {
  sldeploy n;
}

6. Built-in Functions for Arrays

sldeploy len(nums); # 4

7. Combining Arrays

Arrays can be nested or concatenated manually:

let a = [1, 2];
let b = [3, 4];
let c = [a[0], a[1], b[0], b[1]];

sldeploy c; # [1, 2, 3, 4]

8. Summary


Objects in Your Language

Objects are collections of key-value pairs. They are similar to dictionaries or maps in other languages. Keys can be strings, numbers, or expressions, and values can be any type, including other objects or functions.

Creating Objects

Objects are created using let with curly braces {}:

let myObj = {
  "name": "Alice",
  "age": 25,
  "isStudent": true
}

Keys must be unique within an object. Values can be literals, arrays, functions, or even other objects.

Accessing Properties

Properties of an object can be accessed using dot notation or bracket notation:

let name = myObj.name
let age = myObj["age"]

You can also assign new values to existing properties:

myObj.age = 26
myObj["isStudent"] = false

New properties can be added dynamically:

myObj.grade = "A"

Nested Objects

Objects can contain other objects:

let person = {
  "name": "Bob",
  "address": {
    "city": "New York",
    "zip": "10001"
  }
}

let city = person.address.city

Iterating Over Objects

You can iterate over objects using a for-in loop. This iterates over the keys:

for key in person {
  let value = person[key]
}

You can also use built-in functions:

let keysList = keys(person)       # ["name", "address"]
let valuesList = values(person)   # ["Bob", { "city": "New York", "zip": "10001" }]

Object Methods

Objects can hold functions as values:

let calculator = {
  "add": (a, b) => a + b,
  "subtract": (a, b) => a - b
}

let sum = calculator.add(5, 3)       # 8
let difference = calculator["subtract"](10, 4)  # 6

Functions inside objects behave like normal functions but can also access the object if this is used.

Summary


Modules in Starlight

Modules in Starlight allow you to organize code into separate files and reuse functionality across programs. They help keep your code clean, maintainable, and modular.

Importing Modules

Use the import statement to include another module in your program. You can import specific exports, the default export, or the entire module as a namespace.

Default Import

import fs from "./fileUtils.sl"

let content = fs.readFile("data.txt")

Named Import

import { readFile, writeFile } from "./fileUtils.sl"

let content = readFile("data.txt")
writeFile("output.txt", content)

Namespace Import

import * as fs from "./fileUtils.sl"

let content = fs.readFile("data.txt")

Exporting from a Module

In Starlight, everything defined in a file can be exported and used in other modules.

Example: Exporting Named Functions

define greet(name) {
  "Hello " + name
}

define farewell(name) {
  "Goodbye " + name
}

You can then import these functions using a named import:

import { greet, farewell } from "./messages.sl"

let msg = greet("Alice")   # "Hello Alice"
let bye = farewell("Bob")  # "Goodbye Bob"

Default Export

To export the entire module as a default:

let defaultExport = {
  greet: greet,
  farewell: farewell
}

And import it like this:

import messages from "./messages.sl"

let msg = messages.greet("Alice")

Importing External Libraries

Starlight can import Node.js modules or packages installed via npm:

import fs from "fs"

let data = fs.readFileSync("data.txt", "utf-8")

If a module cannot be found, Starlight will throw a RuntimeError with a suggestion if a similar name exists.

Module Scope

Tips


Modules in Starlight make it easy to split large programs into manageable pieces while maintaining clean and reusable code.


async / await in Starlight

your language supports asynchronous programming using async functions and the await keyword. this allows you to write non-blocking code that reads like normal synchronous code.

declaring async functions

use the async func syntax to define an asynchronous function:

async func fetchdata(url) {
    let response = await fetch(url);
    let data = await response.json();
    return data;
}

using await

await can be used with any async operation:

async func main() {
    let user = await get('https://api.example.com/user/1');
    sldeploy user;
}

main();  // calling an async function

error handling with do…track

use do…track to catch errors from async operations:

async func loaddata() {
    do {
        let data = await fetch('https://api.example.com/data');
        sldeploy await data.json();
    } track {
        sldeploy 'an error occurred:', error;
    }
}

awaiting multiple async calls

you can run multiple async calls sequentially:

async func process() {
    let a = await fetch('https://api.example.com/a');
    let b = await fetch('https://api.example.com/b');
    sldeploy [await a.json(), await b.json()];
}

or process arrays asynchronously:

async func processusers(users) {
    let results = await map(users, async (u) => {
        let res = await fetch(`https://api.example.com/user/${u.id}`);
        return await res.json();
    });
    sldeploy results;
}

async arrow functions

async arrow functions work with await:

let fetchuser = async (id) => {
    let response = await fetch(`https://api.example.com/user/${id}`);
    return await response.json();
};

async func run() {
    let user = await fetchuser(1);
    sldeploy user;
}

run();

loops with async/await

you can use async functions inside loops:

async func loopfetch(users) {
    for let u in users {
        let data = await fetch(`https://api.example.com/user/${u}`);
        sldeploy await data.json();
    }
}

or using for…in over objects:

async func objloop(obj) {
    for let key in obj {
        let val = await obj[key];
        sldeploy key, val;
    }
}

sleep and delay

you can pause execution asynchronously:

async func countdown(n) {
    for let i = n; i > 0; i-- {
        sldeploy i;
        await sleep(1000);  // pause 1 second
    }
    sldeploy 'done!';
}

calling async functions

async func main() {
    let data = await fetchdata('https://api.example.com');
    sldeploy data;
}

main();

async with error handling in loops

you can combine loops, async, and do…track:

async func safefetch(users) {
    for let u in users {
        do {
            let res = await fetch(`https://api.example.com/user/${u}`);
            sldeploy await res.json();
        } track {
            sldeploy 'failed to fetch user', u, ':', error;
        }
    }
}

summary table

feature syntax example notes
async function async func name(params) { … } use await inside
await expression let x = await asynccall() only inside async
async arrow function let fn = async (params) => … can be single-expression or block
error handling do { … } track { … } error variable holds exception
async loops for let x in array { await … } handles async correctly
async utilities map, filter, reduce fully async-aware
sleep / delay await sleep(ms) pauses execution asynchronously

starlight cli guide

starlight comes with a command line interface (cli) to run code, open learning guides, and work interactively.

installation

  1. make sure you have node.js installed.
  2. clone or download starlight.
  3. open a terminal in the starlight folder.

usage

starlight <file.sl>        # run a starlight source file
starlight <file.md>        # view a markdown file directly in browser
starlight --version        # show cli version
starlight --help           # show help
starlight --learn          # open learning guide
starlight --writedirectly  # interactive editor mode

options

running files

to run a .sl file:

starlight myscript.sl

to view a markdown file directly:

starlight guide.md

interactive editor (--writedirectly)

  1. type code directly in the terminal.
  2. use :run to execute the code.
  3. syntax is highlighted as you type.
  4. after execution, you can choose to save the code.

example

let x = 5
let y = 10
sldeploy x + y   # outputs 15

saving code from interactive mode

  1. enter folder path when prompted.
  2. enter file name. .sl extension is added automatically if missing.
  3. your code is saved and can be run later using starlight <file.sl>.

error handling

cli workflow summary

command action
starlight <file.sl> run a starlight source file
starlight <file.md> view a markdown file directly in browser
starlight --version show cli version
starlight --help show this help guide
starlight --learn open learning guide in browser
starlight --writedirectly interactive editor with immediate evaluation and optional save

additional features


starlight-math

A lightweight math utility library for JavaScript and Starlight, providing constants, functions, and basic vector/matrix operations.

Installation

Install via npm:

npm install starlight-math@latest

Import

For both JavaScript and Starlight:

import math from "starlight-math";

Constants

console.log(math.pi);           // 3.141592653589793
console.log(math.e);            // 2.718281828459045
console.log(math.phi);          // 1.61803398875

Starlight:

sldeploy(math.pi);
sldeploy(math.e);
sldeploy(math.phi);

Basic Functions

console.log(math.abs(-5));      // 5
console.log(math.sqrt(16));     // 4
console.log(math.pow(2, 3));    // 8
console.log(math.round(4.6));   // 5
console.log(math.floor(4.9));   // 4
console.log(math.ceil(4.1));    // 5
console.log(math.max(1,2,3));   // 3
console.log(math.min(1,2,3));   // 1

Starlight:

sldeploy(math.abs(-5));
sldeploy(math.sqrt(16));
sldeploy(math.pow(2, 3));
sldeploy(math.round(4.6));
sldeploy(math.floor(4.9));
sldeploy(math.ceil(4.1));
sldeploy(math.max([1,2,3])); // pass array instead of arguments if needed
sldeploy(math.min([1,2,3]));

Trigonometric Functions

console.log(math.sin(Math.PI/2)); // 1
console.log(math.cos(0));         // 1
console.log(math.tan(Math.PI/4)); // 1
console.log(math.asin(1));        // 1.5707963267948966
console.log(math.acos(0));        // 1.5707963267948966
console.log(math.atan(1));        // 0.7853981633974483
console.log(math.atan2(1, 1));    // 0.7853981633974483

Starlight:

sldeploy(math.sin(math.pi / 2));
sldeploy(math.cos(0));
sldeploy(math.tan(math.pi / 4));
sldeploy(math.asin(1));
sldeploy(math.acos(0));
sldeploy(math.atan(1));
sldeploy(math.atan2(1,1));

Logarithms

console.log(math.log(10));   // natural log
console.log(math.log10(100));// base 10
console.log(math.log2(8));   // base 2

Starlight:

sldeploy(math.log(10));
sldeploy(math.log10(100));
sldeploy(math.log2(8));

Random Numbers

console.log(math.random());        // random between 0 and 1
console.log(math.random(5, 10));  // random between 5 and 10

Starlight:

sldeploy(math.random());
sldeploy(math.random(5, 10));

Factorials, Combinations, Permutations

console.log(math.factorial(5));   // 120
console.log(math.nCr(5, 2));      // 10
console.log(math.nPr(5, 2));      // 20

Starlight:

sldeploy(math.factorial(5));
sldeploy(math.nCr(5, 2));
sldeploy(math.nPr(5, 2));

Vector Operations

const v1 = [1,2,3];
const v2 = [4,5,6];

console.log(math.vectorAdd(v1, v2));   // [5,7,9]
console.log(math.vectorSub(v1, v2));   // [-3,-3,-3]
console.log(math.vectorDot(v1, v2));   // 32
console.log(math.vectorCross(v1, v2)); // [-3,6,-3]

Starlight:

sldeploy(math.vectorAdd([1,2,3], [4,5,6]));
sldeploy(math.vectorSub([1,2,3], [4,5,6]));
sldeploy(math.vectorDot([1,2,3], [4,5,6]));
sldeploy(math.vectorCross([1,2,3], [4,5,6]));

Matrix Operations

const A = [[1,2],[3,4]];
const B = [[5,6],[7,8]];

console.log(math.matrixAdd(A, B));       // [[6,8],[10,12]]
console.log(math.matrixSub(A, B));       // [[-4,-4],[-4,-4]]
console.log(math.matrixTranspose(A));    // [[1,3],[2,4]]

Starlight:

sldeploy(math.matrixAdd([[1,2],[3,4]], [[5,6],[7,8]]));
sldeploy(math.matrixSub([[1,2],[3,4]], [[5,6],[7,8]]));
sldeploy(math.matrixTranspose([[1,2],[3,4]]));

Notes:


starlight-fs

A simple file system utility for JavaScript and Starlight, providing convenient methods for reading, writing, copying, deleting files and directories, as well as path utilities.


Installation

Install via npm:

npm install starlight-fs@latest

Import

For both JavaScript and Starlight:

import fs from "starlight-fs";

File Operations

Read File

const content = fs.readFile("example.txt");
console.log(content);

Starlight:

sldeploy(fs.readFile("example.txt"));

Write File

fs.writeFile("example.txt", "Hello Starlight!");

Starlight:

fs.writeFile("example.txt", "Hello Starlight!");

Append File

fs.appendFile("example.txt", "\nAppended line");

Starlight:

fs.appendFile("example.txt", "\nAppended line");

Read / Write JSON

const data = fs.readJSON("data.json");
fs.writeJSON("data.json", { name: "Starlight", version: 1 });

Starlight:

sldeploy(fs.readJSON("data.json"));
fs.writeJSON("data.json", { name: "Starlight", version: 1 });

Delete File

fs.deleteFile("example.txt");

Starlight:

fs.deleteFile("example.txt");

Directory Operations

Check if File/Dir Exists

console.log(fs.exists("example.txt")); // true or false

Starlight:

sldeploy(fs.exists("example.txt"));

Make Directory

fs.makeDir("myFolder");

Starlight:

fs.makeDir("myFolder");

List Directory Contents

console.log(fs.listDir("myFolder"));

Starlight:

sldeploy(fs.listDir("myFolder"));

Delete Directory

fs.deleteDir("myFolder");

Starlight:

fs.deleteDir("myFolder");

Copy File / Directory

fs.copyFile("source.txt", "dest.txt");
fs.copyDir("srcFolder", "destFolder");

Starlight:

fs.copyFile("source.txt", "dest.txt");
fs.copyDir("srcFolder", "destFolder");

Path Utilities

console.log(fs.join("folder", "file.txt"));   // "folder/file.txt"
console.log(fs.basename("/path/to/file.txt")); // "file.txt"
console.log(fs.dirname("/path/to/file.txt"));  // "/path/to"
console.log(fs.extname("file.txt"));           // ".txt"
console.log(fs.resolve("folder", "file.txt"));
console.log(fs.relative("/a/b", "/a/b/c/d"));  // "c/d"

Starlight:

sldeploy(fs.join("folder", "file.txt"));
sldeploy(fs.basename("/path/to/file.txt"));
sldeploy(fs.dirname("/path/to/file.txt"));
sldeploy(fs.extname("file.txt"));
sldeploy(fs.resolve("folder", "file.txt"));
sldeploy(fs.relative("/a/b", "/a/b/c/d"));

Notes


starlight-time

A simple time and date utility library for JavaScript and Starlight, providing current time, formatting, timers, and sleep functionality.


Installation

Install via npm:

npm install starlight-time@latest

Import

For both JavaScript and Starlight:

import time from "starlight-time";

Get Current Date and Time

console.log(time.now());          // Current date object
console.log(time.formatDate());   // e.g., "2026-01-12"
console.log(time.formatTime());   // e.g., "14:35:42"

Starlight:

sldeploy(time.now());
sldeploy(time.formatDate());
sldeploy(time.formatTime());

Sleep / Delay

console.log("Start");
time.sleep(1000);   // Sleep for 1 second
console.log("End");

Starlight:

sldeploy("Start");
time.sleep(1000);
sldeploy("End");

⚠ Note: sleep in this version is blocking. Use carefully in loops.


Set a Timer

const stop = time.setTimer(() => console.log("Tick"), 1000); // every 1 second

setTimeout(() => {
    stop(); // stop after 5 seconds
    console.log("Timer stopped");
}, 5000);

Starlight:

const stop = time.setTimer(() => sldeploy("Tick"), 1000);

setTimeout(() => {
    stop();
    sldeploy("Timer stopped");
}, 5000);

In Starlight, sldeploy() is used instead of print().


Convert Seconds to HH:MM:SS

console.log(time.secondsToHMS(3661)); // "01:01:01"
console.log(time.secondsToHMS(59));   // "00:00:59"

Starlight:

sldeploy(time.secondsToHMS(3661));
sldeploy(time.secondsToHMS(59));

Notes


Starlight Color

starlight-color is a simple library for styling console text using ANSI escape codes. You can apply colors, background colors, and text styles like bold, underline, italic, and more.


Installation

npm install starlight-color@latest

Import

import { colors, bgColors, styles, style } from 'starlight-color';

The import line is the same in both JavaScript and Starlight.


JavaScript Usage

import { colors, bgColors, styles, style } from 'starlight-color';

// Basic colors
console.log(colors.red("This is red text"));
console.log(colors.cyan("This is cyan text"));

// Background colors
console.log(bgColors.yellow("Yellow background"));
console.log(bgColors.brightBlue("Bright blue background"));

// Styles
console.log(styles.bold("Bold text"));
console.log(styles.underline("Underlined text"));

// Combined styling
console.log(style("Green bold underlined text", { color: "green", bold: true, underline: true }));

// 256-color support
console.log(style("Custom foreground 202", { fg256: 202 }));
console.log(style("Custom background 120", { bg256: 120 }));

Starlight Usage

In Starlight, use sldeploy() instead of console.log() to output styled text.

import { colors, bgColors, styles, style } from 'starlight-color';

sldeploy(colors.red("This is red text"));
sldeploy(bgColors.yellow("Yellow background"));
sldeploy(styles.bold("Bold text"));
sldeploy(style("Green bold underlined text", { "color": "green", "bold": true, "underline": true }));

sldeploy(style("Custom foreground 202", { "fg256": 202 }));
sldeploy(style("Custom background 120", { "bg256": 120 }));

API

Colors

colors.black(text)
colors.red(text)
colors.green(text)
colors.yellow(text)
colors.blue(text)
colors.magenta(text)
colors.cyan(text)
colors.white(text)
colors.gray(text)
colors.brightRed(text)
colors.brightGreen(text)
colors.brightYellow(text)
colors.brightBlue(text)
colors.brightMagenta(text)
colors.brightCyan(text)
colors.brightWhite(text)
colors.fg256(n, text)   // 256-color foreground

Background Colors

bgColors.black(text)
bgColors.red(text)
bgColors.green(text)
bgColors.yellow(text)
bgColors.blue(text)
bgColors.magenta(text)
bgColors.cyan(text)
bgColors.white(text)
bgColors.brightBlack(text)
bgColors.brightRed(text)
bgColors.brightGreen(text)
bgColors.brightYellow(text)
bgColors.brightBlue(text)
bgColors.brightMagenta(text)
bgColors.brightCyan(text)
bgColors.brightWhite(text)
bgColors.bg256(n, text) // 256-color background

Styles

styles.bold(text)
styles.dim(text)
styles.italic(text)
styles.underline(text)
styles.inverse(text)
styles.hidden(text)
styles.strikethrough(text)

Combined Styling

style(text, { 
  color,       // text color
  bg,          // background color
  bold, dim, italic, underline, inverse, hidden, strike, 
  fg256, bg256 // 256-color support
})

Notes


starlight-txt-to-pdf

A utility to convert TXT files to PDF with text formatting, headers, footers, colors, bold/italic styles, and image embedding. Works in both JavaScript and Starlight.


Installation

Install via npm:

npm install starlight-txt-to-pdf@latest

Import

For both JavaScript and Starlight:

import { txtToPdf } from "starlight-txt-to-pdf";

Usage in JavaScript

import { txtToPdf } from "starlight-txt-to-pdf";

(async () => {
  try {
    const output = await txtToPdf("letter.txt", "letter.pdf", {
      header: "My PDF Document 💌"
    });
    console.log("PDF saved to:", output);
  } catch (err) {
    console.error("Error generating PDF:", err.message);
  }
})();

Features:


Usage in Starlight

import { txtToPdf } from "starlight-txt-to-pdf";

await txtToPdf("letter.txt", "letter.pdf", { header: "My PDF Document 💌" });
sldeploy("PDF generated: letter.pdf");

Example TXT content with formatting:

# My Love Letter 💖
[color:red][b]Dear Alice,[/b][/color]

I hope this letter finds you well.

## Memories
[i]Remember the day we first met?[/i]

[img:heart.png,x=200,y=500,w=100,h=100]

Notes


wiki-starlight-api

A simple Wikipedia API wrapper for fetching search results, summaries, full content, images, categories, and languages. Works in JavaScript and Starlight.


Installation

Install via npm:

npm install wiki-starlight-api@latest

Import

For both JavaScript and Starlight:

import * as wiki from "wiki-starlight-api";

Usage in JavaScript

import * as wiki from "wiki-starlight-api";

(async () => {
  // Search articles
  const results = await wiki.search("JavaScript", 5);
  console.log("Search results:", results);

  // Get summary of an article
  const jsSummary = await wiki.summary("JavaScript");
  console.log(jsSummary);

  // Get full page content
  const jsPage = await wiki.page("JavaScript");
  console.log(jsPage.content);

  // Get a random article
  const randomArticle = await wiki.random();
  console.log(randomArticle);

  // Get article languages
  const langs = await wiki.languages("JavaScript");
  console.log("Available languages:", langs);

  // Get article images
  const imgs = await wiki.images("JavaScript");
  console.log("Images:", imgs);

  // Get article categories
  const cats = await wiki.categories("JavaScript");
  console.log("Categories:", cats);

  // Search and get summaries
  const summaries = await wiki.searchAndSummary("Python", 3);
  console.log(summaries);
})();

Usage in Starlight

import * as wiki from "wiki-starlight-api";

// Search articles
const results = await wiki.search("JavaScript", 5);
sldeploy("Search results:\n" + results);

// Get summary
const jsSummary = await wiki.summary("JavaScript");
sldeploy("JavaScript summary:\n" + jsSummary.extract);

// Get full page content
const jsPage = await wiki.page("JavaScript");
sldeploy(jsPage.content);

// Get random article
const randomArticle = await wiki.random();
sldeploy("Random article:\n" + randomArticle.title + "\n" + randomArticle.extract);

// Get article languages
const langs = await wiki.languages("JavaScript");
sldeploy("Languages: " + langs.map(l => l.lang + " → " + l.title).join(", "));

// Get images
const imgs = await wiki.images("JavaScript");
sldeploy("Images: " + imgs.join(", "));

// Get categories
const cats = await wiki.categories("JavaScript");
sldeploy("Categories: " + cats.join(", "));

// Search and get summaries
const summaries = await wiki.searchAndSummary("Python", 3);
summaries.forEach(s => sldeploy(s.title + ": " + s.extract));

Features


Notes


Language Specification

1. Introduction

This language is a JavaScript-inspired scripting language with custom keywords and syntax for tasks like asynchronous functions, tracking, deployments (sldeploy), and race conditions (start ... race). It supports:


2. Lexical Structure

2.1 Whitespace

2.2 Comments

Type Syntax
Single-line # comment
Multi-line #* comment *#

2.3 Identifiers

2.4 Keywords

Reserved words cannot be used as identifiers.

let, sldeploy, if, else, while, for, break, continue,
func, return, true, false, null,
ask, define, import, from, as,
async, await, new, in, do, track, start, race

2.5 Literals

Type Example
Number 42, 3.14
String "hello", 'hi'
Boolean true, false
Null null

2.6 Operators

Assignment / Compound Assignment

=, +=, -=, *=, /=, %=

Arithmetic

+, -, *, /, %

Comparison

==, !=, <, <=, >, >=

Logical

&&, ||, !, ??

Increment / Decrement

++, --

Arrow Function

=>, ->

2.7 Punctuation

( ) { } [ ] ; , : .

3. Expressions

3.1 Primary Expressions

3.2 Unary Operators

+, -, !, ++, --

3.3 Binary Operators

3.4 Ternary / Conditional

condition ? exprIfTrue : exprIfFalse

3.5 Assignment

variable = expr
variable += expr
...

3.6 Function Calls and Member Access

func(arg1, arg2)
obj.property
array[index]

3.7 Arrow Functions


4. Statements

4.1 Variable Declaration

let x = 5;

4.2 Function Declaration

func foo(a, b) { ... }
async func bar() { ... }

4.3 Control Flow

If Statement

if (condition) { ... } else { ... }

While Loop

while (condition) { ... }

For Loop

for (init; test; update) { ... }
for (let item in iterable) { ... }

Do...Track

do { ... } track { ... }

Start...Race

start expr {
  race condition1 { ... }
  race condition2 { ... }
}

4.4 Return

return expr;

4.5 Break / Continue

break;
continue;

4.6 Expression Statement

Any expression can be a statement:

x + y;
ask("name");

5. Imports

Supports default, named, and namespace imports:

import foo from "module";
import { a, b as c } from "module";
import * as ns from "module";

6. Blocks


7. Error Handling


8. Example Program

async func greet(name) {
  let greeting = ask("Enter greeting:");
  return greeting + ", " + name;
}

start event {
  race ready { sldeploy greet("Alice"); }
  race timeout { sldeploy "Timeout!"; }
}

Keywords & Tokens Reference

1. Reserved Keywords

These are recognized as special tokens and cannot be used as identifiers:

Keyword Token Type
let LET
sldeploy SLDEPLOY
if IF
else ELSE
while WHILE
for FOR
break BREAK
continue CONTINUE
func FUNC
return RETURN
true TRUE
false FALSE
null NULL
ask ASK
define DEFINE
import IMPORT
from FROM
as AS
async ASYNC
await AWAIT
new NEW
in IN
do DO
track TRACK
start START
race RACE

2. Literals

Literal Type Token Type Example
Number NUMBER 42, 3.14
String STRING "hello", 'hi'
Boolean TRUE/FALSE true, false
Null NULL null

3. Operators

Assignment / Compound Assignment

Symbol Token Type
= EQUAL
+= PLUSEQ
-= MINUSEQ
*= STAREQ
/= SLASHEQ
%= MODEQ

Arithmetic

Symbol Token Type
+ PLUS
- MINUS
* STAR
/ SLASH
% MOD

Comparison

Symbol Token Type
== EQEQ
!= NOTEQ
< LT
<= LTE
> GT
>= GTE

Logical

Symbol Token Type
&& AND
! NOT
?? NULLISH_COALESCING

Increment / Decrement

Symbol Token Type
++ PLUSPLUS
-- MINUSMINUS

Arrow Function

Symbol Token Type
=> ARROW
-> ARROW

4. Punctuation & Delimiters

Symbol Token Type
( LPAREN
) RPAREN
{ LBRACE
} RBRACE
[ LBRACKET
] RBRACKET
; SEMICOLON
, COMMA
: COLON
. DOT

5. Comments

Type Syntax
Single-line # comment
Multi-line #* comment *#

✅ Notes:

  1. Keywords are case-sensitive and mapped to uppercase token types.
  2. Strings support escape sequences like \n, \t, \", \', \\.
  3. Number literals can be integers or floats.
  4. Multi-character operators (==, !=, <=, >=, &&, ||, ??, +=, etc.) are checked before single-character tokens.
  5. Arrow functions use both => and ->.

Operators Reference

1. Arithmetic Operators

Operator Type Notes
+ Binary Addition
- Binary Subtraction
* Binary Multiplication
/ Binary Division
% Binary Modulo
+ Unary Unary plus
- Unary Unary minus
++ Unary Increment (prefix/postfix)
-- Unary Decrement (prefix/postfix)

2. Assignment Operators

Operator Type Notes
= Assignment Assign value
+= Compound Assignment Add and assign
-= Compound Assignment Subtract and assign
*= Compound Assignment Multiply and assign
/= Compound Assignment Divide and assign
%= Compound Assignment Modulo and assign

3. Comparison Operators

Operator Type Notes
== Binary Equals
!= Binary Not equal
< Binary Less than
<= Binary Less than or equal
> Binary Greater than
>= Binary Greater than or equal

4. Logical Operators

Operator Type Notes
&& Binary Logical AND
` ` Binary Logical OR
! Unary Logical NOT
?? Binary Nullish coalescing

5. Conditional / Ternary

Operator Type Notes
? : Ternary Conditional expression

6. Arrow / Lambda Operators

Operator Type Notes
=> Arrow Arrow function
-> Arrow Arrow function alternative

7. Member and Index Access

Operator Type Notes
. Member Object property access
[] Index Array or object indexing

8. Special / Function Operators

Operator Type Notes
new Unary Instantiate object/class
await Unary Await asynchronous expression
ask() Call Prompt for user input

9. Precedence Overview (High → Low)

  1. Postfix: ++ --
  2. Unary: + - ! await new
  3. Multiplicative: * / %
  4. Additive: + -
  5. Comparison: < <= > >=
  6. Equality: == !=
  7. Logical AND: &&
  8. Logical OR: ||
  9. Nullish Coalescing: ??
  10. Conditional / Ternary: ? :
  11. Assignment / Compound Assignment: = += -= *= /= %=
  12. Arrow Functions: => ->

Runtime Model

1. Program Execution


2. Values and Types

Your language has the following primitive types:

Type Description Example
number Integer or floating-point 42, 3.14
string Text literal "hello", 'world'
boolean true or false true, false
null Null value null
array Ordered collection of values [1, 2, 3]
object Key-value mapping { x: 10, y: 20 }
function Callable code block func(x) { return x+1 }
async function Asynchronous function async func() { ... }
awaitable Result of async operations await fetchData()

3. Variables and Scope


4. Expressions and Evaluation

Expressions are evaluated according to operator precedence:

  1. Postfix: ++ --
  2. Unary: + - ! await new
  3. Multiplicative: * / %
  4. Additive: + -
  5. Comparison: < <= > >=
  6. Equality: == !=
  7. Logical AND: &&
  8. Logical OR: ||
  9. Nullish Coalescing: ??
  10. Conditional / Ternary: ? :
  11. Assignment: = += -= *= /= %=
  12. Arrow Functions: => ->

5. Functions


6. Control Flow


7. Special Statements

Statement Runtime Behavior
sldeploy Executes a special deploy action with evaluated expression.
ask() Prompts for user input and returns value.
start { race } Executes multiple concurrent blocks, chooses winner.
do ... track Executes a block with an optional error handling block.

8. Objects and Arrays


9. Operators


10. Errors and Exceptions


11. Modules and Imports


12. Asynchronous Execution


Built-in Features of Starlight

Output

sldeploy(value)

Outputs a formatted value to standard output.

sldeploy "Hello"
sldeploy [1, 2, 3]
sldeploy { a: 1, b: 2 }

Input

ask(prompt)

Reads user input from the terminal.

let name = ask("Enter your name:")

Type & Conversion

type(value)

Returns the runtime type of a value.

type(10)        // "number"
type("hi")      // "string"
type([1,2])     // "array"
type({})        // "object"

num(value)

Converts a value to a number.

num("42")       // 42
num("abc")      // RuntimeError

str(value)

Converts a value to a string.

str(100)        // "100"

Collections

len(value)

Returns length of:

len([1,2,3])    // 3
len("abc")      // 3
len({a:1})      // 1

keys(object)

Returns an array of object keys.

keys({a:1, b:2})   // ["a", "b"]

values(object)

Returns an array of object values.

values({a:1, b:2}) // [1, 2]

Array Utilities

map(array, fn)

Applies a function to each element.

map([1,2,3], x => x * 2)

filter(array, fn)

Filters array elements.

filter([1,2,3,4], x => x > 2)

reduce(array, fn, initial?)

Reduces array to a single value.

reduce([1,2,3], (a,b) => a + b)

range(...)

Generates numeric ranges.

range(5)          // [0,1,2,3,4]
range(1,5)        // [1,2,3,4]
range(10,0,-2)    // [10,8,6,4,2]

Async & Time

sleep(ms)

Pauses execution asynchronously.

await sleep(1000)

Networking

fetch(url, options?)

Performs an HTTP request.

Returns an object with:

res = await fetch("https://example.com")
data = await res.json()

get(url)

HTTP GET request returning parsed JSON.

data = await get("https://api.example.com")

post(url, data)

HTTP POST request with JSON body.

post("https://api.example.com", { a: 1 })

Variables

let

Declares a variable with initializer required.

let x = 10

define

Defines a variable or constant.

define PI = 3.14

Control Flow

if / else

Conditional execution.

if x > 5 {
  sldeploy "big"
} else {
  sldeploy "small"
}

while

Loop while condition is true.

while x < 5 {
  x++
}

for

Classic loop:

for let i = 0; i < 5; i++ {
  sldeploy i
}

for ... in

Iterates over arrays or objects.

for x in [1,2,3] {
  sldeploy x
}

for k in {a:1, b:2} {
  sldeploy k
}

break

Exits a loop.


continue

Skips current iteration.


Functions

func

Defines a function.

func add(a, b) {
  return a + b
}

async func

Defines an async function.

async func load() {
  await sleep(1000)
}

Arrow Functions

x => x * 2
(a, b) => a + b

return

Returns a value from a function.


Error Handling

do / track

Error-handling construct.

do {
  risky()
} track {
  sldeploy error
}

Branch Matching

start / race

Value-based branching.

start x {
  race 1 {
    sldeploy "one"
  }
  race 2 {
    sldeploy "two"
  }
}

Imports

import

Supports both Starlight files and Node.js modules.

Import Starlight files (.sl)

import x from "math.sl"
import { add } from "math.sl"
import * as math from "math.sl"

Import Node.js modules

import fs from "fs"
import path from "path"

Expressions & Operators

Binary Operators

+  -  *  /  %
== != < <= > >=

Logical Operators

&&  ||  ??

Unary Operators

!  +  -

Update Operators

x++
--y

Ternary Operator

x > 5 ? "yes" : "no"

Objects

{ a: 1, b: 2 }

Arrays

[1, 2, 3]

Indexing

arr[0]
obj["key"]

Member Access

obj.key

new

Creates an object from a function.

new MyClass(1, 2)

await

Waits for async values.

await fetch(url)

Runtime Notes