Hacker News with Generative AI: C Programming

Writing a Self-Mutating x86_64 C Program (2013) (ephemeral.cx)
“Why would you ever want to write a program that changes its code while it’s running? That’s a horrible idea!”
Right-Truncatable Prime Counter (github.com/EbodShojaei)
This C program efficiently calculates the number of right-truncatable primes for a given number of digits.
Vibe-coded a professional C99 compiler with a broken hand (then threw it away) (reddit.com)
C is not a low-level language (2018) (queue.acm.org)
In the wake of the recent Meltdown and Spectre vulnerabilities, it's worth spending some time looking at root causes. Both of these vulnerabilities involved processors speculatively executing instructions past some kind of access check and allowing the attacker to observe the results via a side channel. The features that led to these vulnerabilities, along with several others, were added to let C programmers continue to believe they were programming in a low-level language, when this hasn't been the case for decades.
I built a native Windows Todo app in pure C (278 KB, no frameworks) (github.com/Efeckc17)
A modern, native Windows Todo application built with C and Win32 API. This project demonstrates advanced Windows GUI programming and system integration capabilities.
Show HN: LoopMix128 – Fast C PRNG (.46ns), 2^128 Period, BigCrush/PractRand Pass (github.com/danielcota)
This repository contains LoopMix128, an extremely fast pseudo-random number generator (PRNG) with a guaranteed period of 2^128, proven injectivity, and clean passes in both BigCrush and PractRand (32TB). It is designed for non-cryptographic applications where speed and statistical quality are important.
Fui: C library for interacting with the framebuffer in a tty context (github.com/martinfama)
fui, standing for framebuffer user interface, is a C library for interacting with the framebuffer in a tty context.
Memory leak proof every C program (tedunangst.com)
Memory leaks have plagued C programs for as long as the language has existed.
GNU C Language Introduction and Reference Manual (gnu.org)
This manual explains the C language for use with the GNU Compiler Collection (GCC) on the GNU/Linux system and other systems.
Open-source interactive C tutorial in the browser (learn-c.org)
Welcome to the learn-c.org free interactive C tutorial.
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.
Show HN: Bptree – A B+ tree implementation in C (github.com/habedi)
Bptree is a lightweight single-header B+ tree implementation written in C.
Embedding Awk in a C Program (neacsu.net)
This article introduces an embedded AWK interpreter that can be called from a C/C++ program.
A port of Mbed-TLS for the Classic Macintosh OS 7/8/9 (github.com/bbenchoff)
This is a C89/C90 port of MbedTLS for Mac System 7/8/9. It works, and compiles under Metrowerks Codewarrior Pro 4. Here's the proof:
Algorithms Design (In C) (ime.usp.br)
The 20th century was the century of the equation; the 21st century is the century of the algorithm.
A diagram of C23 basic types (wordpress.com)
This week on the C committee mailing list we had a discussion about how C’s types are organized into different categories. At the end I came up with a diagram with that organization. It basically translates the section “6.2.5 Types” of the C23 standard into a graph of inclusions.
A decompilation and port of Sonic Advance 2-a GameBoy Advance game written in C (github.com/SAT-R)
⚠️ This project is not completed and still under active development
Beej's Guide to C Programming [pdf] (beej.us)
Writing Programs with Ncurses (invisible-island.net)
This document is an introduction to programming with curses. It is not an exhaustive reference for the curses Application Programming Interface (API); that role is filled by the curses manual pages. Rather, it is intended to help C programmers ease into using the package.
Bootstrap C projects without the pain (github.com/claeusdev)
A minimal C project generator written in Rust.
Strncpy? just say no (2011) (liw.fi)
This is a rant. I’ve made it in various forms in various places over the years, and I think it’s time to put it somewhere so I can point people at it, and stop repeating myself.
Writing a Simple Garbage Collector in C (maplant.com)
People seem to think that writing a garbage collector is really hard, a deep magic understood by a few great sages and Hans Boehm (et al). Well it’s not. In fact, it’s rather straight forward. I claim that the hardest part in writing a GC is writing the memory allocator, which is as hard to write as it is to look up the malloc example in K&R.
Image Processing in C (2000) [pdf] (ed.ac.uk)
Show HN: Krep a High-Performance String Search Utility Written in C (davidesantangelo.github.io)
A blazingly fast string search utility for performance-critical applications
Reinforcement Learning in less than 400 lines of C (github.com/antirez)
This code implements a neural network that learns to play tic-tac-toe using reinforcement learning, just playing against a random adversary, in under 400 lines of C code, without any external library used.
Vulkan Game Engine Series Written in C – Travis Vroman (youtube.com)
Robust Wavefront OBJ model parsing in C (nullprogram.com)
Wavefront OBJ is a line-oriented, text format for 3D geometry. It’s widely supported by modeling software, easy to parse, and trivial to emit, much like Netpbm for 2D image data. Poke around hobby 3D graphics projects and you’re likely to find a bespoke OBJ parser. While typically only loading their own model data, so robustness doesn’t much matter, they usually have hard limitations and don’t stand up to fuzz testing.
Cursed fire or #define black magic (ssloy.github.io)
Have you ever wondered whether it is possible to write fully functional code using only the #define directive in C?
Examples of quick hash tables and dynamic arrays in C (nullprogram.com)
This article durably captures my reddit comment showing techniques for std::unordered_map and std::vector equivalents in C programs. The core, important features of these data structures require only a dozen or so lines of code apiece. They compile quickly, and tend to run faster in debug builds than release builds of their C++ equivalents. What they lack in genericity they compensate in simplicity. Nothing here will be new. Everything has been covered in greater detail previously, which I will reference when appropriate.
Examples of quick hash tables and dynamic arrays in C (nullprogram.com)
This article durably captures my reddit comment showing techniques for std::unordered_map and std::vector equivalents in C programs. The core, important features of these data structures require only a dozen or so lines of code apiece. They compile quickly, and tend to run faster in debug builds than release builds of their C++ equivalents. What they lack in genericity they compensate in simplicity. Nothing here will be new. Everything has been covered in greater detail previously, which I will reference when appropriate.