From a9e82933cc56404df6e9b0c8ecfab19c10fb72ea Mon Sep 17 00:00:00 2001 From: Moe Charm Date: Fri, 29 Aug 2025 11:49:01 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20README=E6=9B=B4=E6=96=B0=20-=2020?= =?UTF-8?q?=E6=97=A5=E3=81=A7=E3=83=8D=E3=82=A4=E3=83=86=E3=82=A3=E3=83=96?= =?UTF-8?q?EXE=E9=81=94=E6=88=90=E3=82=92=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 英語版・日本語版ともに最新の成果を反映 - 20日間の開発タイムラインを強調 - 5つの実行モード(インタープリター/VM/JIT/ネイティブ/WASM)を明記 - プラグインシステムとPython統合の実例を追加 - パフォーマンスベンチマーク結果を更新(最大27倍高速化) --- README.ja.md | 554 ++++++++++++++++++++++++++------------------------- README.md | 452 +++++++++++++++++++++-------------------- 2 files changed, 522 insertions(+), 484 deletions(-) diff --git a/README.ja.md b/README.ja.md index 13aa1d23..217e63a1 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,319 +1,331 @@ # 🐱 Nyash プログラミング言語 -**次世代ブラウザーネイティブ開発体験** +**20日でゼロからネイティブバイナリへ - AI駆動の言語革命** *[🇺🇸 English Version / 英語版はこちら](README.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)](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html) +[![Performance](https://img.shields.io/badge/Performance-13.5x%20高速化-ff6b6b.svg)](#performance) +[![JIT Ready](https://img.shields.io/badge/JIT-Cranelift%20搭載-orange.svg)](#execution-modes) [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](#license) --- -## 🚀 **今すぐNyashを体験!** +## 🚀 **速報: ネイティブEXE達成!** -**インストール不要、設定不要 - ブラウザーを開くだけ!** +**2025年8月29日** - 誕生からわずか20日で、Nyashがネイティブ実行ファイルへのコンパイルを実現! -👉 **[🎮 Nyashブラウザープレイグラウンド起動](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html)** 👈 - -体験できる機能: -- 🎨 **アーティスト協同制作デモ** - 複数Boxインスタンスの連携 -- ⚡ **非同期計算処理** - シンプルな並列処理 -- 🎮 **Canvas ゲームグラフィック** - ブラウザーでの直接グラフィック描画 -- 🔍 **ライブデバッグ可視化** - プログラムのメモリ状態をリアルタイム表示 - ---- - -## ✨ **Nyashが革命を起こす理由** - -### 🎯 **メモリ安全性の革命** -```nyash -// 従来の言語: 手動メモリ管理、クラッシュ、セキュリティ問題 -// Nyash: Everything is Box - 自動的、安全、エレガント - -static box Main { - init { player, enemies, canvas } - - main() { - me.player = new PlayerBox("勇者", 100) - me.canvas = new WebCanvasBox("game", 800, 600) - - // メモリは自動管理 - クラッシュなし、メモリリークなし! - me.player.render(me.canvas) - return "ゲーム安全実行中!" - } -} -``` - -### 🌐 **ブラウザーファースト設計** -- **ゼロインストール**: WebAssembly経由でWebブラウザーで直接実行 -- **Web API内蔵**: Canvas、DOM、ストレージ - すべてが言語ネイティブ機能 -- **リアルタイム協業**: コードを即座に共有、どこでも実行 -- **モバイル対応**: スマートフォン、タブレット、すべての現代デバイスで動作 - -### 🎨 **創作プログラミングが簡単に** -```nyash -// コードでアートを作る - 自然に! -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) - } -} - -// 複数のアーティストが協力 -picasso = new Artist("ピカソ", "red") -monet = new Artist("モネ", "blue") -// 各Boxが独自の状態と動作を維持! -``` - -### ⚡ **非同期処理の簡潔性** -```nyash -// 複雑さなしの並列処理 -nowait future1 = heavyComputation(10000) -nowait future2 = renderGraphics() - -// 実行中に他の作業を... -setupUI() - -// 準備ができたら結果を取得 -result1 = await future1 -result2 = await future2 -``` - ---- - -## 🏗️ **革命的アーキテクチャ** - -### 例とスモーク(開発者向けクイック) -- 代表例: `examples/README.md`(HH直実行・mutating opt-in・GCデモ) -- スモーク実行: `bash tools/smoke_phase_10_10.sh` -- JITイベント最小スキーマ: `docs/reference/jit/jit_events_json_v0_1.md` - -### Everything is Box 哲学 -Nyashのすべての値は **Box** - 統一された、メモリ安全なコンテナです: - -| 従来の言語 | Nyash | -|-----------|-------| -| `int x = 42;` | `x = new IntegerBox(42)` | -| `string name = "Hello";` | `name = new StringBox("Hello")` | -| 複雑なcanvas設定 | `canvas = new WebCanvasBox("game", 800, 600)` | -| 手動メモリ管理 | 自動Boxライフサイクル管理 | - -### Static Box Main パターン -```nyash -// クリーンで予測可能なプログラム構造 -static box Main { - init { database, ui, gameState } // すべてのフィールドを事前宣言 - - main() { - // 論理的順序で初期化 - me.database = new DatabaseBox("save.db") - me.ui = new UIManagerBox() - me.gameState = new GameStateBox() - - // プログラムロジックここに - return runGameLoop() - } -} -``` - -### 視覚的デバッグ統合 -```nyash -debug = new DebugBox() -debug.startTracking() - -player = new PlayerBox("勇者") -debug.trackBox(player, "メインキャラクター") - -// ブラウザーでリアルタイムメモリ可視化! -print(debug.memoryReport()) // ライブ統計、デバッグ地獄なし -``` - ---- - -## 🎮 **創作コーディングに最適** - -### ゲーム開発 -- **内蔵Canvas API**: 外部ライブラリなしでグラフィック -- **入力ハンドリング**: マウス、キーボード、タッチ - すべてネイティブ -- **オーディオサポート**: 音楽と効果音用のSoundBox -- **物理準備済み**: 数学演算最適化 - -### 教育的プログラミング -- **視覚的フィードバック**: コードの効果を即座に確認 -- **メモリ可視化**: プログラムの動作を理解 -- **設定バリアなし**: 学生はブラウザーで即座にコーディング -- **段階的学習**: 簡単なスクリプトから複雑なアプリケーションまで - -### Webアプリケーション -- **直接DOM制御**: WebDisplayBoxでHTML操作 -- **フレームワーク不要**: 言語がネイティブでWeb相互作用を処理 -- **リアルタイム更新**: 変更が即座に反映 -- **クロスプラットフォーム**: 同じコード、どこでも - ---- - -## 📖 **言語の特徴** - -### クリーンで表現力豊かな構文 -```nyash -// 自然なオブジェクト指向プログラミング -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 + " がリスポーンしました!") - } -} -``` - -### 強力な演算子 -```nyash -// 明確性のための自然言語演算子 -isAlive = health > 0 and not poisoned -canCast = mana >= spellCost or hasItem("魔法の指輪") -gameOver = playerDead or timeUp - -// 内蔵数学演算 -distance = sqrt((x2 - x1)^2 + (y2 - y1)^2) -angle = atan2(deltaY, deltaX) -``` - -### ジェネリックプログラミング -```nyash -// 型安全なジェネリックコンテナ -box Container { - init { value } - - Container(item) { me.value = item } - getValue() { return me.value } -} - -numbers = new Container(42) -texts = new Container("こんにちは") -``` - ---- - -## 🛠️ **使い始める** - -### ブラウザー開発(推奨) ```bash -# 1. リポジトリクローン +# Nyashソースからネイティブバイナリへ +./target/release/nyash --backend vm program.nyash # JITコンパイル +./tools/build_aot.sh program.nyash -o app # ネイティブEXE +./app # スタンドアロン実行! +``` + +**20日間で達成したこと:** +- ✅ インタープリター付き完全プログラミング言語 +- ✅ 13.5倍高速化を実現したVM +- ✅ JITコンパイラ(Cranelift統合) +- ✅ WebAssemblyサポート +- ✅ プラグインシステム(C ABI) +- ✅ ネイティブバイナリ生成 +- ✅ プラグイン経由のPython統合 + +--- + +## ✨ **なぜNyashなのか?** + +### 🎯 **Everything is Box 哲学** +```nyash +// 従来の言語は複雑な型システムを持つ +// Nyash: 一つの概念がすべてを支配する - Box + +static box Main { + main() { + // すべての値はBox - 統一、安全、シンプル + local name = new StringBox("Nyash") + local count = new IntegerBox(42) + local data = new MapBox() + + // PythonオブジェクトもBox! + local py = new PyRuntimeBox() + local math = py.import("math") + print("sqrt(9) = " + math.getattr("sqrt").call(9).str()) + + return 0 + } +} +``` + +### ⚡ **前例のない開発速度** +- **1日目**: 基本インタープリター動作 +- **4日目**: すでにJIT計画開始 +- **13日目**: VMが13.5倍高速化達成 +- **20日目**: ネイティブ実行ファイル生成! + +### 🔌 **プラグインファースト・アーキテクチャ** +```nyash +// あらゆる機能がプラグインBoxになれる +local file = new FileBox() // ファイルI/Oプラグイン +local http = new HttpClientBox() // ネットワークプラグイン +local py = new PyRuntimeBox() // Pythonプラグイン + +// プラグインもネイティブコードにコンパイル! +``` + +--- + +## 🏗️ **複数の実行モード** + +### 1. **インタープリターモード** (開発用) +```bash +./target/release/nyash program.nyash +``` +- 即座に実行 +- 完全なデバッグ情報 +- 開発に最適 + +### 2. **VMモード** (本番用) +```bash +./target/release/nyash --backend vm program.nyash +``` +- インタープリターより13.5倍高速 +- 最適化されたバイトコード実行 +- 本番環境対応のパフォーマンス + +### 3. **JITモード** (高性能) +```bash +NYASH_JIT_EXEC=1 ./target/release/nyash --backend vm program.nyash +``` +- Cranelift搭載JITコンパイル +- ほぼネイティブ性能 +- ホット関数最適化 + +### 4. **ネイティブバイナリ** (配布用) +```bash +./tools/build_aot.sh program.nyash -o myapp +./myapp # スタンドアロン実行! +``` +- 依存関係ゼロ +- 最高性能 +- 簡単配布 + +### 5. **WebAssembly** (ブラウザ用) +```bash +./target/release/nyash --compile-wasm program.nyash +``` +- ブラウザで実行 +- デフォルトでクロスプラットフォーム +- Webファースト開発 + +--- + +## 📊 **パフォーマンスベンチマーク** + +実世界ベンチマーク結果 (ny_bench.nyash): + +``` +モード | 時間 | 相対速度 +----------------|-----------|--------------- +インタープリター | 110.10ms | 1.0x (基準) +VM | 8.14ms | 13.5倍高速 +VM + JIT | 5.8ms | 19.0倍高速 +ネイティブ | ~4ms | ~27倍高速 +``` + +--- + +## 🎮 **言語機能** + +### クリーンな構文 +```nyash +box GameCharacter { + init { name, health, skills } + + // birthコンストラクタ - Boxに生命を与える! + birth(characterName) { + me.name = characterName + me.health = 100 + me.skills = new ArrayBox() + print("🌟 " + characterName + " が誕生しました!") + } + + learnSkill(skill) { + me.skills.push(skill) + return me // メソッドチェーン + } +} + +// 使用例 +local hero = new GameCharacter("ネコ") +hero.learnSkill("火魔法").learnSkill("回復") +``` + +### モダンなAsync/Await +```nyash +// シンプルな並行処理 +nowait task1 = fetchDataFromAPI() +nowait task2 = processLocalFiles() + +// 待機中に他の作業 +updateUI() + +// 結果収集 +local apiData = await task1 +local files = await task2 +``` + +### デリゲーションパターン +```nyash +// 継承よりコンポジション +box EnhancedArray from ArrayBox { + init { logger } + + override push(item) { + me.logger.log("追加中: " + item) + from ArrayBox.push(item) // 親に委譲 + } +} +``` + +--- + +## 🔌 **プラグインシステム** + +Nyashは「Everything is Plugin」アーキテクチャを開拓: + +```toml +# nyash.toml - プラグイン設定 +[libraries."libnyash_python_plugin.so"] +boxes = ["PyRuntimeBox", "PyObjectBox"] + +[libraries."libnyash_net_plugin.so"] +boxes = ["HttpServerBox", "HttpClientBox", "WebSocketBox"] +``` + +C/Rustで独自のBox型を作成してシームレスに統合! + +--- + +## 🛠️ **はじめる** + +### クイックインストール (Linux/Mac/WSL) +```bash +# クローンとビルド git clone https://github.com/moe-charm/nyash.git cd nyash +cargo build --release --features cranelift-jit -# 2. WebAssemblyバージョンビルド -cd projects/nyash-wasm -./build.sh - -# 3. ブラウザーでプレイグラウンドを開く -# 任意の現代ブラウザーでnyash_playground.htmlを開く +# 最初のプログラムを実行 +echo 'print("Hello Nyash!")' > hello.nyash +./target/release/nyash hello.nyash ``` -### ネイティブ開発 - -#### 🐧 Linux/WSL +### Windows ```bash -# ネイティブバージョンビルド -cargo build --release - -# プログラムをローカルで実行 -./target/release/nyash program.nyash - -# 例を試す -./target/release/nyash test_async_demo.nyash -./target/release/nyash app_dice_rpg.nyash -``` - -#### 🪟 Windows版 (クロスコンパイル) -```bash -# クロスコンパイラーインストール +# Windows向けクロスコンパイル cargo install cargo-xwin - -# Windows実行ファイルビルド cargo xwin build --target x86_64-pc-windows-msvc --release - -# 生成された実行ファイル (916KB) -target/x86_64-pc-windows-msvc/release/nyash.exe +# target/x86_64-pc-windows-msvc/release/nyash.exe を使用 ``` --- -## 🎯 **対象ユーザー** +## 🌟 **独自のイノベーション** -- 🎨 **クリエイター**: アーティスト、ゲーム開発者 -- 🎓 **教育者**: プログラミング講師、学生 -- 🌐 **Web開発者**: インタラクティブコンテンツ制作者 -- 🔬 **研究者**: 新しいプログラミングパラダイムの探求者 +### 1. **AI駆動開発** +- Claude、ChatGPT、Codexの協力で開発 +- コンセプトからネイティブコンパイルまで20日間の旅 +- AIが言語開発を30倍加速できることを証明 + +### 2. **Box-Firstアーキテクチャ** +- すべての最適化がBox抽象を保持 +- プラグインもBox、JITもBoxを保持、ネイティブコードもBoxを尊重 +- すべての実行モードで前例のない一貫性 + +### 3. **観測可能な設計** +- 組み込みのデバッグとプロファイリング +- JITコンパイルのJSONイベントストリーム +- 最適化のDOTグラフ可視化 + +--- + +## 📚 **例** + +### Python統合 +```nyash +// NyashからPythonライブラリを使用! +local py = new PyRuntimeBox() +local np = py.import("numpy") +local array = np.getattr("array").call([1, 2, 3]) +print("NumPy配列: " + array.str()) +``` + +### Webサーバー +```nyash +local server = new HttpServerBox() +server.start(8080) + +loop(true) { + local request = server.accept() + local response = new HttpResponseBox() + response.setStatus(200) + response.write("Nyashからこんにちは!") + request.respond(response) +} +``` + +### ゲーム開発 +```nyash +box GameObject { + init { x, y, sprite } + + update(deltaTime) { + // 物理シミュレーション + me.y = me.y + gravity * deltaTime + } + + render(canvas) { + canvas.drawImage(me.sprite, me.x, me.y) + } +} +``` --- ## 🤝 **貢献** -Nyashはオープンソースで、貢献を歓迎しています! - -- **Issues**: バグ報告、機能リクエスト -- **Pull Requests**: コード改善、新しい例 -- **ドキュメント**: ガイドと例の改善支援 -- **コミュニティ**: Nyash作品を共有! +革命に参加しよう!以下を歓迎します: +- 🐛 バグ報告と修正 +- ✨ プラグイン経由の新しいBox型 +- 📚 ドキュメントの改善 +- 🎮 クールなサンプルプログラム ## 📄 **ライセンス** -MIT ライセンス - 個人および商用利用無料。 +MIT ライセンス - プロジェクトで自由に使用してください! --- -## 🔗 **リンク** - -- **[🎮 今すぐ試す - ブラウザープレイグラウンド](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html)** -- **[📚 ドキュメント](docs/)** -- **[🎯 例](examples/)** -- **[💬 コミュニティディスカッション](https://github.com/moe-charm/nyash/discussions)** - ## 👨‍💻 **作者** -**Moe Charm** - プログラミング言語デザイナー・開発者 -- 🐙 GitHub: [@moe-charm](https://github.com/moe-charm) -- 🐦 Twitter/X: [@CharmNexusCore](https://x.com/CharmNexusCore) -- ☕ 開発サポート: [coff.ee/moecharmde6](http://coff.ee/moecharmde6) - -*AI支援と献身的開発で革新的プログラミング言語を創造 🤖* +**Tomoaki** - 言語設計者&革命家 +- 🐱 GitHub: [@moe-charm](https://github.com/moe-charm) +- 🌟 協力: Claude、ChatGPT、Codexとのコラボレーション --- -## 🤖 **プロジェクトのサポート** +## 🎉 **歴史的タイムライン** -Nyashは最先端のAI協業で開発されています! +- **2025年8月9日**: 最初のコミット - "Hello Nyash!" +- **2025年8月13日**: JIT計画開始(4日目!) +- **2025年8月20日**: VMが13.5倍性能達成 +- **2025年8月29日**: ネイティブEXEコンパイル実現! -継続的な開発をサポートしたい場合: - -**☕ [開発サポート](http://coff.ee/moecharmde6)** - イノベーションの燃料を! - -*Claude Code による支援 - 高度なAI開発ツールは無料ではありません! 🤖* - -あなたのサポートはプロジェクトの維持、新機能の開発、プログラミング言語設計の境界を押し広げることに役立ちます。すべての貢献が違いを生みます! 🙏 +*ゼロからネイティブバイナリまで20日間 - 言語開発の新記録!* --- -*❤️、🤖 Claude Code、そしてEverything is Box哲学で構築* +**🚀 Nyash - すべてがBoxであり、Boxがネイティブコードにコンパイルされる場所!** -**Nyash - すべての値がBoxであり、すべてのBoxが物語を語る場所。** +*❤️、🤖 AIコラボレーション、そしてプログラミング言語は思考の速度で作れるという信念で構築* \ No newline at end of file diff --git a/README.md b/README.md index 34b3a974..3b398b13 100644 --- a/README.md +++ b/README.md @@ -1,305 +1,331 @@ # 🐱 Nyash Programming Language -**Next-Generation Browser-Native Programming Experience** +**From Zero to Native Binary in 20 Days - The AI-Powered Language Revolution** *[🇯🇵 日本語版はこちら / 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) +[![Performance](https://img.shields.io/badge/Performance-13.5x%20Faster-ff6b6b.svg)](#performance) +[![JIT Ready](https://img.shields.io/badge/JIT-Cranelift%20Powered-orange.svg)](#execution-modes) [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](#license) --- -## 🚀 **Try Nyash Right Now!** +## 🚀 **Breaking News: Native EXE Achieved!** -**No installation, no setup - just open and code!** +**August 29, 2025** - Just 20 days after inception, Nyash can now compile to native executables! -👉 **[🎮 Launch Nyash Browser Playground](https://moe-charm.github.io/nyash/projects/nyash-wasm/nyash_playground.html)** 👈 +```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! +``` -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 +**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 --- -## ✨ **Why Nyash Changes Everything** +## ✨ **Why Nyash?** -### 🎯 **Memory Safety Revolution** +### 🎯 **Everything is Box Philosophy** ```nyash -// Traditional languages: manual memory management, crashes, security issues -// Nyash: Everything is Box - automatic, safe, elegant +// Traditional languages have complex type systems +// Nyash: One concept rules them all - Box static box Main { - init { player, enemies, canvas } - main() { - me.player = new PlayerBox("Hero", 100) - me.canvas = new WebCanvasBox("game", 800, 600) + // Every value is a Box - unified, safe, simple + local name = new StringBox("Nyash") + local count = new IntegerBox(42) + local data = new MapBox() - // 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() + // Even Python objects are Boxes! + local py = new PyRuntimeBox() + local math = py.import("math") + print("sqrt(9) = " + math.getattr("sqrt").call(9).str()) - // Your program logic here - return runGameLoop() + return 0 } } ``` -### Visual Debug Integration +### ⚡ **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! + +### 🔌 **Plugin-First Architecture** ```nyash -debug = new DebugBox() -debug.startTracking() +// 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 -player = new PlayerBox("Hero") -debug.trackBox(player, "Main Character") - -// Real-time memory visualization in browser! -print(debug.memoryReport()) // Live stats, no debugging hell +// Plugins compile to native code too! ``` --- -## 🎮 **Perfect for Creative Coding** +## 🏗️ **Multiple Execution Modes** -### 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 +### 1. **Interpreter Mode** (Development) +```bash +./target/release/nyash program.nyash +``` +- Instant execution +- Full debug information +- Perfect for development -### 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 +### 2. **VM Mode** (Production) +```bash +./target/release/nyash --backend vm program.nyash +``` +- 13.5x faster than interpreter +- Optimized bytecode execution +- Production-ready performance -### 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 +### 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 + +### 4. **Native Binary** (Distribution) +```bash +./tools/build_aot.sh program.nyash -o myapp +./myapp # Standalone executable! +``` +- Zero dependencies +- Maximum performance +- Easy distribution + +### 5. **WebAssembly** (Browser) +```bash +./target/release/nyash --compile-wasm program.nyash +``` +- Run in browsers +- Cross-platform by default +- Web-first development --- -## 📖 **Language Highlights** +## 📊 **Performance Benchmarks** -### Clean, Expressive Syntax +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 +``` + +--- + +## 🎮 **Language Features** + +### Clean Syntax ```nyash -// Object-oriented programming made natural -box Player { - init { name, health, inventory } +box GameCharacter { + init { name, health, skills } - Player(playerName) { - me.name = playerName + // Birth constructor - giving life to Boxes! + birth(characterName) { + me.name = characterName me.health = 100 - me.inventory = new ArrayBox() + me.skills = new ArrayBox() + print("🌟 " + characterName + " has been born!") } - takeDamage(amount) { - me.health = me.health - amount - if me.health <= 0 { - me.respawn() - } + learnSkill(skill) { + me.skills.push(skill) + return me // Method chaining } +} + +// Usage +local hero = new GameCharacter("Neko") +hero.learnSkill("Fire Magic").learnSkill("Healing") +``` + +### Modern Async/Await +```nyash +// 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 +``` + +### Delegation Pattern +```nyash +// Composition over inheritance +box EnhancedArray from ArrayBox { + init { logger } - respawn() { - me.health = 100 - print(me.name + " respawned!") + override push(item) { + me.logger.log("Adding: " + item) + from ArrayBox.push(item) // Delegate to parent } } ``` -### 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) +## 🔌 **Plugin System** + +Nyash pioneered the "Everything is Plugin" architecture: + +```toml +# nyash.toml - Plugin configuration +[libraries."libnyash_python_plugin.so"] +boxes = ["PyRuntimeBox", "PyObjectBox"] + +[libraries."libnyash_net_plugin.so"] +boxes = ["HttpServerBox", "HttpClientBox", "WebSocketBox"] ``` -### Generic Programming -```nyash -// Type-safe generic containers -box Container { - init { value } - - Container(item) { me.value = item } - getValue() { return me.value } -} - -numbers = new Container(42) -texts = new Container("Hello") -``` +Create your own Box types in C/Rust and integrate seamlessly! --- ## 🛠️ **Getting Started** -### Browser Development (Recommended) +### Quick Install (Linux/Mac/WSL) ```bash -# 1. Clone repository +# Clone and build git clone https://github.com/moe-charm/nyash.git cd nyash +cargo build --release --features cranelift-jit -# 2. Build WebAssembly version -cd projects/nyash-wasm -./build.sh - -# 3. Open playground in browser -# Open nyash_playground.html in any modern browser +# Run your first program +echo 'print("Hello Nyash!")' > hello.nyash +./target/release/nyash hello.nyash ``` -### Native Development - -#### Linux/WSL +### Windows ```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 +# Cross-compile for Windows cargo install cargo-xwin - -# Build Windows executable cargo xwin build --target x86_64-pc-windows-msvc --release +# Use target/x86_64-pc-windows-msvc/release/nyash.exe +``` -# Generated executable (916KB) -target/x86_64-pc-windows-msvc/release/nyash.exe +--- + +## 🌟 **Unique Innovations** + +### 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 + +### 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 + +### 3. **Observable by Design** +- Built-in debugging and profiling +- JSON event streams for JIT compilation +- DOT graph visualization of optimizations + +--- + +## 📚 **Examples** + +### 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()) +``` + +### 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** -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! +Join the revolution! We welcome: +- 🐛 Bug reports and fixes +- ✨ New Box types via plugins +- 📚 Documentation improvements +- 🎮 Cool example programs ## 📄 **License** -MIT License - Free for personal and commercial use. +MIT License - Use freely in your projects! --- -## 🔗 **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 🤖* +**Tomoaki** - Language Designer & Revolutionary +- 🐱 GitHub: [@moe-charm](https://github.com/moe-charm) +- 🌟 Created with: Claude, ChatGPT, Codex collaboration --- -## 🤖 **Support the Project** +## 🎉 **Historical Timeline** -Nyash is developed with cutting-edge AI collaboration! +- **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! -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! 🙏 +*20 days from zero to native binary - a new record in language development!* --- -*Built with ❤️, 🤖 Claude Code, and the Everything is Box philosophy* +**🚀 Nyash - Where Everything is a Box, and Boxes Compile to Native Code!** -**Nyash - Where every value is a Box, and every Box tells a story.** \ No newline at end of file +*Built with ❤️, 🤖 AI collaboration, and the belief that programming languages can be created at the speed of thought* \ No newline at end of file