Targets
Targets Overview
Which backends exist, how target selection works, and how the emitters differ.
GSET ships five working backends — go, python, javascript, java, ruby — plus config stubs for future targets.
How the target is chosen
Two rules:
- File extension picks the default —
foo.pydefaults to Python,foo.jsto JavaScript,foo.gset/unknown to Go. --targetalways wins — it overrides the extension default.
| Flag | Values |
|---|---|
--target | go, python, js/javascript, java, ruby |
Unknown targets are rejected with a clear message. Emitted temp files use the extension map: .go, .py, .js, .java, .rb.
Backend table
| Target | Status | run needs installed | Notes |
|---|---|---|---|
| Python | Implemented | python3 | Most faithful subset coverage |
| JavaScript | Implemented | node | console.log, const, arrow lambdas |
| Go | Implemented | go | Default IR, func main() wrapper, needs typed values |
| Java | Implemented | java + javac | Writes Main.java, one class per file |
| Ruby | Implemented | ruby | puts, begin/rescue/ensure |
| C, C++, C#, Rust, PHP, Swift, Kotlin, TypeScript | Planned | — | Config stubs exist, no emitter yet |
What a "working backend" means
gset run foo.gset --target python does four things, all verified:
- Parses your GSET source.
- Emits a complete, runnable file — wrapper (
package main,class Main, shebang-free script) included. - Writes it to a location the target runtime expects.
- Executes the target's compiler/interpreter and streams output.
gset transpile does steps 1–2 and prints the file to stdout, or -o file saves it.
The five outputs of one program
var name = "World"
print("Hello, " + name)| Target | Generated |
|---|---|
--target go | package main / import "fmt" / func main() / fmt.Println("Hello, " + name) |
--target python | name = "World" / print("Hello, " + name) |
--target javascript | let name = "World"; / console.log("Hello, " + name) |
--target java | public class Main { / String name = "World"; / System.out.println(...) |
--target ruby | name = "World" / puts("Hello, " + name) |
Comparing targets
Each target page documents the same three things:
- What runs cleanly — the verified subset for that runtime.
- What compiles but behaves differently — e.g. Go's array printing format, Python floordiv differences.
- What doesn't compile yet — e.g.
tryon Go, methods on Ruby.
Pick your target by asking "what must genuinely run at the end?" — Python/JS are the safest for dynamically-typed GSET; Go/Java require typed annotations; Ruby is a near-Python port with puts.