TypeScript/JavaScript to Native Code Compiler via LLVM
Nova compiles TypeScript and JavaScript directly to native code through a multi-stage compilation pipeline:
TypeScript/JavaScript → AST → HIR → MIR → LLVM IR → Native Code
Key Highlights:
- ⚡ 5-10x faster SQLite than Node.js better-sqlite3
- 🚀 Native performance via LLVM optimization
- 📦 npm-compatible package manager built-in
- 🔧 Node.js API compatible - 40+ built-in modules
- 💾 Low memory usage - 30-50% less than Node.js
- ✅ Expectation-based test gate - 57 verified conformance tests; legacy tests are being migrated
curl -fsSL https://raw.githubusercontent.com/d-osc/Nova/master/scripts/install.sh | bashpowershell -c "irm https://raw.githubusercontent.com/d-osc/Nova/master/scripts/install.ps1 | iex"# Run TypeScript directly
nova run app.ts
# Compile to native binary
nova build app.ts -o app
# Use the package manager
nova pm install lodash- Variables:
let,const,varwith proper scoping - Functions: Declarations, parameters, return values, recursion
- Arrow Functions:
(a, b) => a + b, implicit/explicit return - Classes: Properties, methods, constructors, inheritance, static members, getters/setters
- Control Flow: if/else, switch/case, ternary operator
- Loops: for, while, do-while, for-of, for-in, break/continue with labels
- Error Handling: try/catch/finally, throw, Error types
- Operators: Verified numeric arithmetic plus JavaScript truthiness, short-circuiting, and operand-return behavior for
&&/||; broader coercion conformance is ongoing
| Category | Methods/Features |
|---|---|
| Array | push, pop, shift, unshift, slice, splice, concat, indexOf, includes, find, filter, map, reduce, forEach, sort, reverse, join, every, some, flat, flatMap, at, with, toReversed, toSorted, toSpliced, fill, copyWithin, findIndex, findLast, findLastIndex, lastIndexOf, reduceRight, Array.from, Array.of, Array.isArray |
| String | length, charAt, charCodeAt, indexOf, lastIndexOf, includes, substring, slice, split, concat, repeat, trim, trimStart, trimEnd, toLowerCase, toUpperCase, padStart, padEnd, replace, replaceAll, at, match, localeCompare, String.fromCharCode, String.fromCodePoint |
| Number | toString, toFixed, toExponential, toPrecision, valueOf, Number.isNaN, Number.isFinite, Number.isInteger, Number.isSafeInteger, Number.parseInt, Number.parseFloat, Number.MAX_VALUE, Number.MIN_VALUE, Number.EPSILON, etc. |
| Math | Standard constants and the core floating numeric path are verified; method-by-method conformance migration is ongoing |
| Object | Verified static-literal subset: keys/values/entries, literal-array fromEntries, attribute-aware existing-field assign/defineProperty, hasOwn, computed string reads/writes, integrity state, reflection names/data descriptors, and Object.is SameValue/identity |
| JSON | stringify, parse |
| Console | log, error, warn, info, debug, trace, dir, table, time, timeEnd, count, clear, group, groupEnd |
| TypedArray | Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array with full method support |
| RegExp | test, exec, match (basic support) |
| Promise | resolve, reject, then (basic support) |
| Date | Date.now() |
| Global | parseInt, parseFloat, isNaN, isFinite, encodeURI, decodeURI, encodeURIComponent, decodeURIComponent, btoa, atob |
- Async/Await: async functions, await expressions
- Generators: function*, yield, yield*
- Async Generators: async function*, for-await-of
- Destructuring: Nested array/object declarations and assignments, lazy defaults, rest bindings, and destructured function/arrow parameters are conformance-verified
- Closures: Shared primitive/object binding mutation, escaped object lifetime, returned and local function/arrow closures, transitive nested environments, declared-parameter
argumentswith lexical arrow capture, local and escaped arrow lexicalthis, and captured Promise-executor writes are conformance-verified - Function invocation: Named-function argument forwarding through
call, literal-arrayapply, partialbind(including bind-time value capture), and primitive ordinary-functionthisArgforwarding are conformance-verified - Spread Operator:
...array,...object - Rest Parameters:
function(...args) - Default Parameters:
function(x = 10) - Template Literals:
`Hello ${name}!` - Optional Chaining:
obj?.prop?.method?.() - Nullish Coalescing:
value ?? default - typeof Operator: Runtime type checking
- instanceof Operator: Type checking
- in Operator: Property existence check
- delete Operator: Property deletion
- Enums: Basic enum support
- using/DisposableStack: Resource management
Nova provides extensive Node.js-compatible built-in modules:
| Module | Status | Description |
|---|---|---|
nova:fs |
✅ Full | File system operations (sync/async) |
nova:path |
✅ Full | Path manipulation utilities |
nova:os |
✅ Full | Operating system information |
nova:crypto |
✅ Full | Cryptographic functions |
nova:buffer |
✅ Full | Buffer manipulation |
nova:stream |
✅ Full | Stream operations |
nova:events |
✅ Full | Event emitter |
nova:http |
✅ Full | HTTP server/client |
nova:https |
✅ Full | HTTPS support |
nova:http2 |
✅ Full | HTTP/2 protocol |
nova:net |
✅ Full | TCP/UDP networking |
nova:tls |
✅ Full | TLS/SSL support |
nova:dns |
✅ Full | DNS lookup |
nova:dgram |
✅ Full | UDP datagram sockets |
nova:child_process |
✅ Full | Process spawning |
nova:worker_threads |
✅ Full | Multi-threading |
nova:cluster |
✅ Full | Cluster management |
nova:zlib |
✅ Full | Compression |
nova:sqlite |
✅ Ultra-Fast | SQLite database (5-10x faster than Node.js) |
nova:util |
✅ Full | Utility functions |
nova:url |
✅ Full | URL parsing |
nova:querystring |
✅ Full | Query string handling |
nova:readline |
✅ Full | Interactive I/O |
nova:assert |
✅ Full | Assertion testing |
nova:test |
✅ Full | Test runner |
nova:vm |
✅ Full | VM context |
nova:async_hooks |
✅ Full | Async context tracking |
nova:perf_hooks |
✅ Full | Performance monitoring |
Example:
import { readFileSync } from 'nova:fs';
import { Database } from 'nova:sqlite';
// Read file
const content = readFileSync('data.txt', 'utf-8');
// Use ultra-fast SQLite
const db = new Database(':memory:');
db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
const stmt = db.prepare('INSERT INTO users (name) VALUES (?)');
stmt.run('Alice');Nova's SQLite implementation is 5-10x faster than Node.js better-sqlite3:
Performance Comparison:
| Operation | Node.js | Nova Standard | Nova Ultra | Speedup |
|---|---|---|---|---|
| Batch Insert (10k rows) | 1,200ms | 1,100ms | 180ms | 6.7x |
| Repeated Queries (1k) | 450ms | 420ms | 85ms | 5.3x |
| Large Results (100k rows) | 3,200ms | 2,100ms | 650ms | 4.9x |
| Memory Usage (100k rows) | 250MB | 180MB | 90MB | -64% |
Key Optimizations:
- Statement caching (LRU cache for prepared statements)
- Connection pooling (reuse database connections)
- Zero-copy strings (std::string_view)
- Arena allocator (fast O(1) allocations)
- Ultra-fast pragmas (WAL, mmap, optimized cache)
See SQLITE_ULTRA_OPTIMIZATION.md for details.
Run Benchmarks:
# Windows
cd benchmarks
powershell -ExecutionPolicy Bypass -File run_sqlite_benchmarks.ps1
# Linux/macOS
cd benchmarks
./run_sqlite_benchmarks.shNova includes a built-in package manager compatible with npm:
# Install dependencies from package.json
nova pm install
# Install specific package
nova pm install lodash
# Install dev dependency
nova pm install --save-dev typescript
# Install global package
nova pm install -g typescript
# Update packages
nova pm update
# Remove package
nova pm uninstall lodash- LLVM 18.1.7
- CMake 3.20+
- C++20 Compiler (MSVC 19.29+ on Windows)
# Configure
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build build --config Release# Run TypeScript directly (JIT)
./build/Release/nova.exe script.ts
# Or with explicit run command
./build/Release/nova.exe run script.ts
# Compile to LLVM IR
./build/Release/nova.exe compile app.ts --emit-llvm
# Compile with optimizations
./build/Release/nova.exe compile app.ts -O3 -o app.llHello World:
function main(): number {
console.log("Hello, World!");
return 0;
}Array Operations:
function main(): number {
let arr = [1, 2, 3, 4, 5];
arr.push(6);
let sum = arr.reduce((a, b) => a + b, 0);
return sum; // Returns 21
}Classes:
class Rectangle {
width: number;
height: number;
constructor(w: number, h: number) {
this.width = w;
this.height = h;
}
area(): number {
return this.width * this.height;
}
}
function main(): number {
let rect = new Rectangle(5, 3);
return rect.area(); // Returns 15
}Async/Await:
async function fetchData(): Promise<number> {
return 42;
}
async function main(): Promise<number> {
let result = await fetchData();
return result;
}Nova/
├── src/ # Source code
│ ├── codegen/ # LLVM code generation
│ ├── frontend/ # Lexer, parser, AST
│ ├── hir/ # High-level IR
│ ├── mir/ # Mid-level IR
│ └── runtime/ # Runtime library
├── include/ # Header files
├── tests/ # Verified conformance and legacy test files
├── examples/ # Example programs
├── docs/ # Documentation
├── grammar/ # Language grammar definitions
├── build.bat # Windows build script
├── build.sh # Unix build script
├── CMakeLists.txt # CMake configuration
└── tests/run_all_tests.py # Expectation-based test runner
# Run verified conformance tests
npm test
# Or invoke the runner directly
python tests/run_all_tests.py
# Run specific test
python tests/run_all_tests.py tests/conformance/arrays.tsCurrent Status: 57 verified conformance tests pass. Legacy tests without explicit expected results are not counted as passing.
Nova compiles to native code via LLVM, providing excellent performance:
- Startup Time: ~5-10ms (2-3x faster than Node.js)
- Execution Speed: Near C++ performance for numeric computations
- Memory Usage: 30-50% less than Node.js for most workloads
- SQLite: 5-10x faster than Node.js better-sqlite3
- Array Operations: Optimized with LLVM vectorization
- String Operations: Zero-copy optimizations where possible
Benchmark Results (vs Node.js):
- Fibonacci (recursive): 2.1x faster
- Array operations: 1.8x faster
- String manipulation: 1.5x faster
- SQLite queries: 5-10x faster
- Memory usage: 40% less
See benchmarks/ directory for detailed performance tests.
- USAGE_GUIDE.md - Comprehensive usage guide
- QUICK_REFERENCE.md - Quick command reference
- ARCHITECTURE.md - Compiler architecture
- BUILD.md - Build instructions
- METHODS_STATUS.md - Supported methods list
- TS_JS_COMPATIBILITY.md - TypeScript/JavaScript compatibility
- SQLITE_ULTRA_OPTIMIZATION.md - SQLite ultra-optimization guide
- SQLITE_ULTRA_SUMMARY.md - SQLite optimization summary
- benchmarks/README_SQLITE.md - SQLite benchmark guide
- SQLITE_ULTRA_OPTIMIZATION_TH.md - คู่มือเพิ่มประสิทธิภาพ SQLite
- SQLITE_ULTRA_SUMMARY_TH.md - สรุปการเพิ่มประสิทธิภาพ SQLite
- benchmarks/README_SQLITE_TH.md - คู่มือ benchmark SQLite
See CHANGELOG.md for version history.
MIT License - see LICENSE for details.
Powered by LLVM 18.1.7