MCPcopy Index your code
hub / github.com/GlyphLang/GlyphLang

github.com/GlyphLang/GlyphLang @v0.7.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.7.0 ↗ · + Follow
7,915 symbols 41,179 edges 327 files 4,584 documented · 58%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GlyphLang™

AI Token Savings CI Coverage Version License CLA

GlyphLang™ is an AI-first backend programming language designed to reduce boilerplate, lower LLM token costs, and ship production APIs faster.

Modern backend development is increasingly written with AI—but existing languages and frameworks were never designed for AI generation. The result is bloated code, fragile outputs, high token costs, and endless glue logic.

GlyphLang is built from the ground up to be: - Easy for AI to generate - Strict enough for production - Opinionated enough to stay simple

It compiles to a single static binary, includes a built-in HTTP server and database access, and minimizes files, syntax and configuration so both humans and AI can move faster.


Why GlyphLang?

Same API, fewer tokens, fewer files:

FastAPI: - ~300 lines - 6–8 files - External server, routing, validation, glue code

GlyphLang: - ~60–80 lines - 1 file - Built-in server, routing, validation

Less code isn't just productivity. It directly reduces: - LLM token usage - Generation errors - Maintenance surface area

Glyph:  @ GET /users/:id -> User     (21 tokens)
Python: @app.route('/users/<id>')... (35 tokens)
Java:   @GetMapping("/users/{id}")...  (28 tokens)

What you get

  • AI-optimized syntax that minimizes boilerplate and token usage
  • Built-in HTTP server, async, database access, and WebSockets
  • Single static binary deployment
  • First-class CLI, LSP, and VS Code support
  • Designed for real production backends—not demos

Who is this for?

  • GlyphLang is a great fit if you:
  • Build AI-powered APIs or internal tools
  • Use LLMs heavily for backend code generation
  • Want fewer files, fewer abstractions, and lower AI costs
  • Prefer opinionated tooling over endless configuration

Features

AI-First Design

  • Minimal Ceremony - Skip the boilerplate—routes and types are the program
  • Context Command - Generate project summaries optimized for LLM context windows
  • Structured Validation - JSON error output for AI agents to parse and fix
  • Consistent Patterns - Every route and type definition follows the same structure

Core Language

  • Type System - int, string, bool, float, arrays, objects, optional (T?), union (A | B), generics
  • Pattern Matching - match expressions with guards and destructuring
  • Async/Await - futures with All, Race, Any combinators
  • Modules - file imports, aliases, selective imports
  • Generics - type parameters, inference, constraints
  • Macros - compile-time code generation

Runtime

  • Bytecode Compiler - 3 optimization levels
  • JIT Compilation - type specialization, hot path detection
  • Hot Reload - instant updates during development
  • Debug Mode - breakpoints, variable inspection, REPL

Infrastructure

  • HTTP Server - routes, middleware, WebSocket support
  • Database - PostgreSQL with pooling, transactions, migrations
  • Security - JWT auth, rate limiting, CORS, SQL injection prevention
  • Observability - logging, Prometheus metrics, OpenTelemetry tracing

Code Generation

  • Polyglot Output - Generate Python/FastAPI or TypeScript/Express servers from the same .glyph source
  • Custom Providers - Define provider contracts with provider Name { method(...) -> Type }
  • Semantic IR - Language-neutral intermediate representation powers multi-target output

Tooling

  • LSP Server - full IDE support with completions, diagnostics, rename
  • VS Code Extension - syntax highlighting, LSP support, error checking
  • CLI - compile, run, REPL, decompile, AI context commands

Symbol Reference

GlyphLang uses a small set of symbols for consistent, scannable syntax:

