Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

粋 (Sui) - A programming language optimized for LLM code generation

License

NotificationsYou must be signed in to change notification settings

TakatoHonda/sui-lang

Repository files navigation

Zero syntax errors. Zero typos. LLMs generate code that just works.

日本語版 README

Try it Now

No installation required - try Sui directly in your browser:

Overview

Sui (粋) is a programming language named after the Japanese aesthetic concept meaning "refined" and "elimination of excess." It is designed so that LLMs can generate100% accurate code - not through hope, but through structural guarantees.

Why Sui?

Current LLM code generation problems:

  • Bracket mismatchesif (x { }
  • Variable typoscoutn vscount
  • Indentation errors
  • Complex nested expressions

Sui makes these errors structurally impossible:

ProblemSui's Solution
Bracket mismatchOnly{} for functions, no nesting
Variable typosSequential numbers only (v0, v1, g0) - can't misspell
Indentation errorsLine-based, indentation is ignored
Complex nestingOne instruction per line, decompose to temps

Design Principles

  1. Zero Syntax Error Rate - Structurally impossible to make syntax errors
  2. Zero Typo Rate - Variables are numbers, not names
  3. Line Independence - Each line is completely self-contained
  4. Pure Logic Language - Computation only; UI delegated to any framework
  5. Future-Proof Efficiency - As LLMs learn Sui, token efficiency will surpass traditional languages

Installation

# PyPI (basic)pip install sui-lang# PyPI with WebAssembly supportpip install sui-lang[wasm]# Homebrew (macOS/Linux)brew tap TakatoHonda/suibrew install sui-lang# From sourcegit clone https://github.com/TakatoHonda/sui-lang.gitcd sui-lang

Quick Start

Interactive Mode (REPL)

# Start REPLsui# Example session>>> = v0 10>>> + v1 v0 5>>>. v1>>>15>>> .exit

Commands:.exit /.quit (exit),.reset (reset state)

Interpreter

# Run filesui examples/fibonacci.sui# Run with argumentssui examples/fib_args.sui 15# Validatesui --validate examples/fibonacci.sui# Show helpsui --help

Transpiler (Sui → Python)

# Show converted codesui2py examples/fibonacci.sui# Output to filesui2py examples/fibonacci.sui -o fib.py# Convert and executesui2py examples/fib_args.sui --run 15

Transpiler (Python → Sui) for humans

# Show converted codepy2sui your_code.py# Output to filepy2sui your_code.py -o output.sui

WebAssembly

# Compile to WebAssembly binary (requires: brew install wabt)sui2wasm examples/fibonacci.sui -o fib.wasm# Execute directly via WebAssembly (requires: pip install sui-lang[wasm])suiwasm examples/fibonacci.sui

Browser UI

Sui is apure logic language. UI can be implemented with any framework (React, Vue, Hono.js, vanilla JS, etc).

Sui compiles to Wasm with exports:

  • main() - Initialization
  • f0(),f1(), ... - Functions (callable from JS)
  • g0,g1, ... - Global variables (read/write via.value)
// Any framework worksconstwasm=awaitWebAssembly.instantiate(wasmBytes,{env:{print_i32:console.log}});button.onclick=()=>{wasm.exports.f0();display.textContent=wasm.exports.g0.value;};

Running without Installation (from source)

# Using python directlypython sui.py examples/fibonacci.suipython sui2py.py examples/fibonacci.suipython py2sui.py your_code.py

Syntax

Instructions

InstrFormatDescription
== var valueAssignment
++ result a bAddition
-- result a bSubtraction
** result a bMultiplication
// result a bDivision
%% result a bModulo
<< result a bLess than (0/1)
>> result a bGreater than (0/1)
~~ result a bEquality (0/1)
!! result aNOT
&& result a bAND
|| result a bOR
?? cond labelConditional jump
@@ labelUnconditional jump
:: labelLabel definition
## id argc {Function definition start
}}Function definition end
$$ result func args...Function call
^^ valueReturn
[[ var sizeArray create
]] result arr idxArray read
{{ arr idx valueArray write
.. valueOutput
,, varInput

Variables

FormatMeaning
v0,v1, ...Local variables
g0,g1, ...Global variables
a0,a1, ...Function arguments
c0argc (command-line argument count)
c1,c2, ...argv (command-line arguments, read-only)

Examples

Fibonacci

# 0 1 {< v0 a0 2! v1 v0? v1 1^ a0: 1- v2 a0 1$ v3 0 v2- v4 a0 2$ v5 0 v4+ v6 v3 v5^ v6}= g0 10$ g1 0 g0. g1

Output:55

FizzBuzz

= v0 1: 0> v1 v0 100? v1 9% v2 v0 15~ v3 v2 0? v3 1% v4 v0 3~ v5 v4 0? v5 2% v6 v0 5~ v7 v6 0? v7 3. v0@ 4: 1. "FizzBuzz"@ 4: 2. "Fizz"@ 4: 3. "Buzz"@ 4: 4+ v0 v0 1@ 0: 9

File Structure

sui/├── README.md           # This file (English)├── README_ja.md        # Japanese README├── LICENSE             # MIT License├── sui.py              # Interpreter├── sui2py.py           # Sui → Python transpiler├── sui2wasm.py         # Sui → WebAssembly binary compiler├── suiwasm.py          # WebAssembly runtime (execute via wasmtime)├── py2sui.py           # Python → Sui transpiler (for humans)├── examples/│   ├── fibonacci.sui│   ├── fib_args.sui│   ├── fizzbuzz.sui│   ├── list_sum.sui│   ├── args_demo.sui│   └── counter_app/      # Full app example (Sui + Wasm + HTML)└── prompts/    ├── system_prompt_en.md  # LLM system prompt (English)    ├── system_prompt_ja.md  # LLM system prompt (Japanese)    └── examples.md          # Application examples (Sui + UI)

LLM Integration

Sui is designed for LLM code generation. Use the prompts inprompts/ directory:

  1. Copy the system prompt fromprompts/system_prompt_en.md
  2. Paste it into ChatGPT / Claude / Gemini / etc.
  3. Ask to generate Sui code for your task
  4. Run withsui your_code.sui

Seeprompts/examples.md for prompt templates and expected outputs.

Name Origin

Sui (粋) - A Japanese word meaning "refined," "sophisticated," or "the essence." It represents the aesthetic of eliminating excess and keeping only what is essential.

Token Efficiency: Now vs Future

Current state (LLMs don't know Sui yet):

LanguageFibonacciCounter
Sui79 tokens44 tokens
Python30 tokens30 tokens

Future state (after LLMs learn Sui):

  • v0,g0 → 1 token each (currently 2)
  • Patterns like+ g0 g0 1 → compressed
  • Estimated:40-50% reduction

But token count isn't the point. The real value:

  • 0% syntax error rate (vs ~5-10% for Python/JS)
  • 0% typo rate (variables can't be misspelled)
  • 100% parseable output (every line is valid or clearly invalid)

vs Other Languages

vs Python/JavaScript

AspectPython/JSSui
Syntax errorsCommonImpossible
Variable typosCommonImpossible
Bracket matchingError-proneTrivial
Token efficiency (now)BetterWorse
Token efficiency (future)SameBetter

vs Assembly

AspectAssemblySui
InstructionsHundreds~20
Registers8-32Unlimited
Learning curveSteepMinimal

Roadmap

  • Interpreter (Python)
  • Transpiler (Sui → Python)
  • Transpiler (Python → Sui, for humans)
  • Interactive mode (REPL)
  • WebAssembly output (WAT + runtime)
  • Package manager (hash-based IDs) (#9)
  • Standard packages: sui-math, sui-crypto (#8)
  • Type annotations (optional)
  • LLVM IR output

Future: Standard Packages

Mathematical and utility functions will be provided asstandard packages (not built-in):

; sui-math package (48-bit hash ID)X 182947362847591 0 v2 v0 v1   ; matmul(v0, v1) → v2X 182947362847591 1 v3 v0      ; transpose(v0) → v3X 182947362847591 10 v4 v0     ; mean(v0) → v4X 182947362847591 11 v5 v0     ; std(v0) → v5; sui-crypto packageX 56284719384756 0 v6 v0       ; sha256(v0) → v6

Design principles maintained:

  • No identifiers (package/function IDs are numeric)
  • Consistent with package manager design (#9)
  • Core language stays minimal

SeeIssue #8 (sui-math) andIssue #9 (package manager) for details.

License

MIT License

About

粋 (Sui) - A programming language optimized for LLM code generation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp