Show HN: Jaws – a JavaScript to WASM ahead-of-time compiler
Project goals and architecture
- Jaws is an ahead-of-time JavaScript → WebAssembly compiler that targets the newer WASM GC and exception-handling proposals rather than embedding a full JS engine.
- Focus is primarily server-side: run JS in a small, sandboxed WASM module instead of shipping V8/SpiderMonkey compiled to WASM.
evalwill be disabled by default; supporting it would require custom host functions since WASM cannot generate new code at runtime. Withouteval, aggressive dead-code and type-specific optimizations become possible.
Compatibility, semantics, and current status
- Early-stage project; currently implements “hard” semantic features first (closures, scopes, etc.).
- About 12% of Test262 passes so far, with many failures due to missing syntactic sugar (e.g., bracket property access, loops beyond
while,switch). - Async/await and generators are the last major “hard” semantics planned before focusing on built-ins and easier language constructs.
- ArrayBuffer and many JS built-ins (Map, Set, etc.) are not yet implemented.
I/O, runtimes, and environment integration
- Goal is to rely only on WASI (preview2) for I/O and Node-like APIs such as
fetchandfs, so any WASI-supporting runtime can host Jaws-compiled code. - Browser support would need polyfills/custom glue for I/O (e.g., local storage, in-browser databases, remote storage).
- Currently, only runtimes with WASM GC + exceptions (notably V8 and WasmEdge; others are in progress) can run the generated modules.
Performance and binary size
- Current binaries are only a few KB; target is on the order of tens of KB for simple scripts, vs. multiple MB for embedded JS engines.
- Memory usage is expected to be much lower than approaches that compile SpiderMonkey/V8 to WASM.
- It is considered unlikely to ever outperform modern JS engines with JIT; the value proposition is footprint and sandboxing, not raw speed.
Comparisons to related projects
- Compared to JS→WASM projects using only core WASM (e.g., porffor), Jaws offloads arrays, objects, GC, and exceptions to WASM proposals instead of reimplementing them.
- Compared to TypeScript→WasmGC tools (e.g., Wasmnizer-ts), Jaws targets full JS, avoids host-defined built-ins where possible, and plans to rely on WASI rather than large import objects.
- Future idea: consume TypeScript type annotations to specialize functions and avoid generic
anyrefhandling.
Naming debate
- Significant discussion about the name “Jaws” conflicting with the long-established JAWS screen reader (and the movie).
- Some argue the overlap is negligible given niches and search qualifiers; others, especially a screen reader user, note it could worsen discoverability of accessibility-related information.
- The author indicates willingness to rename (e.g., to “JAWSM”) in light of accessibility concerns.