Posts tagged programming

Don’t Lie To Your Build System

Yesterday, in Make Concepts, I talked about what Make does. Today, I’m going to talk about how Make gets abused.

Read more ...


Make Concepts

There are many resources out there for how to use make and some of them are very good. However, they mostly focus on details of syntax and how to spell the different text manipulation functions. This document is not that. This document is about why Make is the way it is, and how to help it do its job.

Read more ...


Why I like Zig

I’ve been writing C code professionally since about 2006, and while I look at a lot of languages (I have varying levels of familiarity with Python, Erlang, Ada, Haskell, Go, Rust, C++, OCaml, D, Javascript, Prolog, Lua, Lisp, Bash, Perl, Forth…you get the idea) I have yet to find one that I would rather use in cases where C is appropriate. Part of this inclination is that I mainly write for embedded systems where a lot of the features of higher level languages either don’t help or cost too much.

Read more ...


Memory Management With Zig

This post is aimed at people who come from languages with automatic garbage collection and want to get a sense for how to approach memory management in a lower level language. I’ll be using Zig (and a bit of Python) to demonstrate, but the concepts apply to C and other languages where you have to care if your data is going on the stack or the heap.

Read more ...


Pointers in Zig

This post is going to explain how pointers, arrays, and slices work in Zig, without depending on knowledge of other languages that use pointers. If you’re trying to learn Zig and your only programming experience is in a language with managed memory, this is for you. If you’re struggling to understand pointers in C, this might help. If you’re coming from C or C++ and just want to know the differences, you might be better off reading the official documentation for arrays, slices, and pointers. zig.guide is another good resource.

Read more ...


Extending C with Zig

This guide was last updated in March of 2024 with an 0.12.0-dev build. Zig is a moving target, and stuff written about it may fall out of date. If you find something broken about this, feel free to let me know.

Read more ...


Interfaces, or: Runtime Polymorphism in Zig

Update: April 2024 - A lot has happened since I originally wrote this article. I may still update it in to cover the current state of things, but Killian Vounckx wrote an update in February of 2022 and Issue 130 has been closed. I’m not porting the original version of this article to the Sphinx site, so if you want to read it, you can find it here.

Read more ...


Wrapping a C Library with Zig

This post is going to look at wrapping a C library in Zig. The library to wrap will be libsodium, a “modern, easy-to-use software library for encryption, decryption, signatures, password hashing and more.”

Read more ...