Symbol Name Usage Example
@ Route HTTP endpoint definition @ GET /users
: Type Type definition : User { id: int }
$ Variable Variable declaration $ name = "Alice"
! Function Function/CLI command definition ! greet(name: str)
> Return Return statement > {message: "ok"}
+ Middleware Apply middleware + auth(jwt)
% Inject Dependency injection % db: Database
? Optional Optional type modifier email: str?
* Cron Scheduled task definition * "0 * * * *" cleanup
~ Event Event handler definition ~ user.created
& Queue Queue worker definition & emails processEmail
# Comment Single-line comment # This is a comment
-> Arrow Return type annotation -> User
\| Union Union type separator str \| int

Type Modifiers: - T! - Required (non-null) - T? - Optional (nullable) - [T] - Array of T

Installation

Windows Installer (Recommended):

Download and run the installer: glyph-windows-setup.exe

Note: Code signing via SignPath is pending approval. You may see a Windows SmartScreen warning when running the installer - click "More info" then "Run anyway" to proceed.

Download binary:

# Linux
curl -L https://github.com/GlyphLang/GlyphLang/releases/latest/download/glyph-linux-amd64.zip -o glyph.zip
unzip glyph.zip && chmod +x glyph-linux-amd64 && sudo mv glyph-linux-amd64 /usr/local/bin/glyph

# macOS (Intel)
curl -L https://github.com/GlyphLang/GlyphLang/releases/latest/download/glyph-darwin-amd64.zip -o glyph.zip
unzip glyph.zip && chmod +x glyph-darwin-amd64 && sudo mv glyph-darwin-amd64 /usr/local/bin/glyph

# macOS (Apple Silicon)
curl -L https://github.com/GlyphLang/GlyphLang/releases/latest/download/glyph-darwin-arm64.zip -o glyph.zip
unzip glyph.zip && chmod +x glyph-darwin-arm64 && sudo mv glyph-darwin-arm64 /usr/local/bin/glyph

Windows (PowerShell):

Invoke-WebRequest -Uri "https://github.com/GlyphLang/GlyphLang/releases/latest/download/glyph-windows-amd64.zip" -OutFile glyph.zip
Expand-Archive glyph.zip -DestinationPath . ; Move-Item glyph-windows-amd64.exe glyph.exe

Or build from source:

git clone https://github.com/GlyphLang/GlyphLang.git
cd GlyphLang && go build -o glyph ./cmd/glyph

Editor Support

VS Code Extension

The official GlyphLang extension is available on the Visual Studio Code Marketplace:

Install from Marketplace

Features: - Syntax Highlighting - Full semantic highlighting for all GlyphLang symbols and constructs - LSP Integration - Real-time error checking, code completion, and hover documentation - Go to Definition - Navigate to type definitions, functions, and imports - Find References - Locate all usages of symbols across your project - Rename Symbol - Safely rename variables, functions, and types - Diagnostics - Inline error and warning messages as you type

To install, search for "GlyphLang" in the VS Code Extensions panel or run:

ext install GlyphLang.GlyphLang

Quick Start

Create hello.glyph:

@ GET /hello {
  > {message: "Hello, World!"}
}

@ GET /greet/:name {
  > {message: "Hello, " + name + "!"}
}

Run it:

glyph run hello.glyph

Visit http://localhost:3000/hello

Examples

Type Definitions

: User {
  id: int!
  name: str!
  email: str?
  roles: [str]!
}

: ApiResponse<T> {
  data: T?
  error: str?
  success: bool!
}

Routes with Authentication

@ GET /api/users/:id -> User | Error {
  + auth(jwt)
  + ratelimit(100/min)
  % db: Database

  $ user = db.query("SELECT * FROM users WHERE id = ?", id)
  if user == null {
    > {error: "User not found", code: 404}
  }
  > user
}

Pattern Matching

@ GET /status/:code {
  $ result = match code {
    200 => "OK"
    201 => "Created"
    400 => "Bad Request"
    404 => "Not Found"
    n when n >= 500 => "Server Error"
    _ => "Unknown"
  }
  > {status: code, message: result}
}

Async/Await

# Basic async block - executes in background, returns Future
@ GET /compute {
  $ future = async {
    $ x = 10
    $ y = 20
    > x + y
  }
  $ result = await future
  > {value: result}
}

