A programming language for AI to write and humans to read.
Glass programs use ~40% fewer tokens than Python and ~45% fewer than JavaScript. Glass runs on Python, so every Python library works. And it can tell you, in plain English, what any piece of code does.
text = read(args[0]) else: exit("error: {err}")
for word, n in text.lower().find_all("[a-z]+").tally().top(10)
print("{n} {word}")
That's a complete program, error handling included: the 10 most common words in a file.
Most code is now written by AI and steered by people who don't read every line. That gives a language two jobs: be cheap for the AI to write and be easy for a human to trust.
- Fewer tokens, so AI work is faster and cheaper. No colons, braces,
self,returnat the end,lambda,f"...", or try/except blocks, and a standard library built to chain:xs.tally().top(3). - The code explains itself.
glass sigshows what every function touches (files, network, ...), what it changes, and whether it can fail. Glass works this out from the code, so nobody has to write it down and it can't go stale.glass explainturns a program into plain-English steps. - Mistakes are caught before anything runs. Misspelled names, wrong arguments, unhandled failures, and missed cases are all reported with the exact fix, which an AI can apply in one pass.
- No hidden exceptions. Anything that can fail must be handled where it's
called, in one or two tokens:
try f(),f() else 0, orf() else: .... - As capable as Python.
use numpy,use requests, anything on pip. Speed is the same as Python, because Glass compiles to Python. - Easy for AI to learn. With one 1,600-token guide, fresh Claude models wrote 24 of 24 test programs correctly (results).
pip install git+https://github.com/arjuncode/glass-langNeeds Python 3.10+. No other dependencies. Or clone the repo and run ./glass
from it, with no install at all.
echo 'print("hello from glass")' > hello.glassglass hello.glassThen try the commands that make Glass different:
glass check app.glass # find problems without running anythingglass sig app.glass # what each function touches, changes, and whether it can failglass explain app.glass # the whole program in plain EnglishNew to Glass? Read Learn Glass in 10 minutes.
The same JSON web API in both:
| Python (169 tokens) | Glass (49 tokens) |
|---|---|
import json
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import parse_qs, urlparse
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
url = urlparse(self.path)
if url.path != "/add":
self.send_response(404)
self.end_headers()
self.wfile.write(b"not found")
return
q = parse_qs(url.query)
body = json.dumps({"sum": int(q["a"][0]) + int(q["b"][0])}).encode()
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(body)
HTTPServer(("127.0.0.1", 8080), Handler).serve_forever() |
|
- Put docs/AI_GUIDE.md in your agent's instructions: Claude Code's
CLAUDE.md, Cursor rules, or a system prompt. - Ask for what you want, in Glass.
- Have the agent run
glass check→glass test→glass run. It can fix anythingcheckreports from the message alone. - Before you trust the result, read
glass sig, orglass explainfor the full picture.
The same 7 programs written idiomatically in each language, standard library only, all producing identical output. Tokens were counted with a real 151k-vocabulary LLM tokenizer.
| Glass | Python | JavaScript | Go | Rust | C | |
|---|---|---|---|---|---|---|
| tokens (7 programs) | 561 | 922 | 1032 | 1308 | 1515 | 2303 |
| Glass saves | 39% | 46% | 57% | 63% | 76% |
Glass wins every task. Per-task numbers, all the programs, and the counting script are in bench/. (Go and Rust weren't compiled here. The tokenizer is Qwen2.5's, since Claude's isn't public, so treat exact numbers as approximate.)
glass FILE [args] |
check, then run |
glass check FILE |
report problems; run nothing |
glass test FILE |
run the file's test blocks |
glass sig FILE |
one line per function: what it touches, changes, and whether it can fail |
glass explain FILE |
the program in plain English |
glass trace FILE |
run it, printing every step and every changed value |
glass py FILE |
show the Python that Glass generates |
- Learn Glass in 10 minutes: the tutorial
- AI guide: the page to give your AI
- Language reference: everything, in detail
- Examples: a web API, a to-do app with JSON storage, CSV statistics, parallel work, a bytecode VM, raw memory, and calling C
.glass → parse → analyze (check + infer contracts) → Python → run
Glass is a compiler to Python, written in plain Python with no dependencies (~5k lines in glasslang/). Errors always point at your Glass line, never at the generated Python.
- Python speed. Fine for apps, scripts, servers, and data work (numpy runs at native speed), but not for tight loops of pure number crunching.
- Types are optional. Glass checks the types it can see and the ones you write. That's fewer guarantees than Rust or Go.
- Python libraries are tracked by module, not by function. Glass knows
requestsuses the network, but not exactly which calls do. - Not yet built: editor support (syntax highlighting, language server), a formatter, and a package manager for Glass modules (pip works for Python packages).
glass run Glass without installing (./glass file.glass)
glasslang/ the compiler and runtime; std/ holds modules written in Glass
docs/ LEARN.md (tutorial), AI_GUIDE.md (for AI), SPEC.md (reference)
examples/ example programs
tests/ test suite (python3 tests/run_all.py) and the AI evaluation
bench/ the token comparison against other languages