一种纯粹的 Scheme Web 编程工具
A pure scheme web programming tool

原始链接: https://goeteia.dev

该项目是一个高性能、自托管且以 WebAssembly 为目标的 Scheme 编译器。主要特性包括: * **自托管与完整性:** 编译器使用其自身的 Scheme 子集编写,确保输出结果的字节级一致性及严格的定点验证。 * **Wasm 集成:** 利用原生 Wasm GC 进行高效内存管理(包括未装箱定点数、堆结构配对/记录),并借助 Wasm 异常处理提案实现低开销的 `call/cc`。 * **高性能运行时:** 具备真正的闭包、适当的尾递归调用(确保恒定的栈空间使用)以及卫生宏(syntax-rules/syntax-case)。 * **响应式 Web 栈:** 提供原生 Web 开发生态,包括响应式信号、基于 S 表达式的 DOM 渲染,以及用于直接与 JavaScript 交互的 FFI。 * **图形:** 为 3D/WebGL 提供响应式接口,允许使用 S 表达式定义场景和着色器,并将桥接开销降至最低。 * **无缝网络通信:** 实现了一种直接样式的 RPC 机制,能够在网络传输中保留 Scheme 数据类型(如分数),并辅以支持 R6RS 风格导入和死代码裁剪的库系统。 简而言之,这是一个强大且全栈的 Scheme 环境,旨在实现高效运作并与现代 Web 无缝集成。

一个新的 Web 编程工具 **Goeteia** 近日被引入 Hacker News 社区。该项目旨在利用 Scheme 构建 Web 应用程序,试图解决 JavaScript 长期以来缺乏静态可验证性以及在 DOM 操作中易出现静默错误的问题。 作者概述了该工具的三大核心功能: 1. **自托管 (Self-hosting):** 利用卫生宏 (hygienic macros) 在浏览器中直接运行环境。 2. **声明式 UI:** 将 HTML 和 CSS 视为 Scheme 结构,并通过宏进行扩展。 3. **数据通信:** 使用 S-表达式 (S-expressions) 实现无缝的服务器与客户端消息传递。 在讨论中,评论者指出,虽然手动编写 Scheme 可能较为困难,但 AI 辅助编程改变了这一局面。通过将 Scheme 视为一种“编译目标”,开发人员或许能够获得 JavaScript 和现代浏览器标准难以提供的可靠性与结构化优势。Goeteia 代表了一种尝试,旨在摆脱复杂且约束沉重的 JavaScript 框架,转而采用更稳健的函数式编程方法。
相关文章

原文

Self-hosting, to the byte

The compiler is written in the Scheme subset it compiles. The self-hosted build recompiles itself and the output is byte-identical — the fixpoint is checked in CI fashion on every change, and every test runs through both stages.

Native Wasm GC objects

Fixnums are unboxed i31refs, pairs and records are GC structs, eq? is one ref.eq. No shadow heap in JavaScript: the host supplies two byte-stream imports and nothing else.

Hygienic macros

syntax-rules and procedural syntax-case with fenders, nested ellipses and datum->syntax, running in a compile-time interpreter with hygiene by renaming.

Real closures, real tail calls

Typed function references with a fast per-arity entry and a generic entry per closure — variadic procedures and apply are cheap, and every tail call is a return_call. A 100M-iteration loop runs in constant stack, in ~150ms.

call/cc & dynamic-wind

Escape continuations ride the Wasm exception-handling proposal: capture is O(1), the normal path costs one try block, and winders unwind inner-to-outer on the way out.

A reactive web stack

(web sx) templates over fine-grained (web reactive) signals, an (web html) renderer, and a (web js) FFI that reaches straight into the host — this page is built with it.

3D and WebGL

(web three) builds reactive Three.js scenes the way sx builds DOM; (web gl) drives raw WebGL through a command buffer — one bridge call per frame — with shaders written as s-expressions in (web glsl). The title above is exactly this: dot-matrix glyphs, a vertex shader, one draw call.

Scheme-to-Scheme, no codec

When the backend is also Scheme (Igropyr), requests and replies are s-expressions — (rpc "/rpc" '(add 1 2 1/2)) comes back (ok 7/2), the exact ratio intact. (web fetch) makes it direct-style over Wasm JSPI; (web ws) / (web sse) push datum streams; (web json) handles everyone else.

Libraries

R6RS-style (library ...) files with (import (math utils)) resolution, dependencies first; exports are advisory because unused code is pruned anyway.

联系我们 contact @ memedata.com