# Parallel execution - all requests run concurrently
@ GET /dashboard {
  $ userFuture = async { > db.getUser(userId) }
  $ ordersFuture = async { > db.getOrders(userId) }
  $ statsFuture = async { > db.getStats(userId) }

  # Await blocks until Future resolves
  $ user = await userFuture
  $ orders = await ordersFuture
  $ stats = await statsFuture

  > {user: user, orders: orders, stats: stats}
}

Generics

! identity<T>(x: T): T {
  > x
}

! first<T>(a: T, b: T): T {
  > a
}

! map<T, U>(arr: [T], fn: (T) -> U): [U] {
  $ result = []
  for item in arr {
    $ mapped = fn(item)
    result = append(result, mapped)
  }
  > result
}

Modules

# utils.glyph
! formatName(first: str, last: str): str {
  > first + " " + last
}

# main.glyph
import "./utils"

@ GET /user/:id {
  $ name = utils.formatName(user.first, user.last)
  > {displayName: name}
}

Macros

# Define reusable patterns with macros
macro! validate_required(field) {
  if field == null {
    > {error: "field is required", status: 400}
  }
}

macro! json_response(data, status) {
  > {data: data, status: status, timestamp: now()}
}

# CRUD pattern - what macro expansion produces:
@ GET /users {
  > db.query("SELECT * FROM users")
}

@ GET /users/:id {
  > db.query("SELECT * FROM users WHERE id = ?", id)
}

@ POST /users {
  > db.insert("users", input)
}

@ DELETE /users/:id {
  > db.query("DELETE FROM users WHERE id = ?", id)
}

Cron Tasks

# Daily cleanup at midnight
* "0 0 * * *" daily_cleanup {
  % db: Database
  > {task: "cleanup", timestamp: now()}
}

# Every 5 minutes health check
* "*/5 * * * *" health_check {
  > {status: "healthy", checked_at: now()}
}

# Weekly report on Sundays at 9am with retries
* "0 9 * * 0" weekly_report {
  + retries(3)
  % db: Database
  > {week: "current", generated_at: now()}
}

Event Handlers

# Handle user creation event
~ "user.created" {
  $ user_id = event.id
  $ email = event.email
  > {handled: true, user_id: user_id}
}

# Async event handler
~ "order.completed" async {
  $ order_id = event.order_id
  $ total = event.total
  > {processed: true, order_id: order_id}
}

Queue Workers

# Email sending worker with concurrency and retries
& "email.send" {
  + concurrency(5)
  + retries(3)
  + timeout(30)

  $ to = message.to
  $ subject = message.subject
  > {sent: true, to: to}
}

# Image processing worker
& "image.process" {
  + concurrency(3)
  + timeout(120)

  $ image_id = message.image_id
  > {processed: true, image_id: image_id}
}

WebSockets

# Basic WebSocket chat
@ ws /chat {
  on connect {
    ws.join("lobby")
    ws.broadcast("User joined the chat")
  }

  on message {
    ws.broadcast(input)
  }

  on disconnect {
    ws.broadcast("User left the chat")
    ws.leave("lobby")
  }
}

# WebSocket with room parameter
@ ws /chat/:room {
  on connect {
    ws.join(room)
    ws.broadcast_to_room(room, "User joined")
  }

  on message {
    ws.broadcast_to_room(room, input)
  }

  on disconnect {
    ws.broadcast_to_room(room, "User left")
    ws.leave(room)
  }
}

CLI Commands (In-Language)

# Simple command with required argument
! hello name: str! {
  $ greeting = "Hello, " + name + "!"
  > {message: greeting}
}

# Command with multiple arguments
! add a: int! b: int! {
  $ result = a + b
  > {sum: result}
}

# Command with optional flag
! greet name: str! --formal: bool = false {
  if formal {
    > {greeting: "Good day, " + name}
  } else {
    > {greeting: "Hey " + name + "!"}
  }
}

