Writing Type-Safe Generics In C

The fun part about a programming language like C is that although the language doesn’t directly support many features including object-oriented programming and generics, there’s nothing that’s keeping you from implementing said features in C. This extends to something like type-safe generics in C, as [Raph] demonstrates in a blog post.

After running through the various ways that generics are also being implemented using methods including basic preprocessor macros and void pointers, the demonstrated method is introduced. While not necessarily a new one, the advantage with this method is that it is type-safe. Much like C++ templates, these generics are evaluated at compile time, with the preprocessor handling both the type checking and filling in of the right template snippets.

While somewhat verbose, it can be condensed into a single header file, doesn’t rely on the void type or pointers and can be deduplicated by the linker, preventing bloat. If generics is what you are looking for in your C project, this might be a conceivable solution.

Screenshot of X running on Gloire

There’s No Rust On This Ironclad Kernel

Rust is the new hotness in programming languages because of how solid its memory protections are. Race conditions and memory leaks are hardly new issues however, and as greybeards are wont to point out, they were kind of a solved problem already: we have Ada. So if you want a memory-protected kernel but aren’t interested in the new kids’ rusty code, you might be interested in the Ironclad OS kernel, written entirely in Ada.

OK, not entirely in classic Ada– they claim to use SPARK, too, but since SPARK and Ada converged syntax-wise over a decade ago, we’re just going to call it Ada. The SPARK toolchain means they can get this kernel “formally-verified” however, which is a big selling point. If you’re not into CS, that just means the compiler can confirm the code is going to do what we want under all possible conditions — which is a nice thing to be able to say about the heart of your operating system, I think we can all agree. It’s a nice thing to be able to say about any code, which is one reason why you might want to be programming in Ada.

Continue reading “There’s No Rust On This Ironclad Kernel”

FLOSS Weekly Episode 854: The Big Daddy Core

This week Jonathan and Ben chat with Jason Shepherd about Ocre and Atym.io! That’s the lightweight WebAssembly VM that lets you run the same containers on Linux and a host of embedded platforms, on top of the Zephyr embedded OS. What was the spark that led to this project’s creation, what does Atym.io bring to the equation, and what are people actually doing with it? Watch to find out!

Continue reading “FLOSS Weekly Episode 854: The Big Daddy Core”

Audio field emission map

Audio Sound Capture Project Needs Help

When you are capturing audio from a speaker, you are rarely capturing the actual direct output of such a system. There are reflections and artifacts caused by anything and everything in the environment that make it to whatever detector you might be using. With the modern computation age, you would think there would be a way to compensate for such artifacts, and this is what [d.fapinov] set out to do.

[d.fapinov] has put together a code base for simulating and reversing environmental audio artifacts made to rival systems, entirely orders of magnitude higher in cost. The system relies on similar principles used in radio wave antenna transmission to calculate the audio output map, called spherical harmonic expansion. Once this map is calculated and separated from outside influence, you can truly measure the output of an audio device.

The only problem is that the project needs to be tested in the real world. [d.fapinov] has gotten this far but is unable to continue with the project. A way to measure audio from precise locations around the output is required, as well as the appropriate control for such a device.

Audio enthusiasts go deep into this tech, and if you want to become one of them, check out this article on audio compression and distortion.

Hello World In C Without Linking In Libraries

If there’s one constant with software developers, it is that sometimes they get bored. At these times, they tend to think dangerous thoughts, usually starting with ‘What if…’. Next you know, they have gone down a dark and winding rabbit hole and found themselves staring at something so amazing that the only natural conclusion that comes to mind is that while educational, it serves no immediate purpose.

The idea of applying this to snipping out the <stdio.h> header in C and the printf() function that it provides definitely is a good example here. Starting from the typical Hello World example in C, [Old Man Yells at Code] over at YouTube first takes us from the standard dynamically linked binary at a bloated 16 kB, to the statically linked version at an eyepopping 767 kB.

To remove any such dynamic linkages, and to keep file sizes somewhat sane, he then proceeds to first use the write()function from the <unistd.h> header, which does indeed cut out the <stdio.h> include, before doing the reasonable thing and removing all includes by rewriting the code in x86 assembly.

While this gets the final binary size down to 9 kB and needs no libraries to link with, it still performs a syscall, after setting appropriate register values, to hand control back to the kernel for doing the actual printing. If you try doing something similar with syscall(), you have to link in libc, so it might very well be that this is the real way to do Hello World without includes or linking in libraries. Plus the asm keyword is part of C, although one could argue that at this point you could just as well write everything in x86 ASM.

Of course, one cannot argue that this experience isn’t incredibly educational, and decidedly answers the original ‘What if…’ question.

Continue reading “Hello World In C Without Linking In Libraries”

FLOSS Weekly Episode 853: Hardware Addiction; Don’t Send Help

This week Jonathan and Rob chat with Cody Zuschlag about the Xen project! It’s the hypervisor that runs almost everywhere. Why is it showing up in IoT devices and automotive? And what’s coming next for the project? Watch to find out!

Continue reading “FLOSS Weekly Episode 853: Hardware Addiction; Don’t Send Help”

Web Development In… Pascal?

If you were asked to make an e-commerce website in 2025, what language would you reach for? Show of hands: JavaScript? Go? Pascal? Well, there was at least one taker for that last one: [jns], and he has an hour-long tutorial video showing you how he made it happen. 

The site in question is the web store for his personal business, Photronic Arts, so you cannot say [jns] does not have skin in the game. From the front end, this is HTML and could be anything upto and including Shopify under the hood. It’s not, though: it’s a wholly custom backend [jns] put together in FreePascal, using the Lazarus IDE.

There’s a case to be made for Pascal in the modern day, but when we wrote that we weren’t expecting to get tips about web development.  Ironically enough [jns] spends so much time giving the technical details in this video he doesn’t delve that deeply into why he chose FreePascal, especially when it’s clear he’s very familiar with C and C++. In his associated writeup on his Gopher page (link though Floodgap) [jns] simply declares it’s a language he’s quite fond of, which is reason enough of us. The source code is available, though on request, to avoid AI scraping. It’s a sad but understandable response to these modern times.

If you’re not into web development and want to see a deep-dive into how the backend works, this video is worth watching even if you don’t particularly care for Pascal. It’s also worth watching if you do know backend development, and are Pascal-curious. If neither of those things interest you, what about this Pascal Library for Arduino?

Thanks to [jns] for the tip! If you’re doing modern work with questionably-modern tools, we call that a hack and would love to hear from you.