This article relies largely or entirely on a single source.(May 2021) |
Paradigms | Multi-paradigm: imperative, concurrent, procedural, functional |
---|---|
Designed by | Andrew Kelley |
First appeared | 8 February 2016[1] |
Preview release | 0.8.0[2]
/ 4 June 2021 |
Typing discipline | Static, strong, inferred, structural, generic |
Platform | x86-64, ARM, MIPS, IA-32, WebAssembly, RISC-V |
OS | Cross-platform |
License | MIT License |
Filename extensions | .zig, .zir |
Website | ziglang |
Influenced by | |
C, C++, LLVM IR, Go, Rust, JavaScript |
Zig is an imperative, general-purpose, statically typed, compiled system programming language designed by Andrew Kelley.[3][4] The language is designed for "robustness, optimality and maintainability"[5][6] , supporting compile-time generics and reflection, cross-compilation and manual memory management.[7] A major goal of the language is to improve upon the C language,[8][9] while also taking inspiration from Rust,[10][11] among others.
Zig has many features for low-level programming, notably: packed structs (structs without padding between fields), arbitrary width integers[12] and multiple pointer types.[13]
The stage 1 compiler is written in Zig and C++, using LLVM 11[14] as a back-end,[15][16] supporting many of its native targets.[17] The compiler is free and open source software under the MIT License.[18]
The Zig compiler exposes the ability to compile C and C++ similarly to Clang with the commands "zig cc" and "zig c++",[19] providing many headers including libc and libcxx for many different platforms, allowing Zig's cc and c++ sub-commands to act as cross compilers out of the box.[20][21]
Zig development is funded by the Zig Software Foundation (ZSF), a non-profit corporation with Andrew Kelley as president, which takes in donations and hires multiple full-time employees.[22][23][24]
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("Hello, {}!\n", .{"world"});
}
pub fn main() void {
var node = LinkedList(i32).Node {
.prev = null,
.next = null,
.data = 1234,
};
var list = LinkedList(i32) {
.first = &node,
.last = &node,
.len = 1,
};
}
fn LinkedList(comptime T: type) type {
return struct {
pub const Node = struct {
prev: ?*Node,
next: ?*Node,
data: T,
};
first: ?*Node,
last: ?*Node,
len: usize,
};
}
|title=
(help)
By: Wikipedia.org
Edited: 2021-06-18 15:15:02
Source: Wikipedia.org