Files
hakorune/docs/development/roadmap/phases/phase-12/WHY-AIS-FAILED.md
Moe Charm c9366d5c54 Phase 11.8/12: MIR Core-13 roadmap, Nyash ABI design, async/await enhancements with TaskGroupBox foundation
Major additions:
- Phase 11.8 MIR cleanup specification (Core-15→14→13 roadmap)
- Nyash ABI unified design document (3×u64 structure)
- TaskGroupBox foundation with cancelAll/joinAll methods
- Enhanced async/await with checkpoint auto-insertion
- Structured concurrency preparation (parent-child task relationships)

Documentation:
- docs/development/roadmap/phases/phase-11.8_mir_cleanup/: Complete Core-13 path
- docs/development/roadmap/phases/phase-12/NYASH-ABI-DESIGN.md: Unified ABI spec
- Updated Phase 12 README with AOT/JIT explanation for script performance
- Added async_task_system/ design docs

Implementation progress:
- FutureBox spawn tracking with weak/strong reference management
- VM checkpoint integration before/after await
- LLVM backend async support preparation
- Verifier rules for await-checkpoint enforcement
- Result<T,E> normalization for timeout/cancellation

Technical insights:
- MIR as 'atomic instructions', Box as 'molecules' philosophy
- 'Everything is Box' enables full-stack with minimal instructions
- Unified BoxCall for array/plugin/async operations future consolidation

Next steps:
- Complete TaskGroupBox implementation
- Migrate from global to scoped task management
- Implement LIFO cleanup on scope exit
- Continue Core-13 instruction consolidation

🚀 'From 15 atoms to infinite programs: The Nyash Box Theory'
2025-09-02 03:41:51 +09:00

131 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# なぜ天才AIたちは間違えたのか - Phase 12の教訓
## 🤔 根本的な誤解
### AIたちの誤解
```
「スクリプトプラグイン」という特別な仕組みが必要
→ JIT/AOTから呼び出せない問題がある
→ 複雑な解決策が必要
```
### 実際の真実
```
Nyashスクリプト = 普通のユーザー定義Box
→ すでに動いている
→ 何も問題ない
```
## 💡 なぜこんな誤解が生まれたのか
### 1. 「プラグイン」という言葉の罠
- AI思考「プラグイン = 外部DLL/SO = 特別な仕組み」
- 実際:「プラグイン = 再利用可能なBox = 普通のユーザー定義Box」
### 2. 実装レイヤーの混同
```
AIの頭の中
┌─────────────────────┐
│ JIT/AOT (最適化層) │ ← ここに固執
├─────────────────────┤
│ C ABI プラグイン │
├─────────────────────┤
│ スクリプトプラグイン │ ← 新しい層を作ろうとした
└─────────────────────┘
実際のNyash
┌─────────────────────┐
│ Nyash VM/インタープリター │
├─────────────────────┤
│ すべてがBox統一層
│ - ビルトインBox │
│ - C ABIプラグイン │
│ - ユーザー定義Box │ ← これだけで十分!
└─────────────────────┘
```
### 3. 過度な最適化思考
- AI「JIT/AOTで高速化しなければ
- 実際:「インタープリター言語として十分高速」
### 🚀 なぜスクリプトファイルでも高速なのか
**重要な真実NyashはAOT/JITをサポートしている**
```bash
# スクリプトファイルをAOTコンパイル可能
./nyash --aot script.nyash -o script.exe
# JITで実行ホットコードを自動最適化
./nyash --backend vm --jit script.nyash
```
つまり:
1. **開発時**: スクリプトファイルで即座に実行・修正
2. **本番時**: AOTコンパイルで最高速度
3. **中間**: JITで自動的に最適化
**スクリプト言語の利便性 + ネイティブコードの速度 = 両方手に入る!**
### 4. Everything is Boxの哲学を忘れた
```nyash
# これが既に「スクリプトプラグイン」!
box DataProcessor {
init {
me.file = new FileBox() # C ABIプラグイン
me.math = new MathBox() # C ABIプラグイン
me.cache = new MapBox() # ビルトインBox
}
process(data) {
# 全部普通に動く!
local result = me.math.sin(data)
me.file.write("log.txt", result.toString())
return result
}
}
```
## 🎓 教訓
### 1. シンプルな解決策を見逃すな
- 複雑な問題に見えても、既存の仕組みで解決できることが多い
- 「Everything is Box」は強力な統一原理
### 2. 言葉に惑わされるな
- 「プラグイン」→「特別な仕組み」という連想を避ける
- 本質を見る:「再利用可能なコード」
### 3. ユーザー視点を忘れるな
```nyash
# ユーザーから見れば、これで十分!
local processor = new DataProcessor()
local result = processor.process(3.14)
```
### 4. AIの弱点
- 技術用語から過度に複雑な解釈をしがち
- 既存の解決策より新しい仕組みを作りたがる
- レイヤーを増やしたがる傾向
## 📝 Phase 12の本当の価値
### 実は必要なのは
1. **export/import構文**ファイル間でBoxを共有
2. **パッケージマネージャー**Boxの配布・インストール
3. **ドキュメント生成**Boxの使い方を共有
### 必要ないもの
- 特別な「スクリプトプラグイン」層
- JIT/AOT統合
- 複雑なトランスパイル
## 🚀 結論
**Nyashは最初から正しかった。Everything is Boxだから、すべてが統一的に動く。**
AIたちは「プラグイン」という言葉に惑わされて、存在しない問題を解決しようとしていた。
---
*時に、最も賢い解決策は「何もしないこと」である。*