C compiler for Web Assembly (c4wa)

https://news.ycombinator.com/rss Hits: 5
Summary

C compiler for Web Assembly ( c4wa ) This is a compiler from a subset of C language to Web Assembly. If you're not familiar with Web Assembly, check out Wikipedia article. Web Assembly is a new universal executable format for the Web; it complements more traditional JavaScript for computationally intensive tasks or if there is a need to port to Web existing code written in other languages. Binary Web Assembly files have extension .wasm ; throughout this document, WASM is used both as the name for binary Web Assembly format and as a shortcut for Web Assembly. There are many compilers targeting Web Assembly; see for example a comprehensive list here. Why do we need another one? Here are some unique features of c4wa : It creates minimalistic well-optimized Web Assembly output without any "glue" to make it work with your application, without any embedded libraries, or any other overhead. This is simply C code translated as efficiently as possible to WASM; nothing more It is out of the box fully compatible with any WASM runtime; there are no dependencies on JavaScript or node It can efficiently utilize WASM linear memory model, making it possible to write applications with full dynamic memory allocation support and still only minimal overhead In addition to binary WASM format, it can output text-based WAT format, which is entirely readable, properly formatted and could be used for better understanding inner workings of the compiler, edited manually, copied to separate WASM projects, or used for teaching/learning Web Assembly and WAT format c4wa is not a full C implementation and isn't trying to be one. Still, most of the typical day-to-day coding targeting c4wa isn't much more complicated than coding in standard C. It supports loops, conditionals, block scope of variables, intermingled declarations, all of C operators and primitive types, struct s, arrays, pointers, variable arguments and dynamic memory allocation. It can also apply external C preprocessor to your code b...

First seen: 2025-06-28 02:29

Last seen: 2025-06-28 06:30