What are good alternatives to XS and Inline::C, and how do they compare?

Perl offers various alternatives for integrating C code, which can improve performance and extend functionalities. This guide compares some popular alternatives to XS and Inline::C.
Alternatives to XS, Inline::C, Perl performance, C integration, Perl extensions
# Example of using SWIG for Perl integration

/* Example C function in example.c */
int add(int a, int b) {
    return a + b;
}

/* SWIG interface file example.i */
%module example
%{ 
#include "example.h"
%}

extern int add(int a, int b);

/* Command to generate Perl wrapper */
/* swig -perl example.i */
/* gcc -shared -o example.so example_wrap.c example.c -I/usr/lib/perl/5.xx/CORE */
    

Alternatives to XS Inline::C Perl performance C integration Perl extensions