# Command with description
! version "Show version information" {
  > {name: "MyApp", version: "1.0.0"}
}

Run commands with:

glyph exec app.glyph hello --name Alice
glyph exec app.glyph add --a 5 --b 3
glyph exec app.glyph greet --name Bob --formal
glyph commands app.glyph  # List all commands

CLI Commands

AI Agent Commands

These commands are designed for AI coding assistants and agents:

# Generate context for AI agents (fits in context windows)
glyph context                     # Full project context as JSON
glyph context --format compact    # Minimal text (fewer tokens)
glyph context --changed           # Only changes since last run
glyph context --for route         # Focus on routes only
glyph context --for type          # Focus on type definitions

# Validate with structured output for AI to parse and fix
glyph validate main.glyph --ai    # JSON errors with fix hints
glyph validate src/ --ai          # Validate entire directory

Example AI workflow:

# 1. Agent gets project context
glyph context --format compact > context.txt

# 2. Agent makes changes, then validates
glyph validate src/ --ai | agent-fix-errors

# 3. Agent checks what changed
glyph context --changed

Standard Commands

```bash glyph run # Run a Glyph file glyph dev

Extension points exported contracts — how you extend this code

Item (Interface)
Item represents a top-level item (TypeDef, Route, or Function) [21 implementers]
pkg/ast/ast.go
Interpreter (Interface)
Interpreter interface for executing GLYPH route logic This will be properly implemented later - for now we mock it [9 …
pkg/server/types.go
Value (Interface)
Value represents a runtime value [8 implementers]
pkg/vm/value.go
Database (Interface)
Database represents a generic database interface [5 implementers]
pkg/database/database.go
RPCMessage (Interface)
JSON-RPC 2.0 Message Types RPCMessage is the base interface for all JSON-RPC messages [3 implementers]
pkg/lsp/protocol.go
CompilerInterface (Interface)
CompilerInterface defines the interface for the Glyph compiler [3 implementers]
pkg/hotreload/watcher.go
SSEWriter (Interface)
SSEWriter is the interface that yield statements use to send events. It is injected into the environment as "__sse_write [2 …
pkg/interpreter/executor.go
Cache (Interface)
======================================== Cache Interface ======================================== Cache defines the cach [1 …
pkg/cache/cache.go

Core symbols most depended-on inside this repo

Run
called by 936
pkg/websocket/server.go
Error
called by 908
pkg/logging/logger.go
NewInterpreter
called by 616
pkg/interpreter/interpreter.go
EvaluateExpression
called by 452
pkg/interpreter/evaluator.go
Error
called by 429
pkg/interpreter/future.go
NewEnvironment
called by 426
pkg/interpreter/environment.go
Parse
called by 390
pkg/parser/parser.go
NewVM
called by 374
pkg/vm/vm.go

Shape

Function 5,022
Method 2,032
Struct 574
Class 128
Route 67
TypeAlias 47
Interface 32
FuncType 13

Languages

Go93%
Python7%
TypeScript1%
Java1%
Ruby1%

Modules by API surface

pkg/ast/ast.go275 symbols
pkg/database/additional_test.go270 symbols
pkg/interpreter/interpreter_test.go190 symbols
pkg/parser/coverage_boost_test.go127 symbols
pkg/interpreter/coverage_boost_test.go111 symbols
pkg/compiler/compiler_test.go109 symbols
pkg/formatter/formatter_test.go102 symbols
pkg/parser/parser_test.go97 symbols
pkg/parser/parser_coverage_test.go94 symbols
pkg/parser/parser.go89 symbols
pkg/lsp/additional_test.go84 symbols
pkg/vm/vm.go82 symbols

Datastores touched

itemsCollection · 1 repos
ordersCollection · 1 repos
postsCollection · 1 repos
usersCollection · 1 repos
testdbDatabase · 1 repos
mydbDatabase · 1 repos
(mysql)Database · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add GlyphLang \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page