Introduction ᴾᴴᴾ - chung-leong/zigar GitHub Wiki

JavaScript | PHP


What is Zig?

Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software. Its powerful metaprogramming model allows it to interoperate easily with other languages, including dynamic ones like PHP.

const std = @import("std");

pub fn main() void {
    std.debug.print("Hello world!", .{});
} 

What is Zigar?

Zigar is a toolkit for running Zig code in a JavaScript or PHP environment. It lets you use Zig in web apps, server-side apps, and desktop apps. Support in PHP is provided by an extension. It adds functions that you can use to compile Zig code and load native code modules.

<?php

$m = zigar_use(__DIR__ . "/zig/scratch.zig");
$m->main();
Hello world!

What can I do with Zigar?

Zigar allows you to:

  • Create cross-platform desktop applications with full access to system resources and the user interface powered by popular web tech like React and Svelte
  • Create server-side applications with full access to system resources
  • Create high-performance, multithreaded WebAssembly code for data-intensive operations in the web browser

A simple tutorial