Prizm

Prizm Programming Language

Created by: Seigh-sword
Repository: https://github.com/Seigh-sword/Prizm
License: Prizm License (Free Forever)

Prizm is a beginner-friendly programming language designed to make coding simple and approachable. The language emphasizes clarity, creativity, and practical power - perfect for those new to programming and developers who want efficiency.

File Extension: .pzm
Main Entry Point: center.pzm
Current Version: 0.1.0


Table of Contents

Getting Started

Documentation

For Developers

Additional Resources



Installation

Prizm comes with zero external dependencies. Download, run, and code immediately.

Linux & macOS

# One-line install (auto-detects OS & architecture)
curl -fsSL https://raw.githubusercontent.com/Seigh-sword/Prizm/main/install.sh | bash

# Reload shell
source ~/.bashrc  # or ~/.zshrc for macOS

Windows

# PowerShell (as Administrator)
irm https://raw.githubusercontent.com/Seigh-sword/Prizm/main/install.bat | iex

# Reopen PowerShell after installation

Verify Installation

prizm --version
# Output: Prizm v0.1.0

Create Your First Project

# Initialize a new project
./init.sh myapp    # Linux/macOS
# OR
init.bat myapp     # Windows

# Navigate to project
cd myapp

# Run it
prizm run

See QUICKSTART.md for detailed guidance.


Language Features

Built-in Functions (Non-Headered)

These functions are always available at the top level without needing a header. The compiler automatically uses them when called:

Headers and Attributes System

All other functionality is organized in headers. The system only loads the header you request along with its specific attributes. The compiler doesn’t process the entire codebase; it only loads what you need.

Example:

math.random(1-10),

Syntax

Type System

Prizm supports strong typing with the following data types:

var age: int = 25,
var height: float = 5.9,
var name: string = "Alice",
var isActive: boolean = true,
var numbers: array = [1, 2, 3, 4, 5],
var person: object = {name: "Bob", age: 30},

Supported Types:

Built-in Headers and Attributes

1. File Operations Header (file)

2. Math Operations Header (math)

3. Control Flow Header (control)

4. Variables Header (var)

5. Function Definition Header (function)

6. HTTP Operations Header (http)

7. UI Operations Header (ui)

Create interactive windows and handle user interactions.

UI Elements:

Event Handling:

Button Click Example:

# Create a window
ui.window("My App", 400, 300),

# Create a button
ui.button("Click Me", 100, 100, 150, 40),

# Handle click event
ui.event("click", handle_button_click),

# Define callback function
define handle_button_click() {
    output("Button was clicked!"),
    var result: int = math.add(5, 3),
    output("5 + 3 = " + result),
}

# Render everything
ui.render(),

Interactive Form Example:

# Create interactive form
ui.window("Login Form", 500, 400),

ui.label("Username:", 50, 50),
ui.input("Enter username", 50, 80, 300, 30),

ui.label("Password:", 50, 130),
ui.input("Enter password", 50, 160, 300, 30),

ui.button("Login", 100, 230, 100, 40),
ui.button("Cancel", 250, 230, 100, 40),

# Click handlers
ui.event("click", on_login_click),
ui.event("click", on_cancel_click),

define on_login_click() {
    output("Login attempt started..."),
    time.sleep(1000),
    output("Login successful!"),
}

define on_cancel_click() {
    output("User cancelled login"),
}

ui.render(),

8. Root Header (root) - Super Powerful Operations

The root header provides low-level system access and advanced operations:

9. Data/JSON Header (data) - Prizm JSON Format

Prizm has its own JSON format that works seamlessly with variables:

var config: object = {
    name: "App",
    version: "1.0.0",
    features: ["login", "dashboard", "settings"],
    debug: true,
},

// Encode to JSON string
var json_str = data.stringify(config),

// Parse JSON string
var parsed = data.parse(json_str),

// Validate JSON structure
var is_valid = data.validate(config),

// Merge objects
var merged = data.merge(config, other_config),

10. Time Operations Header (time)

ID System

Each header and attribute is assigned a unique ID for Assembly integration:

CLI Commands

# Run a Prizm file
prizm run [filename.pzm]

# Format/Pretty print a file
prizm pretty [filename.pzm]

# Lint and check for errors
prizm lint [filename.pzm]

Example Program: Number Guesser Game

// Number Guesser Game in Prizm
// Uses built-in output and math header

output("Welcome to the Number Guesser Game!"),

var secret: int = math.random(1-10),
var guess: int = 0,
var attempts: int = 0,

loop until (guess == secret) {
    output("Guess a number between 1 and 10: "),
    attempts = attempts + 1,
    
    if (guess < secret) {
        output("Too low! Try again."),
    } else if (guess > secret) {
        output("Too high! Try again."),
    },
},

output("You guessed it in "),
output(attempts),
output(" attempts!"),

Example Program: UI Application

// Simple UI Application in Prizm

// Create main window
ui.window("My Prizm App", 1024, 768),

// Create UI elements
ui.label("Welcome to Prizm!", 50, 50),
ui.button("Click Here", 100, 100, 200, 50),
ui.input("Enter something...", 100, 200, 300, 40),
ui.text("This is a dynamic text element", 100, 300),

// Render the UI
ui.render(),

// Use data/JSON for app config
var app_config: object = {
    theme: "dark",
    language: "en",
    autoSave: true,
},

var config_json = data.stringify(app_config),
output("App Config: "),
output(config_json),

Project Structure

├── README.md
├── build.sh                    (Linux/macOS build script)
├── build.bat                   (Windows build script)
├── assets/
│   └── logo.svg
├── source/
│   └── example.pzm
├── bin/                        (Compiled output)
│   ├── release/                (Release binaries)
│   ├── debug/                  (Debug binaries)
│   └── dll/                    (Compiled DLL files)
├── build/
│   └── build.rs               (Build configuration)
└── compiler/
    ├── Cargo.toml
    ├── compiler.asm
    ├── parser.asm
    └── src/
        ├── main.rs            (CLI executable)
        ├── lib.rs             (DLL library)
        ├── cli.rs             (Command utilities)
        ├── attributes.rs      (Headers & ID system)
        ├── lexer.rs           (Tokenizer with type support)
        └── stdlib.rs          (Built-in functions)

Building Prizm

Linux/macOS

chmod +x build.sh
./build.sh

Windows

build.bat

Manual Build

cd compiler
cargo build --release
./target/release/prizm_compiler run ../source/example.pzm

Binary Output Formats

After building, you’ll find:

Features Summary

Complete Language Features

Performance


Need Help?

Repository & License

Version


Community

We welcome contributions, feedback, and creative Prizm projects!

Happy coding with Prizm!