2025-08-09 15:14:44 +09:00
|
|
|
# 🐱 Nyash Programming Language
|
2025-08-29 11:49:01 +09:00
|
|
|
**From Zero to Native Binary in 20 Days - The AI-Powered Language Revolution**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-09 15:37:24 +09:00
|
|
|
*[🇯🇵 日本語版はこちら / Japanese Version](README.ja.md)*
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
[](#)
|
|
|
|
|
[](#philosophy)
|
2025-08-29 11:49:01 +09:00
|
|
|
[](#performance)
|
|
|
|
|
[](#execution-modes)
|
2025-08-09 15:14:44 +09:00
|
|
|
[](#license)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🚀 **Breaking News: Native EXE Achieved!**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
**August 29, 2025** - Just 20 days after inception, Nyash can now compile to native executables!
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
```bash
|
|
|
|
|
# From Nyash source to native binary
|
|
|
|
|
./target/release/nyash --backend vm program.nyash # JIT compilation
|
|
|
|
|
./tools/build_aot.sh program.nyash -o app # Native EXE
|
|
|
|
|
./app # Standalone execution!
|
|
|
|
|
```
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
**What we achieved in 20 days:**
|
|
|
|
|
- ✅ Full programming language with interpreter
|
|
|
|
|
- ✅ VM with 13.5x performance boost
|
|
|
|
|
- ✅ JIT compiler (Cranelift integration)
|
|
|
|
|
- ✅ WebAssembly support
|
|
|
|
|
- ✅ Plugin system (C ABI)
|
|
|
|
|
- ✅ Native binary generation
|
|
|
|
|
- ✅ Python integration via plugins
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## ✨ **Why Nyash?**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 🎯 **Everything is Box Philosophy**
|
2025-08-09 15:14:44 +09:00
|
|
|
```nyash
|
2025-08-29 11:49:01 +09:00
|
|
|
// Traditional languages have complex type systems
|
|
|
|
|
// Nyash: One concept rules them all - Box
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
static box Main {
|
|
|
|
|
main() {
|
2025-08-29 11:49:01 +09:00
|
|
|
// Every value is a Box - unified, safe, simple
|
|
|
|
|
local name = new StringBox("Nyash")
|
|
|
|
|
local count = new IntegerBox(42)
|
|
|
|
|
local data = new MapBox()
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
// Even Python objects are Boxes!
|
|
|
|
|
local py = new PyRuntimeBox()
|
|
|
|
|
local math = py.import("math")
|
|
|
|
|
print("sqrt(9) = " + math.getattr("sqrt").call(9).str())
|
|
|
|
|
|
|
|
|
|
return 0
|
2025-08-09 15:14:44 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### ⚡ **Unprecedented Development Speed**
|
|
|
|
|
- **Day 1**: Basic interpreter working
|
|
|
|
|
- **Day 4**: Already planning JIT
|
|
|
|
|
- **Day 13**: VM achieving 13.5x speedup
|
|
|
|
|
- **Day 20**: Native executable generation!
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 🔌 **Plugin-First Architecture**
|
2025-08-09 15:14:44 +09:00
|
|
|
```nyash
|
2025-08-29 11:49:01 +09:00
|
|
|
// Any functionality can be a plugin Box
|
|
|
|
|
local file = new FileBox() // File I/O plugin
|
|
|
|
|
local http = new HttpClientBox() // Network plugin
|
|
|
|
|
local py = new PyRuntimeBox() // Python plugin
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
// Plugins compile to native code too!
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🏗️ **Multiple Execution Modes**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 1. **Interpreter Mode** (Development)
|
|
|
|
|
```bash
|
|
|
|
|
./target/release/nyash program.nyash
|
|
|
|
|
```
|
|
|
|
|
- Instant execution
|
|
|
|
|
- Full debug information
|
|
|
|
|
- Perfect for development
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 2. **VM Mode** (Production)
|
|
|
|
|
```bash
|
|
|
|
|
./target/release/nyash --backend vm program.nyash
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
2025-08-29 11:49:01 +09:00
|
|
|
- 13.5x faster than interpreter
|
|
|
|
|
- Optimized bytecode execution
|
|
|
|
|
- Production-ready performance
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 3. **JIT Mode** (High Performance)
|
|
|
|
|
```bash
|
|
|
|
|
NYASH_JIT_EXEC=1 ./target/release/nyash --backend vm program.nyash
|
|
|
|
|
```
|
|
|
|
|
- Cranelift-powered JIT compilation
|
|
|
|
|
- Near-native performance
|
|
|
|
|
- Hot function optimization
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 4. **Native Binary** (Distribution)
|
|
|
|
|
```bash
|
|
|
|
|
./tools/build_aot.sh program.nyash -o myapp
|
|
|
|
|
./myapp # Standalone executable!
|
|
|
|
|
```
|
|
|
|
|
- Zero dependencies
|
|
|
|
|
- Maximum performance
|
|
|
|
|
- Easy distribution
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 5. **WebAssembly** (Browser)
|
|
|
|
|
```bash
|
|
|
|
|
./target/release/nyash --compile-wasm program.nyash
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
2025-08-29 11:49:01 +09:00
|
|
|
- Run in browsers
|
|
|
|
|
- Cross-platform by default
|
|
|
|
|
- Web-first development
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 📊 **Performance Benchmarks**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
Real-world benchmark results (ny_bench.nyash):
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Mode | Time | Relative Speed
|
|
|
|
|
---------------|-----------|---------------
|
|
|
|
|
Interpreter | 110.10ms | 1.0x (baseline)
|
|
|
|
|
VM | 8.14ms | 13.5x faster
|
|
|
|
|
VM + JIT | 5.8ms | 19.0x faster
|
|
|
|
|
Native Binary | ~4ms | ~27x faster
|
|
|
|
|
```
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🎮 **Language Features**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Clean Syntax
|
2025-08-09 15:14:44 +09:00
|
|
|
```nyash
|
2025-08-29 11:49:01 +09:00
|
|
|
box GameCharacter {
|
|
|
|
|
init { name, health, skills }
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
// Birth constructor - giving life to Boxes!
|
|
|
|
|
birth(characterName) {
|
|
|
|
|
me.name = characterName
|
2025-08-09 15:14:44 +09:00
|
|
|
me.health = 100
|
2025-08-29 11:49:01 +09:00
|
|
|
me.skills = new ArrayBox()
|
|
|
|
|
print("🌟 " + characterName + " has been born!")
|
2025-08-09 15:14:44 +09:00
|
|
|
}
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
learnSkill(skill) {
|
|
|
|
|
me.skills.push(skill)
|
|
|
|
|
return me // Method chaining
|
2025-08-09 15:14:44 +09:00
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 11:49:01 +09:00
|
|
|
|
|
|
|
|
// Usage
|
|
|
|
|
local hero = new GameCharacter("Neko")
|
|
|
|
|
hero.learnSkill("Fire Magic").learnSkill("Healing")
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Modern Async/Await
|
2025-08-09 15:14:44 +09:00
|
|
|
```nyash
|
2025-08-29 11:49:01 +09:00
|
|
|
// Concurrent operations made simple
|
|
|
|
|
nowait task1 = fetchDataFromAPI()
|
|
|
|
|
nowait task2 = processLocalFiles()
|
|
|
|
|
|
|
|
|
|
// Do other work while waiting
|
|
|
|
|
updateUI()
|
|
|
|
|
|
|
|
|
|
// Collect results
|
|
|
|
|
local apiData = await task1
|
|
|
|
|
local files = await task2
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Delegation Pattern
|
2025-08-09 15:14:44 +09:00
|
|
|
```nyash
|
2025-08-29 11:49:01 +09:00
|
|
|
// Composition over inheritance
|
|
|
|
|
box EnhancedArray from ArrayBox {
|
|
|
|
|
init { logger }
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
override push(item) {
|
|
|
|
|
me.logger.log("Adding: " + item)
|
|
|
|
|
from ArrayBox.push(item) // Delegate to parent
|
|
|
|
|
}
|
2025-08-09 15:14:44 +09:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🔌 **Plugin System**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
Nyash pioneered the "Everything is Plugin" architecture:
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
```toml
|
|
|
|
|
# nyash.toml - Plugin configuration
|
|
|
|
|
[libraries."libnyash_python_plugin.so"]
|
|
|
|
|
boxes = ["PyRuntimeBox", "PyObjectBox"]
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
[libraries."libnyash_net_plugin.so"]
|
|
|
|
|
boxes = ["HttpServerBox", "HttpClientBox", "WebSocketBox"]
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
Create your own Box types in C/Rust and integrate seamlessly!
|
2025-08-09 16:19:22 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
---
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🛠️ **Getting Started**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Quick Install (Linux/Mac/WSL)
|
|
|
|
|
```bash
|
|
|
|
|
# Clone and build
|
|
|
|
|
git clone https://github.com/moe-charm/nyash.git
|
|
|
|
|
cd nyash
|
|
|
|
|
cargo build --release --features cranelift-jit
|
|
|
|
|
|
|
|
|
|
# Run your first program
|
|
|
|
|
echo 'print("Hello Nyash!")' > hello.nyash
|
|
|
|
|
./target/release/nyash hello.nyash
|
2025-08-09 15:14:44 +09:00
|
|
|
```
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Windows
|
2025-08-09 16:19:22 +09:00
|
|
|
```bash
|
2025-08-29 11:49:01 +09:00
|
|
|
# Cross-compile for Windows
|
2025-08-09 16:19:22 +09:00
|
|
|
cargo install cargo-xwin
|
|
|
|
|
cargo xwin build --target x86_64-pc-windows-msvc --release
|
2025-08-29 11:49:01 +09:00
|
|
|
# Use target/x86_64-pc-windows-msvc/release/nyash.exe
|
2025-08-09 16:19:22 +09:00
|
|
|
```
|
|
|
|
|
|
2025-08-09 15:14:44 +09:00
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🌟 **Unique Innovations**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 1. **AI-Driven Development**
|
|
|
|
|
- Developed with Claude, ChatGPT, and Codex collaboration
|
|
|
|
|
- 20-day journey from concept to native compilation
|
|
|
|
|
- Proves AI can accelerate language development by 30x
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 2. **Box-First Architecture**
|
|
|
|
|
- Every optimization preserves the Box abstraction
|
|
|
|
|
- Plugins are Boxes, JIT preserves Boxes, even native code respects Boxes
|
|
|
|
|
- Unprecedented consistency across all execution modes
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### 3. **Observable by Design**
|
|
|
|
|
- Built-in debugging and profiling
|
|
|
|
|
- JSON event streams for JIT compilation
|
|
|
|
|
- DOT graph visualization of optimizations
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 📚 **Examples**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Python Integration
|
|
|
|
|
```nyash
|
|
|
|
|
// Use Python libraries from Nyash!
|
|
|
|
|
local py = new PyRuntimeBox()
|
|
|
|
|
local np = py.import("numpy")
|
|
|
|
|
local array = np.getattr("array").call([1, 2, 3])
|
|
|
|
|
print("NumPy array: " + array.str())
|
|
|
|
|
```
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
### Web Server
|
|
|
|
|
```nyash
|
|
|
|
|
local server = new HttpServerBox()
|
|
|
|
|
server.start(8080)
|
|
|
|
|
|
|
|
|
|
loop(true) {
|
|
|
|
|
local request = server.accept()
|
|
|
|
|
local response = new HttpResponseBox()
|
|
|
|
|
response.setStatus(200)
|
|
|
|
|
response.write("Hello from Nyash!")
|
|
|
|
|
request.respond(response)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Game Development
|
|
|
|
|
```nyash
|
|
|
|
|
box GameObject {
|
|
|
|
|
init { x, y, sprite }
|
|
|
|
|
|
|
|
|
|
update(deltaTime) {
|
|
|
|
|
// Physics simulation
|
|
|
|
|
me.y = me.y + gravity * deltaTime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(canvas) {
|
|
|
|
|
canvas.drawImage(me.sprite, me.x, me.y)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 🤝 **Contributing**
|
|
|
|
|
|
|
|
|
|
Join the revolution! We welcome:
|
|
|
|
|
- 🐛 Bug reports and fixes
|
|
|
|
|
- ✨ New Box types via plugins
|
|
|
|
|
- 📚 Documentation improvements
|
|
|
|
|
- 🎮 Cool example programs
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 📄 **License**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
MIT License - Use freely in your projects!
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 👨💻 **Creator**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
**Tomoaki** - Language Designer & Revolutionary
|
|
|
|
|
- 🐱 GitHub: [@moe-charm](https://github.com/moe-charm)
|
|
|
|
|
- 🌟 Created with: Claude, ChatGPT, Codex collaboration
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
---
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
## 🎉 **Historical Timeline**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
- **August 9, 2025**: First commit - "Hello Nyash!"
|
|
|
|
|
- **August 13**: JIT planning begins (day 4!)
|
|
|
|
|
- **August 20**: VM achieves 13.5x performance
|
|
|
|
|
- **August 29**: Native EXE compilation achieved!
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
*20 days from zero to native binary - a new record in language development!*
|
2025-08-09 15:14:44 +09:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
**🚀 Nyash - Where Everything is a Box, and Boxes Compile to Native Code!**
|
2025-08-09 15:14:44 +09:00
|
|
|
|
2025-08-29 11:49:01 +09:00
|
|
|
*Built with ❤️, 🤖 AI collaboration, and the belief that programming languages can be created at the speed of thought*
|