Recent stories
Each story's summary, with the places it was discussed.
Summaries are written by AI from the linked sources. Open the source for full context.
eh is a minimalist vi-inspired terminal text editor written primarily in C, using the Buffer Gap method.
It supports UTF-8, cursor motions, editing, search and replacement, undo/redo, indentation, shell filtering, file operations, marks, and Unicode inspection. Built with Curses, it provides a compact command set while documenting terminal, encoding, and platform limitations.
Matheus Moreira, a physician and hobbyist programmer, details his journey from learning C++ to building Lone Lisp, a language running on Linux syscalls without libc.
He emphasizes the benefits of freestanding code, such as removing C legacy issues, and advocates for user ownership of the entire technology stack to combat limited, appliance-like computing.
Translating WebAssembly to C often matches the performance of dedicated runtimes like Wasmer and Wasmtime.
By adding wide arithmetic support to wasm2c, the author demonstrates that native C compilation remains highly efficient. While runtimes offer unique features like WASIX or the Component Model, WebAssembly-to-C provides superior portability, lower overhead, and flexible compiler choices for controlled, precompiled modules.
This technical article explores the implementation of the defer statement in the C programming language, a feature common in modern languages like Zig but currently missing from the C standard.
The author examines various non-portable workarounds, including GCC nested functions with the cleanup attribute, Clang blocks, and Windows-specific structured exception handling. Each method is evaluated for its trade-offs, particularly the security risks of executable stacks associated with GCC trampolines. The article also covers alternative approaches using long jumps, for-loop hacks, and custom stack-based systems for LIFO resource management. Ultimately, the author recommends a simplified GCC/Clang macro using the cleanup attribute for most use cases, emphasizing that while portability remains a challenge, functional defer mechanisms are achievable in current C environments.
This technical analysis explores the implementation of polymorphism in C by mimicking high-level features like Go interfaces and Rust traits.
While C lacks native support for such abstractions, the article demonstrates how to achieve similar functionality using structs and function pointers. It critiques several approaches, including direct function pointer embedding and implementor-side method tables, highlighting issues like memory overhead and layout dependency. The author proposes a refined 'method table in the interface' pattern, which utilizes a static method table (mtab) and a self-reference pointer to ensure memory efficiency and type safety. The study concludes that while manual implementation in C requires careful management and lacks the elegance of modern languages, it remains a viable way to achieve decoupled, contract-based programming.
New performance tests have already improved curl 8.23.0, making base64 decoding, URL encoding and decoding, date and URL parsing, number parsing, and most printf() calls faster.
URL parsing is 20–30% faster, while several parsers exceed twice their previous speed. Core structs are 20–28% smaller, reducing peak memory for a 512MB HTTP download from 130,622 to 126,875 bytes and allocations from 100 to 96. The tests are available in the git repository for further optimization.
Standard C does not provide a fully portable way to detect all `strtod`-family conversion errors.
Overflow reporting depends on `math_errhandling` via `errno` or floating-point exceptions, while underflow reporting is optional; malformed input must be detected with `endptr`, not reliably through `errno`. POSIX always requires `errno == ERANGE` for overflow and underflow but permits implementation differences for invalid input. The differing glibc and musl behavior exposes unclear, arguably conflicting standard wording.
glibc's `initstate` now conforms to POSIX by returning NULL on failure; the bug was fixed in 2013, but the Linux man page still incorrectly documents the old behavior.
The author retracts a previous claim based on a mistaken test and notes that POSIX defines no errors for `initstate`, making glibc's `errno` handling and NULL-state error condition extensions. musl follows POSIX strictly and may segfault on a NULL state pointer.