Introducing Topaz

Meet Topaz, the language where code becomes poetry. A modern, expressive programming language with perfect support for non-English characters and natural multilingual development.

Note: This documentation reflects Topaz v4 (current default).

"The language where code becomes poetry" - Welcome to Topaz! 🌟 v4

Topaz is a modern programming language with perfect support for non-English characters. It pursues maximum expressiveness with minimal code, designed to let developers write code exactly as they think.

Audience
These docs are publicly readable. Some installation flows and tooling are available to Studio Haze engineers via internal channels.

LENA code Interop
Topaz is one of over 30 input/output languages supported by LENA code for 1:1 code conversion workflows, and it powers the CSKernel™ semantic core that drives those transformations.

🎯 What Makes Topaz Special

Perfect Unicode Support

function greet(name: string, language: string = "English") -> string {
    match language {
        case "한국어" => "안녕하세요, {name}님! 👋"
        case "English" => "Hello, {name}! 👋"
        case "Русский" => "Привет, {name}! 👋"
        case "Español" => "¡Hola, {name}! 👋"
        case "Français" => "Salut, {name}! 👋"
    }
}

let user = "김토파즈"
let greeting = greet(user, "한국어")
print(greeting)  // "안녕하세요, 김토파즈님! 👋"

Poetry-like Pipelines

let analysisResult = rawData
    |> normalize(standard: "UTF-8")
    |> filter(condition: x => x.isValid())
    |> groupBy(criteria: x => x.category)
    |> aggregate(method: average)
    |> visualize(chart: "bar")

Smart Type System

// Powerful type inference - safe without explicit types!
let age = 25                // inferred as int
let name = "토파즈"           // inferred as string
let complexStructure = {    // structure fully inferred
    id: 1,
    tags: ["web", "api"]
}

// Literal types for extra safety
type TrafficLight = "red" | "yellow" | "green"
type HTTPStatus = 200 | 404 | 500

function handleSignal(color: TrafficLight) {
    match color {
        case "red" => stop()
        case "yellow" => caution()
        case "green" => go()
        // Compiler ensures all cases are covered!
    }
}

🚀 Core Philosophy

"Write Less, Express More"

Pursue maximum expressiveness with minimal code. Even complex logic can be written in a readable and understandable way.

Global Syntax, Local Expression

Keywords are unified in English, but variable names and function names can freely use any language, including Korean, English, and even emojis.

Everything is an Expression

All constructs like if, match, for, try return values, enabling more functional programming-style code.

🧩 Native Systems Profile

  • Native execution with predictable performance and zero‑cost abstractions
  • Ownership, borrowing, and deterministic resource management (defer)
  • Concurrency primitives (tasks, channels) with a clear effect model
  • FFI with Rust/C for systems integration; internal toolchain handles linking

Concurrency at a Glance

let profileSummary = concurrent(timeout: 5s) {
    profile: API.fetchProfile(userId)?
    activity: API.fetchRecentActivity(userId)?
    recommendations: Recommendation.build(userId)
} else {
    {
        profile: cache.profile(userId),
        activity: [],
        recommendations: []
    }
}

match profileSummary {
    case Ok(data) => log.info("Ready with {data.recommendations.length} suggestions")
    case Err(reason) => log.warn("Served cached profile: {reason}")
}

Conceptual preview
Native FFI and low-level socket APIs are planned for a later phase and will ship with dedicated docs when stabilized.

🌈 Real Code Examples

Simple Web API Server

webServer.create(port: 8080)
    .middleware(auth.JWTValidation)
    .middleware(logging.requestTracker)
    .route("/api/users", method: GET) { request, response =>
        let userList = DB.users.findAll()
        response.JSON(userList)
    }
    .route("/api/users/{id}", method: GET) { request, response =>
        match DB.users.findById(request.params.id) {
            case Some(user) => response.JSON(user)
            case None => response.error(404, "User not found")
        }
    }
    .start()

Data Processing Pipeline

let salesAnalysis = file.read("2024_sales.csv")
    |> CSV.parse(hasHeader: true)
    |> filter(row => row.revenue > 1000000)
    |> groupBy(row => row.region)
    |> mapGroups(group => {
        region: group.key,
        totalRevenue: group.values.sum(row => row.revenue),
        avgRevenue: group.values.average(row => row.revenue)
    })
    |> sortBy(descending: row => row.totalRevenue)

🎁 Revolutionary Features

Automatic Async Handling

// All I/O is automatically async but written like sync!
function getUserInfo(id: int) -> User {
    let user = API.fetchUser(id)              // implicit async
    let profile = API.fetchProfile(user.profileId)  // implicit async
    let activity = API.fetchActivity(id)      // implicit async
    
    return User {
        basicInfo: user,
        profile: profile,
        activity: activity
    }
}

Elegant Error Handling

// Simple with Result type and ? operator
function safeFileProcessing(path: string) -> Result<Data, Error> {
    let file = openFile(path)?         // return immediately on failure
    defer { file.close() }            // guaranteed execution
    
    let content = file.read()?
    let data = JSON.parse(content)?
    let validated = data.validate()?
    
    Ok(validated)
}

The Art of Pattern Matching

let discountRate = match customer {
    case { tier: "VIP", purchaseAmount } if purchaseAmount > 1000000 => 0.3
    case { tier: "VIP" } => 0.2
    case { joinDate } if today - joinDate > 365.days => 0.1
    case { firstPurchase: true } => 0.15
    case _ => 0.0
}

🎯 Who Uses Topaz?

  • Web Developers: Clean API servers and rich web libraries
  • Data Analysts: Powerful pipelines and visualization tools
  • Systems Developers: Rust-level performance and safety
  • Beginners: Easier learning curve than Python
  • International Teams: Perfect Unicode and multilingual support

🚀 Get Started!

Topaz is designed to be learn in 1 day, use in production in 1 week.

Start your journey where coding becomes poetry with Topaz!