Hey HN! I've been working on cppbolt, a lightweight C++ to WebAssembly compiler written in Rust.
The idea was to build something that can compile and run C++ directly in the browser without downloading a massive LLVM/Clang toolchain.
Unlike projects that bundle LLVM/Clang and can require 100+ MB of compiler assets, cppbolt's compiler payload is around 1 MB. It compiles a supported subset of C++17 directly to standard WebAssembly binaries.
Some things it supports: - Classes, inheritance, virtual functions and operator overloading - Templates and a subset of the C++ standard library - Pointers, references, arrays and dynamic memory - Lambdas, structured bindings and range-based loops
It comes with a browser playground, CLI and npm package.
A few caveats: this is still a work in progress, it doesn't implement the full C++17 standard, and it might not work as expected with certain C++ programs. I'm particularly interested in feedback on the compiler architecture, language support and potential use cases and also interested in connecting with someone who might want to use it in their application.
Try it out: - Playground: https://ajtimepyro.is-a.dev/cppbolt/ - Docs: https://ajtimepyro.is-a.dev/cppbolt/book/ - GitHub: https://github.com/AJTimePyro/cppbolt - npm: https://www.npmjs.com/package/cppbolt
Would love to hear what you think, especially from people who've worked on compilers or WebAssembly.
Comments URL: https://news.ycombinator.com/item?id=50369009
Points: 3
# Comments: 1
