A high-performance programming language compiler that combines the best of Go's concurrency model with TypeScript's syntax and static typing, generating direct machine code for maximum performance.
- JavaScript/TypeScript Syntax Compatibility: Familiar syntax for web developers
- Static Typing: Optional but powerful type system with automatic type inference
- Goroutines: Lightweight concurrency using thread pools
- Promises & Async/Await: JavaScript-style asynchronous programming
- Tensor Operations: Built-in PyTorch-compatible tensor support
- Direct Machine Code Generation: No intermediate representation for maximum speed
- Dual Backend Support: Both x86-64 and WebAssembly targets
- JIT Compilation: Runtime code generation and optimization
- Type-driven Optimization: Uses static type information for performance
- Zero-cost Abstractions: High-level features compile to efficient machine code
- Memory-optimized Dynamic Code: When types are unknown, trades memory for speed
- Atomic Operations: Thread-safe operations without locks where possible
- SharedArrayBuffer Support: WebAssembly backend uses shared memory
function doSomething(x: int64): int64 {
return x + 42;
}
// Spawn a goroutine
go doSomething(100);
// Await a goroutine result
let result = await go doSomething(200);
// Parallel execution with goMap
let numbers = [1, 2, 3, 4, 5];
let results = await Promise.all(numbers.goMap(doSomething));
// Explicit typing
let x: int64 = 42;
let y: float64 = 3.14;
// Any Type
let z = 100; // standard flexible js variable
var x: [int64] = Array.full([2,4], 5) // 2x4 array of 5
x.shape; // returns [2]
var y = Array.zeros([10, 4, 5]);
var z = y.transpose().matmul(x);
if x == 5
console.log("x is 5")
for let i: int64 = 0; i < 100; ++i
console.log("i is", i)
for let item of list
print item
- Direct assembly generation
- Register allocation optimization
- Function calling conventions
- Memory management
- WASM bytecode generation
- SharedArrayBuffer for goroutines
- Browser compatibility
- Node.js support
int8
,int16
,int32
,int64
uint8
,uint16
,uint32
,uint64
float32
,float64
boolean
,string
tensor
- Types "cast up" to prevent precision loss
float32 * int32
→float64
int64 * float64
→float64
- Automatic casting when safe
- Explicit casting when needed
- Lightweight threads using thread pool
- Automatic scheduling
- Promise-based results
- Exception handling
Promise.all()
for parallel executiongoMap()
for parallel array processingPromise.race()
for competitive execution- Async/await syntax support
make clean && make
./gots_compiler
make all
- Build compilermake debug
- Debug buildmake test
- Run testsmake clean
- Clean build files
- Lexer: Tokenizes source code
- Parser: Builds Abstract Syntax Tree (AST)
- Type Inference: Analyzes and infers types
- Code Generation: Emits machine code directly
- Runtime: Provides goroutine scheduling and memory management
compiler.h/cpp
- Main compiler interfacelexer.cpp
- Tokenizationparser.cpp
- AST constructiontype_inference.cpp
- Type analysisx86_codegen.cpp
- x86-64 code generationwasm_codegen.cpp
- WebAssembly code generationruntime.h/cpp
- Goroutine scheduler and memory managementtensor.h
- Tensor operations
- Direct code generation (no IR)
- Parallel compilation phases
- Incremental compilation support
- Near-C performance for statically typed code
- Optimized dynamic dispatch for untyped code
- Efficient goroutine scheduling
- Lock-free data structures where possible
- Stack-allocated by default
- Shared memory for goroutines
- Garbage collection for dynamic objects
- Memory pooling for frequent allocations
- Libtorch integration
- Add ability to import parse and run Python syntax.