feat: Unified registry and major code cleanup by ChatGPT5

- Unified Box Registry: Replaced 600+ line match statement with clean factory pattern
- Code cleanup: Removed unused imports, variables, and dead code
- Import fixes: Fixed RangeBox, NullBox, MapBox imports
- Transport Debug: Added Debug trait implementation for Transport interface
- WASM build: Successfully tested with wasm_playground preset ready for integration
- Performance: Build time stable, WASM package generated successfully (1.89MB)

This commit represents a major architectural improvement with the unified registry
system now fully operational, reducing code duplication and improving maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-21 14:28:24 +09:00
parent bf0229c24a
commit 2fc6ce3aa6
14 changed files with 743 additions and 222 deletions

View File

@ -1,180 +1,305 @@
# 🐱 Nyash Programming Language
**Next-Generation Browser-Native Programming Experience**
**Everything is Box** - Revolutionary Programming Language
*[🇯🇵 日本語版はこちら / Japanese Version](README.ja.md)*
[![Build Status](https://img.shields.io/badge/Build-Passing-brightgreen.svg)](#)
[![Everything is Box](https://img.shields.io/badge/Philosophy-Everything%20is%20Box-blue.svg)](#philosophy)
[![WebAssembly](https://img.shields.io/badge/WebAssembly-Ready-orange.svg)](#webassembly)
[![Try Now](https://img.shields.io/badge/Try%20Now-Browser%20Playground-ff6b6b.svg)](projects/nyash-wasm/nyash_playground.html)
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](#license)
## ✨ Key Features
- **Everything is Box Philosophy**: Every value is a unified Box object
- **WebAssembly Ready**: Run natively in browsers with zero setup
- **Web Integration**: Control HTML5 Canvas, DOM elements directly from code
- **Self-Hosting**: Written in itself using revolutionary Box architecture
- **Modern Syntax**: Clean, expressive syntax with powerful abstractions
## 🚀 Quick Start
### Try in Browser (No Installation Required!)
Open [Nyash Playground](projects/nyash-wasm/nyash_playground.html) in your browser and start coding immediately!
### Local Development
```bash
# Clone the repository
git clone https://github.com/user/nyash.git
cd nyash
# Build with Cargo
cargo build --release
# Run your first program
./target/release/nyash examples/hello_world.nyash
```
## 💡 Philosophy: Everything is Box
Nyash revolutionizes programming by treating **everything** as a Box:
```nyash
// Traditional languages: different types, complex syntax
// Nyash: unified Box approach
greeting = new StringBox("Hello!") // Text is a Box
number = new IntegerBox(42) // Numbers are Boxes
display = new WebDisplayBox("output") // Even web elements are Boxes!
// Everything works the same way
display.print(greeting.toString())
display.print("The answer is: " + number)
```
## 🎮 Examples
### Hello World
```nyash
print("🐱 Hello, Nyash World!")
greeting = new StringBox("Welcome to Everything is Box!")
print(greeting.toString())
```
### Web Canvas Graphics
```nyash
canvas = new WebCanvasBox("my-canvas", 400, 300)
canvas.setFillStyle("red")
canvas.fillRect(50, 50, 100, 75)
canvas.fillText("Nyash WebCanvas", 150, 200)
```
### Game of Life (Conway)
```nyash
game = new GameOfLifeBox(50, 30)
game.randomize()
loop (game.generation < 100) {
game.step()
game.display()
}
```
## 📚 Documentation
- **[Getting Started](docs/GETTING_STARTED_2025.md)** - Your first steps with Nyash
- **[Language Guide](docs/LANGUAGE_OVERVIEW_2025.md)** - Complete language reference
- **[Technical Architecture](docs/TECHNICAL_ARCHITECTURE_2025.md)** - Deep dive into Box philosophy
- **[Philosophy](PHILOSOPHY.md)** - Everything is Box explained
## 🌐 Web Integration
Nyash provides seamless browser integration:
```nyash
// Control web page elements directly
display = new WebDisplayBox("output")
display.setHTML("<h1>Generated by Nyash!</h1>")
// Draw on HTML5 Canvas
canvas = new WebCanvasBox("graphics", 800, 600)
canvas.drawScene()
// Interactive web apps in pure Nyash
button = new WebButtonBox("click-me")
button.onClick = new MethodBox(app, "handleClick")
```
## 🎯 Sample Projects
Explore our curated examples:
- **[Hello World](examples/hello_world.nyash)** - Basic syntax and philosophy
- **[Simple Calculator](examples/simple_calculator.nyash)** - Math operations with Boxes
- **[Conway's Game of Life](examples/game_of_life.nyash)** - Complex algorithms made simple
- **[2048 Game](examples/simple_2048.nyash)** - Complete game implementation
- **[Dice RPG](examples/app_dice_rpg.nyash)** - Turn-based battle system
- **[Maze Generator](examples/maze_generator.nyash)** - Procedural generation
- **[Web Canvas Demo](examples/web_canvas_demo.nyash)** - HTML5 Canvas control
- **[Web Display Demo](examples/web_display_demo.nyash)** - DOM manipulation
- **[Text Adventure](examples/text_adventure/)** - Multi-file project structure
- **[Lisp Interpreter](examples/lisp/)** - Meta-programming capabilities
## ⚡ Performance & Architecture
- **Rust Backend**: High-performance native execution
- **WebAssembly Target**: Zero-overhead browser deployment
- **Box Unification**: Simplified memory model, optimized for speed
- **Self-Hosting**: Bootstrap compiler written in Nyash itself
## 🛠 Building from Source
### Prerequisites
- Rust 1.70+
- wasm-pack (for WebAssembly builds)
### Commands
```bash
# Native build
cargo build --release
# WebAssembly build
wasm-pack build --target web --out-dir projects/nyash-wasm/pkg
# Run tests
cargo test
# Generate documentation
cargo doc --open
```
## 🤝 Contributing
We welcome contributions! Here's how to get started:
1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Add** your changes and tests
4. **Ensure** all tests pass (`cargo test`)
5. **Commit** your changes (`git commit -m 'Add amazing feature'`)
6. **Push** to your branch (`git push origin feature/amazing-feature`)
7. **Open** a Pull Request
See our [Contributing Guidelines](CONTRIBUTING.md) for detailed information.
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🌟 Why Nyash?
- **Unified Philosophy**: No more juggling different types and paradigms
- **Web-First**: Built for the modern web development ecosystem
- **Self-Documenting**: Everything is Box makes code naturally readable
- **Performance**: Rust backend ensures native-level speed
- **Innovation**: Revolutionary approach to programming language design
---
**Everything is Box. Everything is Simple. Everything is Nyash.** 🐱
## 🚀 **Try Nyash Right Now!**
[Website](https://nyash-lang.org) • [Documentation](docs/) • [Examples](examples/) • [Community](https://discord.gg/nyash)
**No installation, no setup - just open and code!**
👉 **[🎮 Launch Nyash Browser Playground](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html)** 👈
Experience features like:
- 🎨 **Artist Collaboration Demo** - Multiple Box instances working together
-**Async Computing** - Parallel processing made simple
- 🎮 **Canvas Game Graphics** - Direct browser graphics programming
- 🔍 **Live Debug Visualization** - See your program's memory in real-time
---
## ✨ **Why Nyash Changes Everything**
### 🎯 **Memory Safety Revolution**
```nyash
// Traditional languages: manual memory management, crashes, security issues
// Nyash: Everything is Box - automatic, safe, elegant
static box Main {
init { player, enemies, canvas }
main() {
me.player = new PlayerBox("Hero", 100)
me.canvas = new WebCanvasBox("game", 800, 600)
// Memory automatically managed - no crashes, no leaks!
me.player.render(me.canvas)
return "Game running safely!"
}
}
```
### 🌐 **Browser-First Design**
- **Zero Installation**: Runs directly in web browsers via WebAssembly
- **Web APIs Built-in**: Canvas, DOM, storage - all native language features
- **Real-time Collaboration**: Share code instantly, run anywhere
- **Mobile Ready**: Works on phones, tablets, any modern device
### 🎨 **Creative Programming Made Easy**
```nyash
// Create art with code - naturally!
box Artist {
init { name, color }
paintMasterpiece(canvas) {
canvas.fillCircle(100, 100, 50, me.color)
canvas.fillText("Art by " + me.name, 10, 200, "24px Arial", me.color)
}
}
// Multiple artists collaborate
picasso = new Artist("Picasso", "red")
monet = new Artist("Monet", "blue")
// Each Box maintains its own state and behavior!
```
### ⚡ **Async Simplicity**
```nyash
// Parallel processing without complexity
nowait future1 = heavyComputation(10000)
nowait future2 = renderGraphics()
// Do other work while they run...
setupUI()
// Get results when ready
result1 = await future1
result2 = await future2
```
---
## 🏗️ **Revolutionary Architecture**
### Everything is Box Philosophy
Every value in Nyash is a **Box** - a unified, memory-safe container:
| Traditional Languages | Nyash |
|----------------------|-------|
| `int x = 42;` | `x = new IntegerBox(42)` |
| `string name = "Hello";` | `name = new StringBox("Hello")` |
| Complex canvas setup | `canvas = new WebCanvasBox("game", 800, 600)` |
| Manual memory management | Automatic Box lifecycle management |
### Static Box Main Pattern
```nyash
// Clean, predictable program structure
static box Main {
init { database, ui, gameState } // Declare all fields upfront
main() {
// Initialize in logical order
me.database = new DatabaseBox("save.db")
me.ui = new UIManagerBox()
me.gameState = new GameStateBox()
// Your program logic here
return runGameLoop()
}
}
```
### Visual Debug Integration
```nyash
debug = new DebugBox()
debug.startTracking()
player = new PlayerBox("Hero")
debug.trackBox(player, "Main Character")
// Real-time memory visualization in browser!
print(debug.memoryReport()) // Live stats, no debugging hell
```
---
## 🎮 **Perfect for Creative Coding**
### Game Development
- **Built-in Canvas API**: Graphics without external libraries
- **Input Handling**: Mouse, keyboard, touch - all native
- **Audio Support**: SoundBox for music and effects
- **Physics Ready**: Mathematical operations optimized
### Educational Programming
- **Visual Feedback**: See your code's effects immediately
- **Memory Visualization**: Understand how programs work
- **No Setup Barriers**: Students code instantly in browser
- **Progressive Learning**: From simple scripts to complex applications
### Web Applications
- **Direct DOM Control**: WebDisplayBox manipulates HTML
- **No Framework Needed**: Language handles web interaction natively
- **Real-time Updates**: Changes reflect immediately
- **Cross-Platform**: Same code, everywhere
---
## 📖 **Language Highlights**
### Clean, Expressive Syntax
```nyash
// Object-oriented programming made natural
box Player {
init { name, health, inventory }
Player(playerName) {
me.name = playerName
me.health = 100
me.inventory = new ArrayBox()
}
takeDamage(amount) {
me.health = me.health - amount
if me.health <= 0 {
me.respawn()
}
}
respawn() {
me.health = 100
print(me.name + " respawned!")
}
}
```
### Powerful Operators
```nyash
// Natural language operators for clarity
isAlive = health > 0 and not poisoned
canCast = mana >= spellCost or hasItem("Magic Ring")
gameOver = playerDead or timeUp
// Mathematical operations built-in
distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)
angle = atan2(deltaY, deltaX)
```
### Generic Programming
```nyash
// Type-safe generic containers
box Container<T> {
init { value }
Container(item) { me.value = item }
getValue() { return me.value }
}
numbers = new Container<IntegerBox>(42)
texts = new Container<StringBox>("Hello")
```
---
## 🛠️ **Getting Started**
### Browser Development (Recommended)
```bash
# 1. Clone repository
git clone https://github.com/moe-charm/nyash.git
cd nyash
# 2. Build WebAssembly version
cd projects/nyash-wasm
./build.sh
# 3. Open playground in browser
# Open nyash_playground.html in any modern browser
```
### Native Development
#### Linux/WSL
```bash
# Build native version
cargo build --release
# Run programs locally
./target/release/nyash program.nyash
# Try examples
./target/release/nyash test_async_demo.nyash
./target/release/nyash app_dice_rpg.nyash
```
#### 🪟 Windows (Cross-compile)
```bash
# Install cross-compiler
cargo install cargo-xwin
# Build Windows executable
cargo xwin build --target x86_64-pc-windows-msvc --release
# Generated executable (916KB)
target/x86_64-pc-windows-msvc/release/nyash.exe
```
---
## 🤝 **Contributing**
Nyash is open source and welcomes contributions!
- **Issues**: Report bugs, request features
- **Pull Requests**: Code improvements, new examples
- **Documentation**: Help improve guides and examples
- **Community**: Share your Nyash creations!
## 📄 **License**
MIT License - Free for personal and commercial use.
---
## 🔗 **Links**
- **[🎮 Try Now - Browser Playground](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html)**
- **[📚 Documentation](docs/)**
- **[🎯 Examples](examples/)**
- **[💬 Community Discussion](https://github.com/moe-charm/nyash/discussions)**
## 👨‍💻 **Creator**
**Moe Charm** - Programming Language Designer & Developer
- 🐙 GitHub: [@moe-charm](https://github.com/moe-charm)
- 🐦 Twitter/X: [@CharmNexusCore](https://x.com/CharmNexusCore)
- ☕ Support Development: [coff.ee/moecharmde6](http://coff.ee/moecharmde6)
*Creating innovative programming languages with AI assistance and dedication 🤖*
---
## 🤖 **Support the Project**
Nyash is developed with cutting-edge AI collaboration!
If you enjoy Nyash and want to support continued development:
**☕ [Support Development](http://coff.ee/moecharmde6)** - Help fuel innovation!
*Powered by Claude Code - Advanced AI development tools aren't free! 🤖*
Your support helps maintain the project, develop new features, and continue pushing the boundaries of programming language design. Every contribution makes a difference! 🙏
---
*Built with ❤️, 🤖 Claude Code, and the Everything is Box philosophy*
**Nyash - Where every value is a Box, and every Box tells a story.**