Hacker News with Generative AI: C

Understanding Memory Management, Part 1: C (educatedguesswork.org)
I've been writing a lot of Rust recently, and as anyone who has learned Rust can tell you, a huge part of the process of learning Rust is learning to work within its restrictive memory model, which forbids many operations that would be perfectly legal in either a systems programming language like C/C++ or a more dynamic language like Python or JavaScript. That got me thinking about what was really happening and what invariants Rust was trying to enforce.
Obvious things C should do (digitalmars.com)
Standard C undergoes regular improvements, now at C23. But there are baffling things that have not been fixed at all. The Dlang community embedded a C compiler in the D programming language compiler so it could compile C. This C compiler (aka ImportC) was built from scratch. It provided the opportunity to use modern compiler technology to fix those shortcomings. Why doesn’t Standard C fix them?
C: Simple Defer, Ready to Use (wordpress.com)
With this post I will concentrate on the here and now: how to use C’s future lifesaving defer feature with existing tools and compilers.
Ask HN: Why do/don't you use C? (ycombinator.com)
I've been having a blast writing projects in C lately (emulator, raycaster) and using it extensively for a game engine I'm making.
Writing a simple pool allocator in C (8dcc.github.io)
I found out about pool allocators some time ago, and I really liked its simplicity and high performance, so I decided to write my own. This article was initially inspired by Dmitry Soshnikov’s article.
Boffins carve up C so code can be converted to Rust (theregister.com)
Computer scientists affiliated with France's Inria and Microsoft have devised a way to automatically turn a subset of C code into safe Rust code, in an effort to meet the growing demand for memory safety.
Syzygy: Dual Code-Test C to Rust Translation Using LLMs and Dynamic Analysis (arxiv.org)
Despite extensive usage in high-performance, low-level systems programming applications, C is susceptible to vulnerabilities due to manual memory management and unsafe pointer operations.
Write a Shell in C (2015) (brennan.io)
It’s easy to view yourself as “not a real programmer.” There are programs out there that everyone uses, and it’s easy to put their developers on a pedestal. Although developing large software projects isn’t easy, many times the basic idea of that software is quite simple. Implementing it yourself is a fun way to show that you have what it takes to be a real programmer.
Train a Mnist VAE with C and CUDA (github.com/ggerganov)
Hi, I just want to share what I have been working on recently. This is an example of training a MNIST VAE. The goal is to use only ggml pipeline and its implementation of ADAM optimizer.
Compiling C to Safe Rust, Formalized (arxiv.org)
The popularity of the Rust language continues to explode; yet, many critical codebases remain authored in C, and cannot be realistically rewritten by hand. Automatically translating C to Rust is thus an appealing course of action.
Fixing C Strings (thasso.xyz)
It’s well-known that null-terminated C strings are bug-prone and unsafe to use. They’re the stereotypical footgun. I’ve been tinkering in a bare-metal environment recently, writing all code myself, including the common types and routines you find in libc or similar. In all the code I wrote, there is not at single null-terminated string, and I have yet to encounter a bug related to bounds checking on strings or buffers.
Show HN: Non-backtracking, Unicode aware regular expression library in C89 (github.com/mnurzia)
Compact, non-backtracking, unicode aware regular expressions in C89
Show HN: I built an embeddable Unicode library with MISRA C conformance (railgunlabs.com)
Embeddable Unicode® algorithms.
C has its limits. If you know where to look (subethasoftware.com)
Thank you, Bing Copilot (ChatGPT), for giving me another “thing I just learned” to blog about.
Is this the weirdest thing in C? (wordpress.com)
There are many weird things in C. So many that it is one of the reasons why C can be a challenging language for novice programmers. But what is the weirdest? Well in my experience, the weirdest things in C all have to do with pointers, but the weirdest one may be x[i] == i[x].
Show HN: A portable hash map in C (github.com/e-dant)
A small, portable, linear-probing hash map in C.
Ask HN: Best dev environment for C in 2024? (ycombinator.com)
Accepting suggestions about anything: IDEs, compilers, editors, editor extensions, etc.
Flappy Bird in 1000 lines of C (github.com/alxyng)
A clone of .GEARS' Flappy Bird in just over 1000 lines of C.
CJIT – C, Just in Time (dyne.org)
CJIT is a lightweight C interpreter that lets you run C code instantly, without needing to build it first. Just use the executable interpreter: no extra tools, libs, or headers required.
Wrote a custom libc for POSIX and x86-64 (github.com/elricmann)
C library (POSIX & x86-64)
The trouble with struct sockaddr's fake flexible array (lwn.net)
Flexible arrays — arrays that are declared as the final member of a structure and which have a size determined at run time — have long drawn the attention of developers seeking to harden the kernel against buffer-overflow vulnerabilities.
Truly portable C applications (lwn.net)
Programming language polyglots are files that are valid programs in multiple languages, and do different things in each. While polyglots are normally nothing more than a curiosity, the Cosmopolitan Libc project has been trying to put them to a novel use: producing native, multi-platform binaries that run directly on several operating systems and architectures. There are still some rough edges with the project's approach, but it is generally possible to build C programs into a polyglot format with with minimal tweaking.
Why Smart C Coders Love Lua (realtimelogic.com)
Raylib 5.5 – a library to program graphic apps in C (github.com/raysan5)
One year after raylib 5.0 release, arribes raylib 5.5, the next big revision of the library. It's been 11 years since raylib 1.0 release and in all this time it has never stopped growing and improving. With an outstanding number of new contributors and improvements, it's, again, the biggest raylib release to date.
Rust haters, unite! Fil-C aims to Make C Great Again (theregister.com)
Developers looking to continue working in the C and C++ programming languages amid the global push to promote memory-safe programming now have another option that doesn't involve learning Rust.
C Compiler to SPIR-V (github.com/heroseh)
HCC is a C compiler that allows you to compile your C codebase (with limitations) to SPIR-V for the Vulkan graphics API. This means you can share struct's, enum's and functions between your CPU & GPU code. HCC targets the future of GPU programming so is designed around features such as bindless resources and scalar alignment. This makes it easier to interop with the GPU and focus on writing shader code without writing your own shader build system.
Trapc – The Memory Safe C (theregister.com)
Exclusive C and C++ programmers may not need to learn Rust after all to participate in the push for memory safety.
C Gibberish to English (cdecl.org)
Is `(expession, lvalue) = rvalue` a valid assignment in C or C++? (stackoverflow.com)
Some time ago I stumbled upon the idea of how a C construct, such as (expr0, expr1, expr2), evaluates (see "What does the comma operator , do?" for more context).
Rust vs. C vs. Go runtime speed comparison (2023) (rust-lang.org)