Home ⚡ Zig Programming Language (original) (raw)

Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.

⚡ A Simple Language

Focus on debugging your application rather than debugging your programming language knowledge.

⚡ Comptime

A fresh approach to metaprogramming based on compile-time code execution and lazy evaluation.

⚡ Maintain it with Zig

Incrementally improve your C/C++/Zig codebase.

index.zig

const std = @import("std");
const parseInt = std.fmt.parseInt;

test "parse integers" {
    const input = "123 67 89,99";
    const ally = std.testing.allocator;

    var list = std.ArrayList(u32).init(ally);
    // Ensure the list is freed at scope exit.
    // Try commenting out this line!
    defer list.deinit();

    var it = std.mem.tokenizeAny(u8, input, " ,");
    while (it.next()) |num| {
        const n = try parseInt(u32, num, 10);
        try list.append(n);
    }

    const expected = [_]u32{ 123, 67, 89, 99 };

    for (expected, list.items) |exp, actual| {
        try std.testing.expectEqual(exp, actual);
    }
}

Shell

$ zig test index.zig 1/1 index.test.parse integers...OK All 1 tests passed.

Zig Software Foundation

The ZSF is a 501(c)(3) non-profit corporation.

The Zig Software Foundation is a non-profit corporation founded in 2020 by Andrew Kelley, the creator of Zig, with the goal of supporting the development of the language. Currently, the ZSF is able to offer paid work at competitive rates to a small number of core contributors. We hope to be able to extend this offer to more core contributors in the future.

The Zig Software Foundation is sustained by donations.

Learn More