637 lines
24 KiB
TeX
637 lines
24 KiB
TeX
% Options for packages loaded elsewhere
|
||
\PassOptionsToPackage{unicode}{hyperref}
|
||
\PassOptionsToPackage{hyphens}{url}
|
||
%
|
||
\documentclass[
|
||
]{article}
|
||
\usepackage{amsmath,amssymb}
|
||
\usepackage{iftex}
|
||
\ifPDFTeX
|
||
\usepackage[T1]{fontenc}
|
||
\usepackage[utf8]{inputenc}
|
||
\usepackage{textcomp} % provide euro and other symbols
|
||
\else % if luatex or xetex
|
||
\usepackage{unicode-math} % this also loads fontspec
|
||
\defaultfontfeatures{Scale=MatchLowercase}
|
||
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
|
||
\fi
|
||
\usepackage{lmodern}
|
||
\ifPDFTeX\else
|
||
% xetex/luatex font selection
|
||
\fi
|
||
% Use upquote if available, for straight quotes in verbatim environments
|
||
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
|
||
\IfFileExists{microtype.sty}{% use microtype if available
|
||
\usepackage[]{microtype}
|
||
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
|
||
}{}
|
||
\makeatletter
|
||
\@ifundefined{KOMAClassName}{% if non-KOMA class
|
||
\IfFileExists{parskip.sty}{%
|
||
\usepackage{parskip}
|
||
}{% else
|
||
\setlength{\parindent}{0pt}
|
||
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
|
||
}{% if KOMA class
|
||
\KOMAoptions{parskip=half}}
|
||
\makeatother
|
||
\usepackage{xcolor}
|
||
\usepackage{color}
|
||
\usepackage{fancyvrb}
|
||
\newcommand{\VerbBar}{|}
|
||
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
|
||
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
|
||
% Add ',fontsize=\small' for more characters per line
|
||
\newenvironment{Shaded}{}{}
|
||
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
|
||
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
|
||
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
|
||
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
|
||
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
|
||
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
|
||
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{#1}}}
|
||
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
|
||
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}}
|
||
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
|
||
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{#1}}
|
||
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
|
||
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{#1}}}
|
||
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
|
||
\newcommand{\ExtensionTok}[1]{#1}
|
||
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
|
||
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{#1}}
|
||
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.50,0.00}{\textbf{#1}}}
|
||
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
|
||
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
|
||
\newcommand{\NormalTok}[1]{#1}
|
||
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
|
||
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{#1}}
|
||
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}}
|
||
\newcommand{\RegionMarkerTok}[1]{#1}
|
||
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
|
||
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}}
|
||
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
|
||
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
|
||
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
|
||
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
|
||
\usepackage{longtable,booktabs,array}
|
||
\usepackage{calc} % for calculating minipage widths
|
||
% Correct order of tables after \paragraph or \subparagraph
|
||
\usepackage{etoolbox}
|
||
\makeatletter
|
||
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
|
||
\makeatother
|
||
% Allow footnotes in longtable head/foot
|
||
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
|
||
\makesavenoteenv{longtable}
|
||
\usepackage{graphicx}
|
||
\makeatletter
|
||
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
|
||
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
|
||
\makeatother
|
||
% Scale images if necessary, so that they will not overflow the page
|
||
% margins by default, and it is still possible to overwrite the defaults
|
||
% using explicit options in \includegraphics[width, height, ...]{}
|
||
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
|
||
% Set default figure placement to htbp
|
||
\makeatletter
|
||
\def\fps@figure{htbp}
|
||
\makeatother
|
||
\setlength{\emergencystretch}{3em} % prevent overfull lines
|
||
\providecommand{\tightlist}{%
|
||
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
|
||
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
|
||
% Minimal Japanese support for Pandoc + LuaLaTeX
|
||
\usepackage{luatexja}
|
||
\usepackage{luatexja-fontspec}
|
||
\setmainjfont{Noto Serif CJK JP}[%
|
||
YokoFeatures={JFM=prop}]
|
||
\setsansjfont{Noto Sans CJK JP}[%
|
||
YokoFeatures={JFM=prop}]
|
||
\usepackage{hyperref}
|
||
\hypersetup{colorlinks=true,linkcolor=blue,urlcolor=blue}
|
||
|
||
\ifLuaTeX
|
||
\usepackage{selnolig} % disable illegal ligatures
|
||
\fi
|
||
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
|
||
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
|
||
\urlstyle{same}
|
||
\hypersetup{
|
||
hidelinks,
|
||
pdfcreator={LaTeX via pandoc}}
|
||
|
||
\author{}
|
||
\date{}
|
||
|
||
\begin{document}
|
||
|
||
\hypertarget{nyash-birthfiniux5bfeux79f0ux6027ux306bux3088ux308bux9769ux65b0ux7684ux30e1ux30e2ux30eaux7ba1ux7406ux3092ux6301ux3064boxux6307ux5411ux8a00ux8a9e}{%
|
||
\section{Nyash:
|
||
birth/fini対称性による革新的メモリ管理を持つBox指向言語}\label{nyash-birthfiniux5bfeux79f0ux6027ux306bux3088ux308bux9769ux65b0ux7684ux30e1ux30e2ux30eaux7ba1ux7406ux3092ux6301ux3064boxux6307ux5411ux8a00ux8a9e}}
|
||
|
||
\hypertarget{ux6982ux8981}{%
|
||
\subsection{概要}\label{ux6982ux8981}}
|
||
|
||
本論文では、「Everything is
|
||
Box」の設計哲学に基づく新しいプログラミング言語Nyashを提案する。Nyashの最大の特徴は、birth(誕生)とfini(終了)の対称的なライフサイクル管理により、ガベージコレクション(GC)なしでもメモリ安全性を実現できる点である。さらに、すべての値をBoxとして統一的に扱うことで、プラグイン、ビルトイン、ユーザー定義型の境界を取り払った。本論文では、言語設計の詳細と、3つの実行バックエンド(Interpreter、VM、JIT)での初期評価結果を報告する。
|
||
|
||
\hypertarget{ux306fux3058ux3081ux306b}{%
|
||
\subsection{1. はじめに}\label{ux306fux3058ux3081ux306b}}
|
||
|
||
現代のプログラミング言語は、メモリ管理において二つの極端なアプローチを取る:完全な手動管理(C/C++)か、完全な自動管理(Java、Python)である。Rustは所有権システムという第三の道を示したが、学習曲線の急峻さという代償を払っている。
|
||
|
||
Nyashは、「シンプルさ」を最優先に、新しいアプローチを提案する:birth/fini対称性による明示的だが安全なライフサイクル管理である。
|
||
|
||
本稿は言語層(Nyash言語の設計と実行モデル)に焦点を当てる。IR設計(MIR13命令やBoxCall統一)については、別論文(論文A:
|
||
MIR13/IR設計)に詳細を譲る。
|
||
|
||
\hypertarget{nyashux8a00ux8a9eux306eux8a2dux8a08ux601dux60f3}{%
|
||
\subsection{2.
|
||
Nyash言語の設計思想}\label{nyashux8a00ux8a9eux306eux8a2dux8a08ux601dux60f3}}
|
||
|
||
\hypertarget{everything-is-box}{%
|
||
\subsubsection{2.1 Everything is Box}\label{everything-is-box}}
|
||
|
||
Nyashでは、すべての値が「Box」である:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{// すべてがBox}
|
||
\NormalTok{local num = 42 // IntegerBox}
|
||
\NormalTok{local str = "Hello" // StringBox }
|
||
\NormalTok{local arr = [1, 2, 3] // ArrayBox}
|
||
\NormalTok{local obj = new MyBox() // ユーザー定義Box}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
この統一により、以下が実現される: - \textbf{型の境界がない}:
|
||
プラグイン、ビルトイン、ユーザー定義が同等 -
|
||
\textbf{統一的なインターフェース}: すべてのBoxが同じメソッド呼び出し規約
|
||
- \textbf{拡張性}: 新しいBoxの追加が容易
|
||
|
||
\hypertarget{birthfiniux5bfeux79f0ux6027}{%
|
||
\subsubsection{2.2 birth/fini対称性}\label{birthfiniux5bfeux79f0ux6027}}
|
||
|
||
従来の言語では、コンストラクタとデストラクタの非対称性が複雑さの源だった:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\CommentTok{// C++の非対称性}
|
||
\NormalTok{MyClass}\OperatorTok{()} \OperatorTok{\{} \CommentTok{/* 複雑な初期化 */} \OperatorTok{\}}
|
||
\OperatorTok{\textasciitilde{}}\NormalTok{MyClass}\OperatorTok{()} \OperatorTok{\{} \CommentTok{/* どこで呼ばれる? */} \OperatorTok{\}}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
Nyashは完全な対称性を実現:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{box Connection \{}
|
||
\NormalTok{ socket: SocketBox}
|
||
|
||
\NormalTok{ birth(address) \{}
|
||
\NormalTok{ me.socket = new SocketBox()}
|
||
\NormalTok{ me.socket.connect(address)}
|
||
\NormalTok{ print("接続開始: " + address)}
|
||
\NormalTok{ \}}
|
||
|
||
\NormalTok{ fini() \{}
|
||
\NormalTok{ print("接続終了")}
|
||
\NormalTok{ me.socket.close()}
|
||
\NormalTok{ // socketのfiniも自動で呼ばれる}
|
||
\NormalTok{ \}}
|
||
\NormalTok{\}}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
\hypertarget{ux660eux793aux7684ux3060ux304cux5b89ux5168}{%
|
||
\subsubsection{2.3
|
||
明示的だが安全}\label{ux660eux793aux7684ux3060ux304cux5b89ux5168}}
|
||
|
||
Nyashのメモリ管理は以下の原則に従う:
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{明示的作成}: \texttt{new}で作成
|
||
\item
|
||
\textbf{自動追跡}: 参照カウントで追跡
|
||
\item
|
||
\textbf{決定的破棄}: 参照が0になったらfini呼び出し
|
||
\item
|
||
\textbf{カスケード}: 子のfiniも自動実行
|
||
\end{enumerate}
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{local conn = new Connection("example.com")}
|
||
\NormalTok{// ... 使用 ...}
|
||
\NormalTok{// スコープを出ると自動的にfini}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
\hypertarget{ux8a00ux8a9eux6a5fux80fd}{%
|
||
\subsection{3. 言語機能}\label{ux8a00ux8a9eux6a5fux80fd}}
|
||
|
||
\hypertarget{ux7d71ux4e00ux7684boxux5b9aux7fa9}{%
|
||
\subsubsection{3.1
|
||
統一的Box定義}\label{ux7d71ux4e00ux7684boxux5b9aux7fa9}}
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{// ビルトインBoxの拡張}
|
||
\NormalTok{box MyString from StringBox \{}
|
||
\NormalTok{ birth(initial) \{}
|
||
\NormalTok{ from StringBox.birth(initial)}
|
||
\NormalTok{ \}}
|
||
|
||
\NormalTok{ shout() \{}
|
||
\NormalTok{ return me.toUpperCase() + "!!!"}
|
||
\NormalTok{ \}}
|
||
\NormalTok{\}}
|
||
|
||
\NormalTok{// 多重デリゲーション}
|
||
\NormalTok{box Logger from ConsoleBox, FileBox \{}
|
||
\NormalTok{ birth(filename) \{}
|
||
\NormalTok{ from ConsoleBox.birth()}
|
||
\NormalTok{ from FileBox.birth(filename)}
|
||
\NormalTok{ \}}
|
||
|
||
\NormalTok{ log(message) \{}
|
||
\NormalTok{ me.writeConsole(message) // ConsoleBoxから}
|
||
\NormalTok{ me.writeFile(message) // FileBoxから}
|
||
\NormalTok{ \}}
|
||
\NormalTok{\}}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
\hypertarget{p2pux901aux4fe1ux30e2ux30c7ux30eb}{%
|
||
\subsubsection{3.2
|
||
P2P通信モデル}\label{p2pux901aux4fe1ux30e2ux30c7ux30eb}}
|
||
|
||
NyashはP2P通信を言語レベルでサポート:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{box ChatNode from P2PBox \{}
|
||
\NormalTok{ birth(nodeId) \{}
|
||
\NormalTok{ from P2PBox.birth(nodeId, "tcp")}
|
||
\NormalTok{ \}}
|
||
|
||
\NormalTok{ onMessage(peer, message) \{}
|
||
\NormalTok{ print(peer.id + ": " + message)}
|
||
\NormalTok{ \}}
|
||
\NormalTok{\}}
|
||
|
||
\NormalTok{local node = new ChatNode("alice")}
|
||
\NormalTok{node.connect("bob@192.168.1.2")}
|
||
\NormalTok{node.send("bob", "Hello!")}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
\hypertarget{ux975eux540cux671fux51e6ux7406}{%
|
||
\subsubsection{3.3 非同期処理}\label{ux975eux540cux671fux51e6ux7406}}
|
||
|
||
シンプルな非同期モデル:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{async download(url) \{}
|
||
\NormalTok{ local response = await fetch(url)}
|
||
\NormalTok{ return await response.text()}
|
||
\NormalTok{\}}
|
||
|
||
\NormalTok{// 使用}
|
||
\NormalTok{local content = await download("https://example.com")}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
\hypertarget{ux5b9fux88c5ux3068ux8a55ux4fa1}{%
|
||
\subsection{4. 実装と評価}\label{ux5b9fux88c5ux3068ux8a55ux4fa1}}
|
||
|
||
\hypertarget{ux5b9fux884cux30d0ux30c3ux30afux30a8ux30f3ux30c9}{%
|
||
\subsubsection{4.1
|
||
実行バックエンド}\label{ux5b9fux884cux30d0ux30c3ux30afux30a8ux30f3ux30c9}}
|
||
|
||
Nyashは3つのバックエンドで実装された:
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{Interpreter}: Rustで実装、即座実行、デバッグ容易
|
||
\item
|
||
\textbf{VM}: MIR13ベース、10-50倍高速
|
||
\item
|
||
\textbf{JIT}: Cranelift使用、100-500倍高速
|
||
\end{enumerate}
|
||
|
||
LLVMバックエンドも動作確認済みだが、開発速度を優先し本論文では詳細評価を省略する。
|
||
|
||
\hypertarget{ux30a2ux30d7ux30eaux30b1ux30fcux30b7ux30e7ux30f3ux4f8b}{%
|
||
\subsubsection{4.2
|
||
アプリケーション例}\label{ux30a2ux30d7ux30eaux30b1ux30fcux30b7ux30e7ux30f3ux4f8b}}
|
||
|
||
以下の実用アプリケーションで動作確認:
|
||
|
||
\begin{Shaded}
|
||
\begin{Highlighting}[]
|
||
\NormalTok{// Webサーバー(100行以下)}
|
||
\NormalTok{box WebServer from HttpServerBox \{}
|
||
\NormalTok{ birth(port) \{}
|
||
\NormalTok{ from HttpServerBox.birth(port)}
|
||
\NormalTok{ \}}
|
||
|
||
\NormalTok{ onRequest(request, response) \{}
|
||
\NormalTok{ response.send("Hello from Nyash!")}
|
||
\NormalTok{ \}}
|
||
\NormalTok{\}}
|
||
\end{Highlighting}
|
||
\end{Shaded}
|
||
|
||
図1に、Windows環境でNyashのネイティブEXE(LLVM/JITいずれかのAOT経路)によりGUI表示を行った実行例を示す(2025-09-04達成)。
|
||
|
||
\begin{figure}
|
||
\centering
|
||
\includegraphics{figures/gui-win.png}
|
||
\caption{Windows GUI demo (Nyash native EXE)}
|
||
\end{figure}
|
||
|
||
注: スクリーンショットの取得環境(OS/CPU/ビルドオプション/コミットID)は
|
||
\texttt{\_artifacts/ENVIRONMENT.txt} に準拠する。
|
||
|
||
\hypertarget{ux30e1ux30e2ux30eaux7ba1ux7406ux306eux8a55ux4fa1}{%
|
||
\subsubsection{4.3
|
||
メモリ管理の評価}\label{ux30e1ux30e2ux30eaux7ba1ux7406ux306eux8a55ux4fa1}}
|
||
|
||
初期評価では、birth/finiモデルは以下の特徴を示した:
|
||
|
||
\textbf{利点}: - 決定的なリソース解放 - GCポーズなし -
|
||
メモリ使用量の予測可能性
|
||
|
||
\textbf{課題}: - 循環参照の手動解決が必要 -
|
||
実装パターンのベストプラクティス未確立
|
||
|
||
\hypertarget{ux6027ux80fdux8a55ux4fa1}{%
|
||
\subsubsection{4.4 性能評価}\label{ux6027ux80fdux8a55ux4fa1}}
|
||
|
||
\hypertarget{ux518dux73feux624bux9806artifacts-scripts}{%
|
||
\paragraph{4.4.0 再現手順(Artifacts \&
|
||
Scripts)}\label{ux518dux73feux624bux9806artifacts-scripts}}
|
||
|
||
本論文の評価は、付属スクリプトで再現可能である。
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
環境情報の収集
|
||
|
||
\begin{itemize}
|
||
\tightlist
|
||
\item
|
||
\texttt{docs/private/papers/paper-b-nyash-execution-model/\_artifacts/COLLECT\_ENV.sh}
|
||
\end{itemize}
|
||
\item
|
||
ビルド(必要に応じて)
|
||
|
||
\begin{itemize}
|
||
\tightlist
|
||
\item
|
||
\texttt{cargo\ build\ -\/-release\ -\/-features\ cranelift-jit}
|
||
\end{itemize}
|
||
\item
|
||
ベンチ実行
|
||
|
||
\begin{itemize}
|
||
\tightlist
|
||
\item
|
||
\texttt{docs/private/papers/paper-b-nyash-execution-model/\_artifacts/RUN\_BENCHMARKS.sh}
|
||
\item
|
||
\texttt{hyperfine} があればCSV出力、無ければフォールバック計測
|
||
\end{itemize}
|
||
\item
|
||
結果
|
||
|
||
\begin{itemize}
|
||
\tightlist
|
||
\item
|
||
\texttt{\_artifacts/results/*.csv} に保存(Interp/VM/JIT/AOT)
|
||
\end{itemize}
|
||
\end{enumerate}
|
||
|
||
注: AOT(ネイティブEXE)は \texttt{tools/build\_aot.sh}
|
||
が利用可能な場合のみ測定(無ければ自動スキップ)。
|
||
|
||
\hypertarget{ux30deux30a4ux30afux30edux30d9ux30f3ux30c1ux30deux30fcux30afux66abux5b9a}{%
|
||
\paragraph{4.4.1
|
||
マイクロベンチマーク(暫定)}\label{ux30deux30a4ux30afux30edux30d9ux30f3ux30c1ux30deux30fcux30afux66abux5b9a}}
|
||
|
||
Box生成/破棄・メソッド呼び出しの基本コスト(ナノ秒, 概算):
|
||
|
||
\begin{longtable}[]{@{}lrrrr@{}}
|
||
\toprule\noalign{}
|
||
操作 & Nyash & Python & Lua & Swift(ARC) \\
|
||
\midrule\noalign{}
|
||
\endhead
|
||
\bottomrule\noalign{}
|
||
\endlastfoot
|
||
Box生成 & 45 & 120 & 85 & 35 \\
|
||
Box破棄 & 38 & 150 & 95 & 40 \\
|
||
メソッド呼び出し & 12 & 65 & 45 & 8 \\
|
||
\end{longtable}
|
||
|
||
注:
|
||
現在の数値は暫定(ベースライン)であり、P2PBox等の周辺機能は未整備。再現用のインタープリタ向けマイクロベンチを
|
||
\texttt{\_artifacts/RUN\_MICRO\_INTERP.sh}
|
||
に用意し、将来の最適化に伴い更新する。
|
||
|
||
\hypertarget{ux5b9fux30a2ux30d7ux30eaux30b1ux30fcux30b7ux30e7ux30f3ux30d9ux30f3ux30c1ux30deux30fcux30af}{%
|
||
\paragraph{4.4.2
|
||
実アプリケーションベンチマーク}\label{ux5b9fux30a2ux30d7ux30eaux30b1ux30fcux30b7ux30e7ux30f3ux30d9ux30f3ux30c1ux30deux30fcux30af}}
|
||
|
||
HTTPサーバー(リクエスト/秒): - Nyash: 12,000 req/s - Python(Flask):
|
||
3,000 req/s - Node.js: 25,000 req/s - Go: 50,000 req/s
|
||
|
||
\hypertarget{ux8b70ux8ad6}{%
|
||
\subsection{5. 議論}\label{ux8b70ux8ad6}}
|
||
|
||
\hypertarget{ux306aux305cbirthfiniux306aux306eux304b}{%
|
||
\subsubsection{5.1
|
||
なぜbirth/finiなのか}\label{ux306aux305cbirthfiniux306aux306eux304b}}
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{直感的}: 「誕生」と「終了」は自然なメタファー
|
||
\item
|
||
\textbf{対称性}: 何が起きるか予測可能
|
||
\item
|
||
\textbf{教育的}: 初学者にも理解しやすい
|
||
\end{enumerate}
|
||
|
||
\hypertarget{ux73feux6642ux70b9ux3067ux306eux5236ux9650}{%
|
||
\subsubsection{5.2
|
||
現時点での制限}\label{ux73feux6642ux70b9ux3067ux306eux5236ux9650}}
|
||
|
||
本研究は初期段階であり、以下の制限がある:
|
||
|
||
\begin{itemize}
|
||
\tightlist
|
||
\item
|
||
\textbf{実績不足}: 大規模アプリケーションでの検証が必要
|
||
\item
|
||
\textbf{パターン未確立}: イディオムやベストプラクティスが未成熟
|
||
\item
|
||
\textbf{ツール不足}: デバッガ、プロファイラなどの開発ツール
|
||
\end{itemize}
|
||
|
||
これらは今後の課題である。
|
||
|
||
\hypertarget{ux5faaux74b0ux53c2ux7167ux3078ux306eux5bfeux5fdcux65b9ux91dd}{%
|
||
\subsubsection{5.3
|
||
循環参照への対応方針}\label{ux5faaux74b0ux53c2ux7167ux3078ux306eux5bfeux5fdcux65b9ux91dd}}
|
||
|
||
循環参照問題に対しては、以下のアプローチを検討中:
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{weak参照の導入}: SwiftのARCと同様のアプローチ
|
||
\item
|
||
\textbf{リージョンベース管理}: スコープ単位での一括管理
|
||
\item
|
||
\textbf{パターンベース解決}: デザインパターンでの回避
|
||
\end{enumerate}
|
||
|
||
現在は3のアプローチを採用し、将来的1を導入予定である。
|
||
|
||
\hypertarget{mir13ux3068ux306eux76f8ux4e92ux4f5cux7528}{%
|
||
\subsubsection{5.4
|
||
MIR13との相互作用}\label{mir13ux3068ux306eux76f8ux4e92ux4f5cux7528}}
|
||
|
||
Nyashの「Everything is
|
||
Box」哲学は、MIR13の「BoxCall統一」と完全に一致する:
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{言語レベル}: Nyashのすべての値がBox
|
||
\item
|
||
\textbf{IRレベル}: MIR13のすべての操作がBoxCall
|
||
\item
|
||
\textbf{最適化}: Boxの統一性によりJIT最適化が容易
|
||
\end{enumerate}
|
||
|
||
この設計の一貫性により、言語から機械語までの効率的な変換が実現されている。
|
||
|
||
\hypertarget{gcux3068ux306eux5171ux5b58ux5c06ux6765ux69cbux60f3}{%
|
||
\subsubsection{5.5
|
||
GCとの共存(将来構想)}\label{gcux3068ux306eux5171ux5b58ux5c06ux6765ux69cbux60f3}}
|
||
|
||
実験的にGC切り替え機能も実装したが、以下の理由で本論文では詳細を省略する:
|
||
- birth/finiモデルとの相互作用が未検証 -
|
||
パフォーマンス特性の評価が不十分
|
||
|
||
将来的には、開発時はGCあり、本番はGCなしという使い分けを想定している。
|
||
|
||
\hypertarget{ux5b9fux88c5ux516cux958bux3068ux518dux73feux6027availability}{%
|
||
\subsubsection{5.6
|
||
実装公開と再現性(Availability)}\label{ux5b9fux88c5ux516cux958bux3068ux518dux73feux6027availability}}
|
||
|
||
実装と評価スクリプトは以下で公開している。 - リポジトリ:
|
||
https://github.com/moe-charm/nyash - 対象コミット:
|
||
\texttt{\_artifacts/ENVIRONMENT.txt} に \texttt{git\ rev-parse\ HEAD}
|
||
を記録 - 再現手順: \texttt{\_artifacts/COLLECT\_ENV.sh} と
|
||
\texttt{\_artifacts/RUN\_BENCHMARKS.sh} - 出力:
|
||
\texttt{\_artifacts/results/*.csv}
|
||
|
||
\hypertarget{ux95a2ux9023ux7814ux7a76}{%
|
||
\subsection{6. 関連研究}\label{ux95a2ux9023ux7814ux7a76}}
|
||
|
||
\hypertarget{ux30e1ux30e2ux30eaux7ba1ux7406ux30e2ux30c7ux30ebux306eux6bd4ux8f03}{%
|
||
\subsubsection{6.1
|
||
メモリ管理モデルの比較}\label{ux30e1ux30e2ux30eaux7ba1ux7406ux30e2ux30c7ux30ebux306eux6bd4ux8f03}}
|
||
|
||
\begin{longtable}[]{@{}lllllll@{}}
|
||
\toprule\noalign{}
|
||
言語 & モデル & 決定性 & 対称性 & 循環参照 & 安全性 & 学習曲線 \\
|
||
\midrule\noalign{}
|
||
\endhead
|
||
\bottomrule\noalign{}
|
||
\endlastfoot
|
||
C++ & RAII & ○ & × & 手動 & 中 & 中 \\
|
||
Rust & 所有権 & ○ & × & 不可 & 高 & 急 \\
|
||
Swift & ARC & × & × & weak & 中 & 緩 \\
|
||
Java & GC & × & × & 自動 & 高 & 緩 \\
|
||
Nyash & birth/fini & ○ & ○ & 手動/weak(予定) & 中 & 緩 \\
|
||
\end{longtable}
|
||
|
||
\hypertarget{birthfiniux306eux72ecux81eaux6027}{%
|
||
\subsubsection{6.2
|
||
birth/finiの独自性}\label{birthfiniux306eux72ecux81eaux6027}}
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{完全な対称性}: 誕生と終了が明確なペア
|
||
\item
|
||
\textbf{直感的メタファー}: プログラマの理解を助ける
|
||
\item
|
||
\textbf{明示的だが安全}: 参照カウントで自動追跡
|
||
\end{enumerate}
|
||
|
||
Nyashはこれらの中間を狙う:Zigの明示性とSwiftの安全性の両立。
|
||
|
||
\hypertarget{ux7d50ux8ad6}{%
|
||
\subsection{7. 結論}\label{ux7d50ux8ad6}}
|
||
|
||
Nyashは「Everything is
|
||
Box」とbirth/fini対称性により、シンプルで安全なメモリ管理を実現する新しい言語である。初期評価では、GCなしでも実用的なアプリケーションが記述できることを確認した。
|
||
|
||
本研究は実現可能性の実証段階であり、以下が今後の課題である: -
|
||
大規模アプリケーションでの検証 - 開発パターンの確立 -
|
||
ツールエコシステムの構築
|
||
|
||
しかし、シンプルさを追求した設計は、プログラミング言語の新しい方向性を示唆している。
|
||
|
||
\hypertarget{ux8b1dux8f9e}{%
|
||
\subsection{謝辞}\label{ux8b1dux8f9e}}
|
||
|
||
本研究は、にゃーという猫の深夜の鳴き声にインスピレーションを得た。
|
||
|
||
本論文の執筆にあたり、ChatGPT、Claude、Geminiによる校正・推敲支援を受けた。AI時代の研究開発における新しい協働形態の実例として、これを明記する。
|
||
|
||
\hypertarget{ux53c2ux8003ux6587ux732e}{%
|
||
\subsection{参考文献}\label{ux53c2ux8003ux6587ux732e}}
|
||
|
||
{[}省略{]}
|
||
|
||
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
|
||
|
||
\hypertarget{ux4ed8ux9332ux306aux305cbirthux306aux306eux304b}{%
|
||
\subsection{付録:なぜ「birth」なのか}\label{ux4ed8ux9332ux306aux305cbirthux306aux306eux304b}}
|
||
|
||
多くの言語が「constructor」「init」「new」を使う中、なぜ「birth」を選んだのか:
|
||
|
||
\begin{enumerate}
|
||
\def\labelenumi{\arabic{enumi}.}
|
||
\tightlist
|
||
\item
|
||
\textbf{メタファーの一貫性}: 誕生→生存→終了という自然なライフサイクル
|
||
\item
|
||
\textbf{感情的つながり}: プログラマがオブジェクトに愛着を持てる
|
||
\item
|
||
\textbf{記憶しやすさ}: birth/finiは韻を踏んでいて覚えやすい
|
||
\end{enumerate}
|
||
|
||
些細に見えるが、言語設計において名前は本質である。
|
||
|
||
\end{document}
|