tek-sys-hub/Rubix-lang
概要
The 100% Pure x86-64 Assembly Systems Language
言語・ランタイムできること
- Pure Assembly Compiler: The compiler itself is written completely in GNU x86-64 assembly (src/*.s). No external dependencies or runtime libraries are needed.
- Tiny & Instant: The compiler binary is only ~42 KB, with sub-millisecond compilation times.
- Compiles .ix code into standalone native executables equipped with an adaptive assembly runtime.
- Linux ELF64: Direct Linux kernel syscall dispatch for file I/O, process exit, and 64 KB arena bump allocation.
計測したスター増加
- 24時間
- 0
- 7日間
- -1
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルRubix Programming Language (.ix)
The Ultra-Lightweight x86-64 Systems Programming Language
Zero C. Zero libc. Zero LLVM. A ~42 KB compiler building standalone native binaries in sub-milliseconds.
██████╗ ██╗ ██╗██████╗ ██╗██╗ ██╗
██╔══██╗██║ ██║██╔══██╗██║╚██╗██╔╝
██████╔╝██║ ██║██████╔╝██║ ╚███╔╝
██╔══██╗██║ ██║██╔══██╗██║ ██╔██╗
██║ ██║╚██████╔╝██████╔╝██║██╔╝ ██╗
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝╚═╝ ╚═╝
A sovereign systems programming language whose entire compiler is written in 100% pure x86-64 assembly.
Zero libc. Zero C. Zero LLVM. Zero Virtual Machines. Zero external toolchains.
Produces standalone native executables for Linux ELF64, Windows PE64, macOS Mach-O64, and ARM64 ELF64.
⚡ 10-Second Syntax Preview
struct Point {
x: int,
y: int
}
fn hypot_squared(p: Point): int {
return p.x * p.x + p.y * p.y;
}
fn main() {
print_str("Hello from Rubix!\n");
let pt = Point { x: 3, y: 4 };
let dist = hypot_squared(pt);
print(dist); // Prints: 25
let pi: float = 3.141592;
print(pi * 2.0); // Native SSE2 float math
return 0;
}
🎯 Why Rubix? (vs. C or Zig)
Why choose Rubix over industry standards like C, Zig, or Rust?
- Instant Compilation (< 1 ms): Zero LLVM or Clang optimization overhead. Rubix compiles source code directly into machine code in fractions of a millisecond.
- Ultra-Lightweight (~42 KB Binary): The entire compiler is about 42 KB on disk. While Zig, Rust, and Clang toolchains weigh between 100 MB and 1.5 GB, Rubix runs effortlessly even on a 512 MB Raspberry Pi or a 4 GB RAM laptop.
- 100% Pure Assembly & Total Transparency: The compiler is written in ~3,500 lines of readable GNU x86-64 Intel-syntax assembly. There are no black-box optimizations or thousands of hidden header files.
- True Standalone Executables (Zero Libc): Produced binaries have zero dependency on
libc,musl, or C runtimes. They talk directly to the OS kernel via Linuxsyscall, resolve Windows APIs by walking the PEB in memory, or emit Darwin syscalls for macOS. - Zero External Toolchain: The compiler embeds its own assembler and ELF64/Mach-O writer — no GNU
asorldrequired to produce binaries.
📊 Verify the Benchmarks Yourself
You can verify the sub-millisecond compilation time and tiny binary footprint directly on your machine:
# 1. Verify the tiny compiler binary footprint:
ls -lh rubix_compiler
# (Unstripped: ~64 KB | Stripped: ~49 KB)
# 2. Benchmark compile time on a comprehensive program:
time ./rubix_compiler examples/large_system_test.ix /dev/null
# Output: real 0m0.001s (instant sub-millisecond execution)
# 3. Verify zero external toolchain dependency:
PATH="/nonexistent:$PATH" ./rubixc -r examples/15_floats.ix
📄 The .ix File Format & Identity
Every Rubix program is authored in the sovereign
.ix file format. Designed for pure systems-level performance, .ix source files are converted directly to native machine code by rubix_compiler and orchestrated via the ./rubixc driver. The official .ix file badge reflects Rubix's sharp geometric lineage and uncompromising fidelity to native hardware.
⚡ Highlights
- Pure Assembly Compiler: The compiler itself is written completely in GNU x86-64 assembly (
src/*.s). No external dependencies or runtime libraries are needed. - Tiny & Instant: The compiler binary is only ~42 KB, with sub-millisecond compilation times.
- Zero-Libc Native Runtimes:
- Compiles
.ixcode into standalone native executables equipped with an adaptive assembly runtime. - Linux ELF64: Direct Linux kernel
syscalldispatch for file I/O, process exit, and 64 KB arena bump allocation. - Windows PE64 (
-t windows): Dynamic Process Environment Block (gs:[0x60]) resolver that walkskernel32.dllexport directories without requiring import libraries (.lib) or MinGW. - macOS Mach-O64 (
-t macos): Mach-O segment/section layout with Darwin 64-bit syscall offsets (0x2000000 | sys_id). - ARM64 ELF64 (
-t arm64): AArch64 machine code emission with ELF64 executable format (e_machine = EM_AARCH64). Linux syscall interface (svc #0) with ARM64 calling convention (x0-x7 arguments, x0 return).
- Compiles
- Built-in Toolchain: Embedded assembler and ELF64/Mach-O writer — produces binaries without invoking external
asorld. - Rich Language Features:
forandwhileloops withbreak,continue, and arbitrary nesting- Dynamic heap allocation (
alloc,free) with a high-performance 64 KB arena sub-allocator - Compound
structdeclarations, heap instantiation, and field mutation without name collisions - Full 64-bit IEEE-754 double precision floats (
float) with SSE2 native arithmetic and relational comparisons - Dynamic array indexing (
arr[i] = val) and array literal syntax ([1, 2, 3]) - Runtime array bounds checking — out-of-bounds access traps with
__rubix_bounds_error - First-class function calls with unbounded parameter counts (>6 parameters supported via AMD64 ABI registers + stack spills)
- Multi-file module imports (
import "lib.ix") - BSD Sockets API —
socket,connect,bind,listen,accept,send,recv,setsockopt_reuseaddr,sockaddr_inin pure assembly (zero libc) - Embedded standard library: File I/O, string manipulation, math routines
- Hardware-trapped integer overflow detection (
jo __rubix_overflow_error) - Rust-style compiler error diagnostics with source code snippets and caret pointers (
^)
- Self-Hosting: The bootstrap compiler in
rubixc_bootstrap/is written in native Rubix (.ix) and reaches a fixed point (Stage 2 output == Stage 3 output).
🏗️ Compiler Architecture
+-----------------------------------+
| Rubix Source Code (.ix) |
+-----------------------------------+
│
▼
+---------------------------------------------------------------------------------+
| rubix_compiler |
| |
| [Lexer (src/lexer.s)] |
| • Tokenizer converting source buffers into structured 32-byte token records |
| │ |
| ▼ |
| [Parser (src/parser.s)] |
| • Recursive descent parser with Pratt-style operator precedence |
| • Handles scopes, statements, expressions, control flow, loops & imports |
| • Runtime array bounds checks & BSD sockets builtins |
| │ |
| ▼ |
| [Symbol Table (src/symtab.s)] |
| • Lexical block scoping (up to 64 depth) and stack offset calculation |
| • Variable redeclaration guards and symbol lookup |
| │ |
| ▼ |
| [Code Generator (src/codegen.s)] |
| • Emits native x86-64 GNU assembly (.intel_syntax noprefix) |
| • Generates .rodata string literals & links embedded assembly runtime |
| [ELF64/Mach-O Writer (src/elf.s)] |
| • Direct binary emission — no external as or ld required |
| [Built-in Assembler (src/builtin_as.s)] |
| • Two-pass text assembler embedded in the compiler |
+---------------------------------------------------------------------------------+
│
▼
+-----------------------------------+
| Universal Native Executable |
| (Direct Syscalls / No C / No VM) |
+-----------------------------------+
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
[Host: Linux] [Host: Windows] [Host: macOS]
Direct Linux Dynamic kernel32 Direct Darwin
Syscalls PEB Export Resolver Syscalls
📁 Repository Layout
project 2.0/
├── Makefile # Compiler build automation
├── rubixc # User-friendly compiler & runner script
├── test.sh # Complete 24-test verification suite
├── src/ # 100% Pure x86-64 Assembly Source Code
│ ├── main.s # Entry point (_start), command line parser, file pipeline
│ ├── constants.s # Linux syscall numbers, token types, buffer capacity limits
│ ├── strings.s # String length, compare, copy, and integer conversion routines
│ ├── io.s # Raw kernel file I/O & Rust-style diagnostic error reporting
│ ├── lexer.s # Tokenizer & scanner (keywords, identifiers, literals, operators)
│ ├── symtab.s # Lexical scope stack, symbol table buffer, and stack offsets
│ ├── codegen.s # Instruction emitters, rodata manager, and standard library runtime
│ ├── elf.s # ELF64 & Mach-O binary writer (built-in linker)
│ ├── builtin_as.s # Two-pass text assembler (built-in assembler)
│ └── parser.s # Recursive-descent parser, operator precedence, and loop frames
├── lib/ # Runtime Library (Pure Assembly)
│ └── runtime.s # Syscalls, print, math, memory, sockets, string routines
└── examples/ # Test & Demonstration Programs
├── 01_hello.ix # Hello World string literal output
├── 02_arithmetic.ix # Expressions, operator precedence, and variables
├── 03_control_flow.ix# While loops, if-else chains, and reassignments
├── 04_functions.ix # Multi-parameter functions and recursive Fibonacci
├── 05_prime_numbers.ix# Prime number sieve demonstrating nested logic
├── 06_arrays.ix # Dynamic heap allocation, indexing, and array literals
├── 07_types_and_logic.ix # Booleans, chars, logical operators (&&, ||, !), optional types
├── 08_many_params.ix # Unbounded 8-parameter function caller/callee stack passing
├── 09_modules.ix # Multi-file module import system
├── 10_safe_math.ix # Hardware integer overflow detection trap
├── 11_for_loops.ix # Complete for loops (break, continue, nesting, dynamic arrays)
├── 12_stdlib.ix # Embedded stdlib (File I/O, string manipulation, math routines)
├── 15_floats.ix # Float/Double f64 arithmetic, conversions, and print_float
├── 16_structs.ix # Struct declarations, literals, field access and mutation
├── 17_native_floats.ix # True Type Propagation & SSE2 Native Operators
├── 18_compiler_fixes.ix# Struct scoping, SSE2 float comparisons, assignment typing
├── 19_http_server.ix # Minimal Pure-Assembly HTTP/1.1 Server (BSD sockets)
├── 20_bounds_check.ix# Length-Prefixed Array & Runtime Bounds Verification
├── large_system_test.ix # 200-element Quicksort, 4x4 matrix multiplication, and multi-file math
├── comprehensive_large_test.ix # Grand stress test: 1,000-element Sieve, binary search, prefix sums
└── rubixc_bootstrap/ # Self-hosting compiler written in native Rubix (.ix)
├── main.ix # Bootstrap compiler entry point
├── lexer.ix # Bootstrap lexer
├── tokens.ix # Bootstrap token types
├── parser.ix # Bootstrap parser
├── codegen.ix # Bootstrap code generator
└── symtab.ix # Bootstrap symbol table
📖 Language Syntax & Capabilities
1. Variables & Basic Types
Rubix is statically typed with 64-bit integer primitives (int, bool, char). Type annotations are optional:
let count = 10; # Inferred 64-bit int
let flag: bool = true; # Explicit bool
let symbol: char = 'R'; # Character literal
2. Operators & Safe Arithmetic
Supports full precedence: (), !, - (unary), *, /, %, +, -, <, <=, >, >=, ==, !=, &&, ||.
All arithmetic operations detect hardware overflow and terminate safely:
let x = (10 + 5) * 2 - 4 / 2; # Precedence respected
let valid = (x > 10) && (!flag || x < 100);
3. For & While Loops with break and continue
for loops support <init>; <cond>; <step>, empty clauses, nested loops with isolated stack frames, and control jumps:
for (let i = 0; i < 20; i = i + 1) {
if (i >= 15) {
break; # Exits loop early
}
if (i % 2 == 0) {
continue; # Skips to step clause (i = i + 1)
}
print(i); # Prints 1, 3, 5, 7, 9, 11, 13
}
4. Dynamic Heap Memory & Arrays
Direct interaction with the Linux memory manager via alloc and free (mmap/munmap). Arrays are length-prefixed (8-byte header) with runtime bounds checking:
# Dynamic array allocation with bounds checking
let size = 100;
let arr = alloc(size * 8);
for (let i = 0; i < size; i = i + 1) {
arr[i] = i * i;
}
print(arr[9]); # Prints 81
print(arr[100]); # TRAPS: "Rubix Runtime Error: index out of bounds"
free(arr, size * 8);
# Array literal initialization
let primes = [2, 3, 5, 7, 11, 13, 17];
print(primes[4]); # Prints 11
5. Functions & Unbounded Parameters
Functions adhere to the AMD64 System V ABI. When more than 6 arguments are supplied, additional arguments are seamlessly spilled and retrieved from the stack frame:
fn compute_sum(a: int, b: int, c: int, d: int, e: int, f: int, g: int, h: int): int {
return a + b + c + d + e + f + g + h;
}
fn main(): int {
let sum = compute_sum(1, 2, 3, 4, 5, 6, 7, 8);
print(sum); # Prints 36
return 0;
}
6. Multi-File Module System
Split code across multiple files with automatic cycle prevention and deduplication:
import "examples/math_lib.ix";
fn main(): int {
let result = compute_cube(5);
print(result); # Prints 125
return 0;
}
7. BSD Sockets API (Pure Assembly, Zero libc)
Rubix includes built-in socket primitives for network services without linking libc:
# Create TCP socket
let srv_fd: int = socket(2, 1, 0); # AF_INET=2, SOCK_STREAM=1, TCP=0
# Bind and listen
let addr: int = sockaddr_in(8080, 2130706433); # 127.0.0.1:8080
bind(srv_fd, addr, 16);
listen(srv_fd, 16);
# Accept and communicate
let client_fd: int = accept(srv_fd, 0, 0);
recv(client_fd, buf, 2047, 0);
send(client_fd, response, resp_len, 0);
file_close(client_fd);
8. Embedded Standard Library Reference
Every Rubix binary includes a built-in standard library with zero external runtime requirements:
| Module | Function | Description |
|---|---|---|
| I/O | print(val) |
Prints a 64-bit signed integer followed by a newline |
print_str(expr) |
Prints a static or dynamic null-terminated string | |
print_char(c) |
Prints a single ASCII character | |
print_float(val) |
Prints a 64-bit float with 6 decimal places | |
| File I/O | file_open(path, flags, mode) |
Calls Linux sys_open (syscall 2) |
file_read(fd, buf, count) |
Calls Linux sys_read (syscall 0) |
|
file_write(fd, buf, count) |
Calls Linux sys_write (syscall 1) |
|
file_close(fd) |
Calls Linux sys_close (syscall 3) |
|
| Strings | str_len(s) |
Returns length of null-terminated string |
str_cmp(s1, s2) |
Compares strings (0 if equal) |
|
str_copy(dst, src) |
Copies source string into destination buffer | |
str_cat(dst, src) |
Concatenates source onto destination buffer | |
puts(s) |
Writes null-terminated string to stdout | |
| Math | math_abs(x) |
Absolute value |
math_min(a, b) |
Minimum of two integers | |
math_max(a, b) |
Maximum of two integers | |
math_pow(base, exp) |
Integer exponentiation ($base^{exp}$) | |
math_sqrt(n) |
Integer square root ($\lfloor\sqrt{n}\rfloor$) | |
| Memory | alloc(bytes) |
Allocates memory via sys_mmap (syscall 9) |
free(ptr, bytes) |
Releases memory via sys_munmap (syscall 11) |
|
| Sockets | socket(domain, type, protocol) |
Creates a network socket (syscall 41) |
connect(fd, addr, addrlen) |
Connects to a remote address (syscall 42) | |
bind(fd, addr, addrlen) |
Binds socket to local address (syscall 49) | |
listen(fd, backlog) |
Listens for incoming connections (syscall 50) | |
accept(fd, addr, addrlen) |
Accepts an incoming connection (syscall 43) | |
send(fd, buf, len, flags) |
Sends data over socket (syscall 44) | |
recv(fd, buf, len, flags) |
Receives data from socket (syscall 45) | |
setsockopt_reuseaddr(fd) |
Sets SO_REUSEADDR on socket | |
sockaddr_in(port, ip) |
Builds a 16-byte sockaddr_in struct | |
| Process | argc() |
Returns command-line argument count |
argv() |
Returns command-line argument vector |
9. Universal Multi-OS Architecture (Linux, Windows, macOS)
Rubix binaries break the operating system barrier by incorporating an adaptive native runtime:
- Multi-OS Entry Points: Defines
_start,_start_linux,_start_windows, and_start_macos. The host kernel's loader jumps directly to its corresponding entry vector. - Dynamic Host OS Detection: Automatically sets
rubix_host_os(1 = Linux, 2 = Windows, 3 = macOS). - Universal System Dispatchers:
__rubix_sys_write: Linuxsys_write/ WindowsWriteFile/ macOS0x2000004__rubix_sys_read: Linuxsys_read/ WindowsReadFile/ macOS0x2000003__rubix_sys_open: Linuxsys_open/ macOS0x2000005__rubix_sys_close: Linuxsys_close/ macOS0x2000006__rubix_sys_mmap: Linuxsys_mmap/ WindowsVirtualAlloc/ macOS0x20000c5__rubix_sys_munmap: Linuxsys_munmap/ WindowsVirtualFree/ macOS0x2000049__rubix_sys_exit: Linuxsys_exit/ WindowsExitProcess/ macOS0x2000001
- Windows PEB / kernel32 Dynamic Resolver: On Windows x64, dynamically walks the Process Environment Block (
gs:[0x60]), locateskernel32.dll, and resolves API exports without relying on external DLL import tables.
[!NOTE] Platform & Cross-Compilation: Rubix natively targets Linux ELF64, Windows PE64 (
.exe), and macOS Mach-O64 directly from its built-in binary writer without externalasorld.
💎 Advanced Systems Capabilities
1. Floating-Point Numbers (f64 / Double Precision) & Type System
Full IEEE-754 64-bit double-precision support with type-aware symbol table resolution, native SSE2 machine code emission (addsd, subsd, mulsd, divsd), and polymorphic print():
let pi: float = 3.141592;
let rad: float = 2.5;
// Native SSE2 arithmetic (+, -, *, /) and mixed int-float operations
let area = pi * rad * rad;
print(area); // 19.634950 (automatically dispatches to float formatting)
// Typed function parameters and return types
fn hypot(a: float, b: float): float {
return a * a + b * b;
}
Built-in math routines (float_add, float_sub, float_mul, float_div, float_to_int, int_to_float, print_float) remain fully available for backwards compatibility.
2. Struct Declarations & Dynamic Instances
User-defined compound data structures with compile-time offset layout, heap instantiation, and member access/mutation:
struct Vector3 {
x: int,
y: int,
z: int
}
fn main() {
let v = Vector3 { x: 10, y: 20, z: 30 };
print(v.x);
v.z = v.x + v.y;
print(v.z); // 30
free(v, 24);
return 0;
}
3. DWARF Debug Information (gdb / lldb)
The compiler generates native DWARF .file and .loc debug directives mapping machine instructions directly back to .ix source lines:
./rubixc -g examples/01_hello.ix -o hello_dbg
gdb ./hello_dbg
# (gdb) break 3
# (gdb) run
# Breakpoint 1, main () at examples/01_hello.ix:3
4. Cross-OS Compilation (Windows PE64 & macOS Mach-O64 & ARM64 ELF64)
Produce real 64-bit executables directly on Linux:
# Windows PE64
./rubixc -t windows examples/01_hello.ix -o hello.exe
file hello.exe
# hello.exe: PE32+ executable for MS Windows 5.02 (console), x86-64
# macOS Mach-O64
./rubixc -t macos examples/01_hello.ix -o hello_mac
file hello_mac
# hello_mac: Mach-O 64-bit x86_64 executable
# ARM64 ELF64
./rubixc -t arm64 examples/01_hello.ix -o hello_arm64
file hello_arm64
# hello_arm64: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV)
5. Separate Compilation & Static Object Linking
Compile individual .ix files into ELF relocatable objects (.o) and link multiple units:
./rubixc -c module1.ix -o module1.o
./rubixc -c module2.ix -o module2.o
./rubixc module1.o module2.o -o my_app
6. Zero-External-Toolchain Build
Compile and run without GNU as or ld installed (the compiler embeds its own assembler and ELF64 writer):
# Block external as/ld to prove they aren't needed
PATH="/nonexistent:$PATH" ./rubixc -r examples/15_floats.ix
🛠️ Rich Diagnostic Error Reporting
Rubix produces clear, informative compile-time diagnostics pointing directly to the offending token:
Rubix Compiler Error: Expected expression
--> line 4
|
4 | let x = ;
| ^
🚀 Quickstart & Usage
Prerequisites
- Linux OS (x86-64)
- No external tools required — the compiler includes its own assembler and binary writer
1. Build the Compiler (or Download Prebuilt)
make clean && make
Produces rubix_compiler (the standalone ~42 KB binary).
[!TIP] Prebuilt Binaries: If you don't want to build from source, standalone prebuilt binaries for Linux x86-64 are available on the GitHub Releases page.
2. Compile and Run a Program
Use the ./rubixc compiler driver:
# Compile and immediately run
./rubixc -r examples/15_floats.ix
./rubixc -r examples/16_structs.ix
./rubixc -r examples/17_native_floats.ix
./rubixc -r examples/18_compiler_fixes.ix
# BSD sockets HTTP server self-test
./rubixc -r examples/19_http_server.ix -- --self-test
# Array bounds checking test
./rubixc -r examples/20_bounds_check.ix
# Compile for Windows PE64
./rubixc -t windows examples/01_hello.ix -o hello.exe
# Compile for macOS Mach-O64
./rubixc -t macos examples/01_hello.ix -o hello_mac
# Compile for ARM64 ELF64
./rubixc -t arm64 examples/01_hello.ix -o hello_arm64
# Compile with DWARF debug info
./rubixc -g examples/01_hello.ix -o hello_dbg
# Compile to object file only
./rubixc -c module.ix -o module.o
3. Run the Entire Test Suite
./test.sh
Executes all 24 test suites verifying the compiler build, arithmetic, control flow, functions, prime algorithms, dynamic arrays, modules, loops, standard library, floats, structs, native float SSE2 operators, compiler bug fixes, BSD sockets HTTP server, array bounds checking, multi-target compilation (Windows PE64 / macOS Mach-O64 / ELF64 object), zero-binutils toolchain independence, and self-hosting fixed point.
🔄 Self-Hosting & Compiler Status
- Primary Production Compiler (
src/*.s):
Implemented in ~3,500 lines of pure GNU x86-64 assembly. This is the official, complete compiler that powers Rubix and passes all 24 test suites. - Bootstrap Self-Hosting Compiler (
rubixc_bootstrap/):
Written in native Rubix (.ix). Achieves the self-hosting milestone: Stage 2 output is byte-identical to Stage 3 output (fixed point). Run./test.shtest #24 to verify.
📜 License
Created with precision in pure x86-64 Assembly. Free and open source under the MIT License.
関連プロジェクトを探す
読み込み中…