Compile a JavaScript file to a standalone WebAssembly binary that runs without a JavaScript runtime.
Compile TypeScript or JavaScript to a native executable using Porffor's C backend and Clang or GCC.
Experiment with ahead-of-time JavaScript compilation to understand how JS engines work under the hood.
Research project, many JavaScript features are not yet supported, check the bench directory for currently working examples.
Porffor is an experimental JavaScript and TypeScript compiler that converts code to WebAssembly or native C binaries before it runs, rather than interpreting or compiling it at the moment of execution. This approach is called ahead-of-time compilation. The project describes itself as a research project, not intended for production use yet. Most JavaScript engines work by interpreting code on the fly or compiling it just in time while it runs. Porffor does all the compilation work upfront, so there is no interpreter or just-in-time compiler involved when the output actually executes. The generated WebAssembly includes no boilerplate runtime code and requires as few external imports as possible. Only input and output operations are pulled from the host environment. The compiler is built almost entirely from scratch in JavaScript. It uses the Acorn parser to read JavaScript source code into a syntax tree, then generates WebAssembly bytecode directly without relying on tools like Binaryen. The codebase includes its own WebAssembly optimizer, a partial constant evaluator, a WebAssembly disassembler, and a custom WebAssembly-to-C compiler called 2c. The command-line tool is available through npm. It can run JavaScript files directly, open a REPL, compile code to WebAssembly files, compile to native executables using a C compiler like Clang or GCC, or print C source code to standard output. The README is upfront that many JavaScript features are not yet supported, and it points to the bench directory for examples of what currently works. Versioning encodes the Test262 pass percentage in the minor version number, providing a public measure of how much of the JavaScript specification the compiler supports at any given point in time. The name comes from the Welsh word for purple. The project is released publicly on GitHub.
← canadahonk on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.