Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Calculates the nth Fibonacci number recursively and prints it.
# zig/demo/fibonacci.zig
const std = @import("std");
fn fib(n: i32) i32 {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
pub export fn fibonacci(n: i32) void {
std.debug.print("Fibonacci: {d}\n", .{fib(n)});
}Zig is a general-purpose programming language designed for robustness, optimality, and simplicity. With Zig-Wasm, developers can compile Zig code to WebAssembly, enabling high-performance, low-level applications in the browser or other Wasm runtimes.
Origin & Creator
Zig is created by Andrew Kelley, with the community contributing to language development, compiler improvements, and WebAssembly support.
Industrial Note
Zig-Wasm is particularly useful for developers who need predictable, high-performance WebAssembly modules, low-level memory control, or integration with C/C++ codebases for web execution.