This proposal introduces an effect system to C2x, aiming to enhance code modularity, optimization, and correctness by explicitly declaring and checking the side effects of functions. It defines a set of effect keywords, like reads
and writes
, to annotate function parameters and return values, indicating how they are accessed. These annotations are part of the function's type and are checked by the compiler, ensuring that declared effects match the function's actual behavior. The proposal also includes a mechanism for polymorphism over effects, enabling more flexible code reuse and separate compilation without sacrificing effect safety. This mechanism allows for abstracting over effects, so that functions can be written generically to operate on data structures with varying levels of mutability.
This paper introduces Crusade, a formally verified translation from a subset of C to safe Rust. Crusade targets a memory-safe dialect of C, excluding features like arbitrary pointer arithmetic and casts. It leverages the Coq proof assistant to formally verify the translation's correctness, ensuring that the generated Rust code behaves identically to the original C, modulo non-determinism inherent in C. This rigorous approach aims to facilitate safe integration of legacy C code into Rust projects without sacrificing confidence in memory safety, a critical aspect of modern systems programming. The translation handles a substantial subset of C, including structs, unions, and functions, and demonstrates its practical applicability by successfully converting real-world C libraries.
HN commenters discuss the challenges and nuances of formally verifying the C to Rust transpiler, Cracked. Some express skepticism about the practicality of fully verifying such a complex tool, citing the potential for errors in the formal proofs themselves and the inherent difficulty of capturing all undefined C behavior. Others question the performance impact of the generated Rust code. However, many commend the project's ambition and see it as a significant step towards safer systems programming. The discussion also touches upon the trade-offs between a fully verified transpiler and a more pragmatic approach focusing on common C patterns, with some suggesting that prioritizing practical safety improvements could be more beneficial in the short term. There's also interest in the project's handling of concurrency and the potential for integrating Cracked with existing Rust tooling.
This project introduces a C-based web framework designed for dynamic module loading and hot reloading. Leveraging a custom module format and a simple HTTP server, it allows developers to modify and reload C code without restarting the server, facilitating rapid development and experimentation. The framework compiles and links modules on-the-fly, managing dependencies and updating the running server seamlessly. While currently limited in features, it aims to offer a performant and flexible foundation for building web applications directly in C.
Hacker News users discussed the practicality and novelty of a C web framework with hot reloading. Some questioned the real-world use cases and performance benefits compared to existing solutions, suggesting the project serves more as an interesting experiment than a production-ready tool. Others expressed interest in the technical implementation, particularly the hot reloading aspect, and appreciated the author's effort in exploring this concept. Several users pointed out potential issues like memory leaks and the challenges of safely reloading C code in a web server environment. The overall sentiment leans towards acknowledging the project's technical ingenuity while remaining skeptical about its broad applicability.
Summary of Comments ( 6 )
https://news.ycombinator.com/item?id=42750517
The Hacker News comments on the C2y effect system proposal express a mix of skepticism and cautious interest. Several commenters question the practicality and performance implications of implementing such a system in C, citing the language's existing complexity and the potential for significant overhead. Concerns are raised about the learning curve for developers and the possibility of introducing subtle bugs. Some find the proposal intriguing from a research perspective but doubt its widespread adoption. A few express interest in exploring the potential benefits of improved code analysis and error detection, particularly for concurrency and memory management, though acknowledge the challenges involved. Overall, the consensus leans towards viewing the proposal as an interesting academic exercise with limited real-world applicability in its current form.
The Hacker News post "An effect system proposal for C2y" links to a 2023 draft of N3317, a proposal for adding an effect system to a future version of the C programming language (then tentatively called C2y, now C2x). The discussion on Hacker News is relatively brief, consisting of only a few comments, and doesn't delve very deep into the technical details of the proposal.
One commenter expresses skepticism about the proposal's practicality, wondering whether the added complexity of an effect system would outweigh its benefits for typical C programming tasks. They question whether the kind of guaranteed safety that effect systems provide is truly necessary or desirable in the C ecosystem, where performance and low-level control are often prioritized. This commenter explicitly states they would not want to use an effects system in C, even if it were fully baked and easy to use. They view effects systems as more suited to functional languages, and fundamentally at odds with the design ethos and intended use cases of C.
Another commenter focuses on the evolution of C standards, noting the long period between revisions and the challenges in introducing significant changes to a language with such a large and established codebase. They also point out that alternative languages or extensions already offer some form of effect systems or related features, implying that developers needing such features might prefer those options rather than waiting for a potentially complex and slow-to-be-adopted change in the C standard itself. They mention Zig as a modern C-like language and Rust as two examples with stricter, more sophisticated type and safety features.
Finally, one commenter briefly remarks on the proposal's age (dating back to 2023), suggesting that its status and likelihood of incorporation into a future C standard are uncertain. This comment highlights the long process of standardization and the possibility that the proposal might be superseded by other developments in the meantime.