For decades, the barrier between Perl and the raw speed of C (or Rust, or C++, or Fortran) has been guarded by the complex, arcane rituals of XS. You had to learn a new macro language, configure a build system, handle the Perl stack manually, and compile everything before you could even run a "Hello World".

Affix changes the menu.

Affix is a Foreign Function Interface (FFI) built on the low-overhead infix JIT engine. It allows you to bind libraries, marshal complex data structures, and manage memory dynamically, all from within your Perl script.

What is in this Cookbook?

This document is a collection of recipes designed to take you from a hungry beginner to a master chef of systems programming.

We will cover:

In some articles, I'll be including benchmarks, the majority of results presented will be taken from my system running Windows 11 Pro on an AMD Ryzen 7 7840HS with 32Gb of RAM, and the most recent release of Strawberry Perl (currently v5.42.0).

Prerequisites

To follow these recipes, you will need:

Grab your apron. Let's get cooking. (Tired of the cooking references yet?)