Hikari is a modern, dynamically-typed programming language built from the ground up. It features a custom bytecode compiler and a virtual machine, designed to be instantly familiar to millions of developers by adopting the popular and expressive syntax of JavaScript.
The project is a deep dive into the mechanics of language implementation. It features a complete execution pipeline from source code to final value, including closures, classes, a prototype-based object model, and a full non-blocking, resumable execution model with generators and async/await.
- Custom Language & Runtime: Hikari is not a JavaScript engine. It is a unique language with its own compiler and execution semantics, implemented from scratch.
- AST-to-Bytecode Compiler: A tree-walking compiler that translates the language's AST into a custom, efficient instruction set.
- Stack-Based Virtual Machine: A stable and performant C-style dispatch loop for executing Hikari bytecode.
- Advanced Programming Constructs:
- Closures: First-class functions with full lexical scoping, enabling modern functional patterns.
- Classes & Prototypes: An object-oriented model with syntactic sugar for
class,constructor, andthis. - Error Handling: A robust
try/catch/throwmechanism with proper stack unwinding.
- Modern Resumable Execution Model – Hikari fully supports asynchronous and pausable computation:
- Generators & Iterators – Use
function*andyieldfor lazy evaluation, custom iteration, and resumable computation. - Event Loop – A non-blocking event loop that integrates with the host environment.
- Native Promises & Async/Await – Full VM-native
Promiseimplementation withasync/awaitsupport, built on top of generators for seamless asynchronicity.
- Generators & Iterators – Use
- Powerful Native Interoperability (WIP): Call any host JavaScript function (e.g.,
console.log,fetch) from within Hikari. This powerful feature provides the entire standard library (JSON,Math,Map,Set, etc.) by directly leveraging the rich capabilities of the host JS environment.
The goal of Hikari is to demystify the inner workings of a modern, high-level language runtime. By building each component from the ground up—from the compiler's code generation to the VM's memory management and execution loop—the project serves as a comprehensive case study in language design.
Why adopt JavaScript's syntax? I chose JavaScript's syntax as the foundation for Hikari due to its universal familiarity and unparalleled accessibility on the web. This strategic choice lowers the barrier to entry, allowing developers to immediately be productive in a new language environment without learning a new syntax. It's the best of both worlds: a well-understood, expressive syntax on top of a completely custom, modern runtime.
Hikari has a clean, multi-stage architecture that separates concerns for clarity and maintainability.
-
Parsing (Leveraging Babel): Source code written in Hikari is first fed into the industry-standard Babel Parser (
@babel/parser). Since Hikari is syntactically compatible with JavaScript, Babel can produce a compliant Abstract Syntax Tree (AST). -
Compilation: A custom Hikari Compiler traverses the AST. For each node type, it emits a series of custom Opcodes (like
OP_YIELDandOP_AWAIT), specifically designed for the Hikari VM. -
Execution: The generated bytecode is loaded into the Hikari Virtual Machine (VM). The VM's core is a stack-based execution engine that executes the bytecode, managing memory, call frames, and the event loop's microtask queue according to Hikari's own semantics.
This project is developed in distinct, feature-focused phases.
-
✅ Phase 1: Core Language Runtime (Complete)
- Parsing, AST Generation, Compiler v1, Bytecode v1, VM v1, all basic data types, operators, variable scoping, and control flow.
-
✅ Phase 2: Advanced Functions & Object Model (Complete)
- First-class Closures, a prototype chain,
classsyntactic sugar, and a fulltry/catchimplementation.
- First-class Closures, a prototype chain,
-
✅ Phase 3: Modern Asynchronous Execution (Complete)
- This now includes Generators (
yield), a host-integrated event loop, a VM-nativePromiseclass, and full compiler/VM support forasync/await.
- This now includes Generators (
-
🟡 Phase 4: Memory Management (In Progress)
- Implementation of a Mark and Sweep Garbage Collector to provide automatic memory management.
-
🟡 Phase 5: High-Performance WASM Backend (In Progress [Phase 1])
- New Direction: To achieve near-native performance, this phase will explore compiling Hikari's bytecode into WebAssembly (WASM). The plan is to develop a secondary, high-performance VM in Rust, which will then be compiled to a WASM module. This provides a portable, secure, and incredibly fast execution path for performance-critical functions.
-
⚪ Phase 6: Future Expansions (Planned)
- Tooling: Create a debugger, a REPL (Read-Eval-Print Loop), or a Language Server Protocol (LSP) implementation.
- Inheritance: Add full support for
extendsandsuperkeywords for more complex class hierarchies.
For a detailed breakdown of tasks, see the roadmap.md file.
- Node.js (v16.0.0 or higher recommended)
- npm
- Clone the repository:
git clone https://github.com/SSL-ACTX/hikari.git cd hikari - Install the dependencies:
npm install
Hikari can execute any JavaScript file directly, thanks to its syntactic compatibility. To try it out:
# Run a sample file
node index.js ./test.jsNotes:
test.jscan be any JS file using standard JS syntax (Hikari will parse it).- You can create your own file, e.g.:
// test.js
console.log("Hello from Hikari!");Then run:
node index.js ./test.jsYou should see the output in your terminal.
This project is licensed under the Apache License 2.0. Please see the LICENSE file for full details.
Developed by Seuriin

