goplus/xgo
XGo is a programming language that reads like plain English. But it's also incredibly powerful — it lets you leverage assets from C/C++, Go, Python, and JavaScript/TypeScript, creating a unified software engineering ecosystem. Our vision is to enable everyone to become a builder of the world.
XGo (goplus/xgo)
XGo is a programming language designed to read like plain English while still being powerful enough for real engineering work. Its stated goal is to let one language work across C/C++, Go, Python, and JavaScript/TypeScript ecosystems, summarized by the project's own formula: XGo := C * Go * Python * JavaScript + Scratch.
What It Is
- A new programming language that is fully compatible with Go — you can mix Go and XGo code in the same package.
- Simplified syntax: it removes boilerplate (e.g., you can omit
package mainandfunc main) and replaces function-call style with command style:echo "Hello world"instead offmt.Println("Hello world"). - A smaller syntax set than Go or Python, yet still Turing-complete.
- A bridge to other languages: through the LLGo compiler (based on LLVM), XGo can import C/C++ and Python libraries directly.
Key Features
| Feature | What it means in practice |
|---|---|
| Natural-language-like expressions | Code reads closer to English; fewer parentheses and symbols |
| Go compatibility | Existing Go code works; Go and XGo can coexist in one package |
| C/C++/Python integration | Via the -llgo flag, you can call C's printf or Python's print directly |
| Classfiles | A way to express domain-specific patterns without creating a new language (SDF, not DSL) |
| Simplified data structures | Lists use [1, 2, 3], maps use {...}, appending uses a <- 4 |
| Keyword arguments | Python-like play "1.mp3", loop = true |
| Simplified enums and structs | Less verbose type declarations |
How It Works
XGo sits on top of Go compilers. It currently defaults to the official Go compiler, but the project plans to default to LLGo in the future. LLGo is a Go compiler built on LLVM that enables the C/C++/Python integration.
To use LLGo, you initialize a module with:
xgo mod init -llgo YourModulePath
Then you can write code like:
import "c"
c.printf c"Hello world\n"
or
import "py/std"
std.print py"Hello world"
Classfiles and Frameworks
XGo deliberately avoids Domain-Specific Languages (DSLs) but supports "Specific Domain Friendliness" (SDF) through classfiles — files with custom suffixes that bundle domain knowledge. Examples:
- yap (
.yapfiles): a web framework where filenames define routes. A file namedget.yapserves the GET/route;get_p_#id.yapservesget /p/:id. - spx (
.spxfiles): a Scratch-compatible 2D game engine for STEM education, with event-driven code likeonStart => { ... }. - gsh (
.gshfiles): lets you write shell scripts in XGo, supporting all shell commands. - cobra: a CLI framework.
- mcp: an implementation of the Model Context Protocol for AI programming.
Installation
Requires Go 1.19 or later. Available via:
- Windows:
winget install goplus.xgo - Debian/Ubuntu: apt repository
- RedHat/CentOS/Fedora: yum repository
- macOS/Linux:
brew install xgo - From source: clone the repo and run
all.bash(mac/linux) orall.bat(Windows)
Example Code Comparison
| Go | XGo |
|---|---|
fmt.Println("Hi") |
echo "Hi" |
a := []int{1, 2, 3} |
a := [1, 2, 3] |
a = append(a, 4) |
a <- 4 |
map[string]int{"Monday": 1} |
{"Monday": 1} |
OnStart(func() { ... }) |
onStart => { ... } |
Play("1.mp3", &Options{Loop: true}) |
play "1.mp3", loop = true |
Target Users
- Engineering: a simple language children can master
- STEM education: an engineering language that remains useful later
- Data science: a shared language for communicating with engineers
Ecosystem
- Games: spx, Aircraft War, Flappy Bird, Maze Play, Gobang, Dinosaur
- Web: yap, yaptest, ydb (database framework)
- DevOps: gsh
- Data processing: hdq (HTML DOM query language)
- IDE: Visual Studio Code extension "Go/XGo"
Project Status
The README positions XGo as a project that welcomes contributors, with documentation on compiler design and tooling conventions. It also requests stars from users who find it useful.
Related
- Dispatch
- Project
- Project
- Project
- Project