$ show google/wuffs
Wuffs is a memory-safe programming language and toolchain for writing parsers and codecs, with C code generation as its primary output. The system provides a comprehensive library of decoders for image formats (JPEG, PNG, GIF, BMP, WebP, etc.), compression formats (Deflate, Zlib, Gzip, LZMA, XZ, BZip2, etc.), and checksums (CRC32, Adler32, SHA256). It is designed to eliminate buffer overflows, integer overflows, and null pointer dereferences at compile time through formal verification and interval arithmetic, without runtime overhead. The architecture consists of a custom DSL (Wuffs language) with a Go-based compiler (parser, type checker, optimizer), a C code generator that produces a single-file header-only C library, and a set of auxiliary C++ modules for high-level APIs. Key entry points include the `wuffs` CLI tool for managing packages and generating C code, the `wuffs-c` tool for C-specific operations, and the generated `wuffs-unsupported-snapshot.c` file that can be dropped into any C project. External dependencies are minimal: the development toolchain requires Go, but the generated C library has no dependencies beyond standard C. The system is used in production (e.g., GIF decoder in Google Chrome) and is benchmarked as 1.3–6× faster than equivalent C libraries.
The LLM identified 4 files worth highlighting for reuse:
Provides arbitrary-precision interval arithmetic for integer ranges, supporting operations like Add, Mul, And, Or, and comparisons. Used by the Wuffs compiler for compile-time bounds checking, but is a self-contained Go package that can be reused in any project requiring safe integer range analysis.
Implements a novel, very lossy image thumbnail format (Handsum) with configurable quality (1–4). Contains DCT transforms, quantization, chroma downsampling, and Huffman-like encoding in a single Go package. Reusable as a standalone image encoder/decoder with no external dependencies beyond the standard library.
Defines C types for integer ranges and rectangles (e.g., `wuffs_base__range_ie_u32`, `wuffs_base__rect_ie_i32`) with inline methods for intersection, union, containment, and emptiness checks. A reusable, zero-dependency C header that can be extracted for any project needing geometric or interval operations.
Implements the Random Access Compression (RAC) format, allowing seeking within compressed data without decompressing the entire stream. Provides readers and writers with support for multiple codecs (zlib, zstd, lz4), page-sized chunk alignment, and concurrent decompression. A self-contained Go package with minimal imports, reusable for building compressed archives with random access.