Saturday, April 19, 2025

learning Zig programming language

Zig is a relatively new programming language
intended to be a "modern version of C": low-level "systems" language
for code where performance and safety are important.

While both Rust and Go have similar objective,  there are some important differences. 
Zig, in fact, is the closest to "spirit" of C:
relatively simple syntax, full control and responsibility for memory management.

Rust is much bigger / more complex, but also more used. 
Almost like C++ is to C, Rust may be to Zig. 

Go, on the other side is also simple, fast, but it does have "GC", automated memory management.
That makes it much easier to use correctly, while limits its usage for real-time critical applications.

At this time, there are not many prominent projects using Zig yet. Rust is more popular.
I

Zig (programming language) - Wikipedia

Home ⚡ Zig Programming Language

Learn ⚡ Zig Programming Language

Getting Started ⚡ Zig Programming Language

Samples ⚡ Zig Programming Language

const std = @import("std"); pub fn main() !void { const stdout = std.io.getStdOut().writer(); try stdout.print("hello world!\n", .{}); }

$ zig run hello-world.zig

or

$ zig build-exe hello-world.zig $ ./hello-world hello world!


Here is a fun demo of Windows GUI low-level program, fully functional!
Adding more GUI elements quickly gets much more verbose, but resulting EXE is small and fast.

// https://ziglang.org/learn/samples/
const win = @import("std").os.windows;

extern "user32" fn MessageBoxA(?win.HWND, [*:0]const u8, [*:0]const u8, u32) callconv(win.WINAPI) i32;

pub fn main() !void {
    _ = MessageBoxA(null, "world!", "Hello", 0);
}


What is the EASIEST way to learn "zig"? : r/Zig


e-books:


courses:



Zig or Go, but not Rust (ThePrimeTime)

No comments: