JVM, Wasmバイトコード生成、
Toshiaki Maki
2026-11-28
Toshiaki Maki @making
なんで
そもそも
黒歴史
なんで
なんで
pythonコマンドではなく(* (+ 10 20) 4) ; => 120rontoは
人間は
"ronto"の
なんで
ディズニーに
rontolispとは
一つの
.class や .jar を.wasm を、https://github.com/making/rontolisp
コアライブラリは
今と
rontolispとは
https://github.com/making/rontolisp/releases/tag/0.1.0-SNAPSHOTから
echo '(print (+ 1 2))' > hello.lisp
rontolisp # REPL
rontolisp hello.lisp # インタプリタ
rontolisp hello.lisp -o Hello.class # JVM
java Hello
rontolisp hello.lisp -o hello.wasm # Wasm
wasmtime run hello.wasm
rontolisp hello.lisp -o hello --native # native image
./hello
rontolispとは
この
(defun fact (n)
(if (= n 0) 1 (* n (fact (- n 1)))))
(print (fact 10))Run で 3628800 が
rontolispとは
;; ソースコード
(10 + 20) * 4
;; Lexer(字句解析)
LPAREN INT(10) OP(+) INT(20) RPAREN OP(*) INT(4)
;; Parser(構文解析)
Binary(*, Binary(+, 10, 20), 4)
rontolispとは
.class.wasmS式は(* (+ 10 20) 4)。
rontolispとは
cond、and、or、setf などは、if、let、progn、setq などに
(defun sign (x)
(cond ((< x 0) 'neg)
((= x 0) 'zero)
(t 'pos)))
rontolispとは
rontolisp xxxx.lisp --dump-ir は
(defun sign (x)
(if (< x 0) 'neg
(if (= x 0) 'zero 'pos)))
rontolispとは
;; rontolisp add1.lisp -o Add1.class
(defun add1 (x) (+ x 1))
aload_0
checkcast java/lang/Long ; 引数を取り出す
invokevirtual java/lang/Long.longValue:()J
lconst_1
invokestatic java/lang/Math.addExact:(JJ)J ; 1 を足す
invokestatic java/lang/Long.valueOf:(J)Ljava/lang/Long;
areturn
Javaコンパイラが
rontolispとは
;; rontolisp add1.lisp --no-gc -o add1.wasm
(defun add1 (x) (+ x 1))
local.get 0
i64.const 1
i64.add ; 1 を足す
Wasmも
rontolispとは
| Java | Wasm |
|---|---|
| クラスファイル | .wasm |
| JVM | wasmtime、 |
| JVMの | WasmGC |
System.out、 | WASI |
Wasmは
rontolispとは
mainをmainに_startからfd_writeのようなrontolispとは
| フラグ | 形式 | Javaで | 動く |
|---|---|---|---|
| なし | WASI Preview 1 | mainを | wasmtime runまたは |
--component | WASI 0.3 | Servletの | 同上 |
--no-wasi | Reactor | mainの | ブラウザ、 |
--no-gc | Reactor | 数値と | どの |
rontolispとは
(ql:quickload "clack") ; ライブラリを読み込む
(defun app (env) ; リクエストを受け取る関数
(list 200 ; ステータス
'(:content-type "text/plain") ; ヘッダ
'("Hello World!"))) ; ボディ
(clack:clackup #'app :server :rontolisp
:port 8080
:use-thread nil) ; 起動
rontolispとは
| デプロイ先 | ビルド | 実行 |
|---|---|---|
| JDK HTTP Server | -o app.jar | java -jar app.jar |
| Servlet | -o app.war | Tomcatなどに |
| WASI HTTP | -o app.wasm --component | wasmtime serve -S cli app.wasm |
| Cloudflare Workers | -o worker.wasm --no-wasi | wrangler deploy |
| ビルドした | -o app --native | ./app |
rontolispとは
| API | 使いどころ |
|---|---|
| パターンマッチング | 25種類の |
| Class-File API | JVMの |
| Virtual Thread | HTTPサーバで、 |
| Flow API | HTTPクライアントの |
| Vector API | --simdオプションの |
| FFM | BLAS、 |
rontolispとは
S式で
ブログの
ブログ記事の
rontolispの
.class.wasmASTと
rontolispの
.class.wasm違うのは
rontolispの
Common Lisp
;; sq.lisp
(defun sq (x) (* x x))
(print (sq 12))Scheme
;; sq.scm
(define (sq x) (* x x))
(display (sq 12))Clojure
;; sq.clj
(defn sq [x] (* x x))
(println (sq 12))どの
rontolispの
ここまで
一般的な
S式=AST。
rontolispの
rontolispの
理論上は、
任意の
第一弾は Starlark
rontolispの
def square(x):
return x * x
print([square(i) for i in range(5)])Starlarkの
第2弾は Java
rontolispの
void main() {
IO.println("Hello World!");
}rontolispの
static int square(int x) {
return x * x;
}
void main() {
IO.println(IntStream.range(0, 5)
.mapToObj(x -> square(x))
.toList());
}rontolispの
$ rontolisp --source-language java
java> var list = new ArrayList<String>()
list ==> []
java> list.add("a")
$1 ==> true
java> list
$2 ==> [a]
jshellのような
rontolispの
record Point(int x, int y) {
}
void main() {
Point p = new Point(10, 20);
String description = switch (p) {
case Point(int x, int y) when x == y -> "y = x 上の点: " + p;
case Point(int x, int y) -> "座標: " + p;
case null -> "null のため座標なし";
};
IO.println(description);
}rontolispの
import module java.net.http;
void main() throws IOException, InterruptedException {
var client = HttpClient.newHttpClient();
var uri = URI.create("https://httpbin.ik.am/get");
var request = HttpRequest.newBuilder(uri).build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
IO.println(response.statusCode() + "\n----\n" + response.body());
}JDKは
rontolispの
import am.ik.servlet.httpserver.ServletHttpServer;
import jakarta.servlet.http.*;
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws java.io.IOException {
res.setContentType("text/plain;charset=UTF-8");
res.getWriter().println("Hello World!");
}
void main() throws Exception {
ServletHttpServer.builder().port(8080)
.servlet("hello", new HelloServlet(), s -> s.urlPatterns("/"))
.start();
}
}
rontolispの
rontolisp \
HelloServlet.java \
--component -o hello-servlet.wasm \
--java-source-dep am.ik.servlet:servlet-httpserver:0.1.0-SNAPSHOT \
--java-snapshots
wasmtime serve hello-servlet.wasm
Clackで
JDK HTTP Serverが
rontolispの
mvn rontolisp:wasm)rontolispは
rontolispの
.lisp Common Lisp --+ +-- Interpreter (REPL)
.scm Scheme --+ +-- JVM: .class / .jar
.clj Clojure --+--> S-expressions -----+-- WASM (WasmGC): WASI Preview 1,
.star Starlark --+ (core Lisp forms) | WASI 0.3 component
.java Java --+ +-- WASM (--no-gc): MVP module
+-- Native executable (--native)
rontolispは
rontolispは
Opus
Fable
Sonnet
その
2月
41
3-5月
0
6月
169
7月
575
8月
1316
9月
2166
10月
2406
11月
1769
コミットの Co-Authored-By から
rontolispは
| モデル | サービス | 9月 | 10月 | 11月 |
|---|---|---|---|---|
| Muse Spark 1.3 | OpenCode Go | 229 | 408 | |
| Qwen3.8-Flash-Next | ローカルLLM | 47 | ||
| DeepSeek V4.1 | ローカルLLM | 26 | 52 | |
| GLM-5.3-Flash | ローカルLLM | 31 | 21 |
rontolispは
DGX Spark (互換機) を
8月以降、
こちらを
rontolispは
;; 第1フェーズ
<やりたいこと>を実現するためのSpikeを実施し、
実現するためのtodoをファイルに書き出して
→ todoファイルが
;; 第2フェーズ
あなたはオーケストレータです。サブエージェントを立てて、
Todo 001からNNNまでを消化して。各Todoはworktreeで作業し、
完了する毎にコミット&pushとworktreeの削除。並列4件まで。
各Todoへの指示は「Todo NNNに着手して」「終わったらコミット&push」
くらいでよい。新しく発生したTodoは再帰的にキューへ回して。
→ 寝ている
rontolispは
価値の
ただし、
rontolispは
ArchUnit
パッケージの
Nullability Maven Plugin
JSpecify + NullAwayを
こちらの SKILLを
rontolispは
| 困りごと | どうした |
|---|---|
| ラップトップが | ベアメタル |
| フルテストが | タスク単位では |
| 落ちた | 数タスク分ためて、 |
| CIに | CI対象の |
端末の
まとめ
まとめ
rontolispも