Zig (プログラミング言語 )
![]() | この |
![]() Zigのロゴ | |
パラダイム | |
---|---|
アンドリュー・ケリー ![]() | |
0.13.0 / 2024 | |
C![]() | |
プラットフォーム | クロスプラットフォーム |
ライセンス |
MIT License ![]() |
ウェブサイト | |
zig ![]() |
Zigは、アンドリュー・ケリーによって
Zigにはパックされた
リファレンスzig cc
zig c++
をそれぞれzig cc
を
コード例 [編集 ]
Hello world[編集 ]
// zig version 0.9.1 const std = @import("std"); pub fn main() !void { const stdout = std.io.getStdOut().writer(); try stdout.print("Hello, {s}!\n", .{"world"}); }
ジェネリック連結 リスト[編集 ]
// ジェネリックなLinkedList
型 const std = @import("std"); const stdout = std.io.getStdOut().writer(); fn LinkedList(comptime T: type) type { return struct { const Self = @This(); pub const Node = struct { next: ?*Node = null, data: T, }; first: ?*Node = null, pub fn prepend(list: *Self, new_node: *Node) void { new_node.next = list.first; list.first = new_node; } pub fn format( list: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype, ) !void { try out_stream.writeAll("( "); var it = list.first; while (it) |node| : (it = node.next) { try std.fmt.formatType(node.data, fmt, options, out_stream, 1); try out_stream.writeAll(" "); } try out_stream.writeAll(" )"); } }; } pub fn main() !void { const ListU32 = LinkedList(u32); var list = ListU32{}; var node1 = ListU32.Node{ .data = 1 }; var node2 = ListU32.Node{ .data = 2 }; var node3 = ListU32.Node{ .data = 3 }; list.prepend(&node1); list.prepend(&node2); list.prepend(&node3); try stdout.print("{}\n", .{list}); try stdout.print("{b}\n", .{list}); }実行 結果 ( 3 2 1 ) ( 11 10 1 )
このコードは、Zig
main
脚注 [編集 ]
注釈 [編集 ]
- ^ フィールド
間 のパディングがゼロの構造 体 のこと。
出典 [編集 ]
- ^
出典 URL: https://ziglang.org/download/#release-0.13.0,題名 : Release 0.13.0 - ^ Motroc, Gabriela (2017
年 10月 31日 ). ““Zig has all the elegant simplicity of C, minus all the ways to shoot yourself in the foot””. JAXenter. 2021年 1月 1日 閲覧 。 - ^ Elizabeth, Jane (2017
年 10月 19日 ). “Tired of C? New programming language Zig aims to be more pragmatic and readable”. JAXenter. 2021年 1月 1日 閲覧 。 - ^ Yegulalp, Serdar (2016
年 8月 29日 ). “New challenger joins Rust to topple C language”. InfoWorld. 2021年 1月 1日 閲覧 。 - ^ IT
之 家 (2020年 7月 12日 ). “想 替 代 C的 Zig 语言成立 了 基金 会 ” (中国 語 ).新 浪 数 码. 2021年 1月 1日 閲覧 。 - ^ “The Zig Programming Language”. ziglang.org. 2021
年 1月 1日 閲覧 。 - ^ “Mozilla’s Observatory, the Zig programming language, and uSens’ VR/AR SDK—SD Times news digest: Aug. 29, 2016”. SD Times (2016
年 8月 29日 ). 2021年 1月 1日 閲覧 。 - ^ “Zig competes with C instead of depending on it”. ziglang.org. 2021
年 1月 1日 閲覧 。 - ^ Kelley, Andrew (2018
年 1月 24日 ). “Unsafe Zig is Safer than Unsafe Rust”. andrewkelley.me. 2021年 1月 1日 閲覧 。 - ^ Anderson, Tim (2020
年 4月 24日 ). “Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers”. The Register. 2021年 1月 1日 閲覧 。 - ^ “Documentation - The Zig Programming Language”. ziglang.org. 2021
年 1月 1日 閲覧 。 - ^ Lewkowicz, Jakub (2020
年 4月 14日 ). “SD Times news digest: C++20 concepts in Visual Studio 2010 version 16.3, Bootstrap to drop IE support, and Zig 0.60 released”. SD Times. 2021年 1月 1日 閲覧 。 - ^ Bill, Ginger (2019
年 5月 13日 ). “A Reply to The Road to Zig 1.0”. gingerBill. 2021年 1月 1日 閲覧 。 - ^ a b “ziglang/zig”. GitHub. 2021
年 1月 1日 閲覧 。 - ^ “Tier System”. ziglang.org. 2021
年 1月 1日 閲覧 。 - ^ “zig cc”. ziglang.org (2020
年 4月 13日 ). 2021年 1月 1日 閲覧 。 - ^ “Add support for `zig cc` as C compiler. #13757”. GitHub. 2021
年 1月 1日 閲覧 。