词条 | Draft:Zig Programming Language |
释义 |
{{Infobox programming language | name = Zig | logo = | caption = | paradigm = imperative, compiled, procedural | year = {{Start date and age|2015}} | designer = Andrew Kelley | developer = | latest release version = 0.3.0 | latest release date = {{Start date and age|2018|09|28}}[1] | typing = static | influenced by = C, C++, Go | platform = i386, x86-64, arm, aarch64, bpf, hexagon, mips, powerpc, r600, amdgcn, sparc, s390x, thumb, spir, lanal | operating system = Cross-platform[2][3] | license = MIT[3] | website = {{URL|https://ziglang.org/}} | file_ext = .zig }}Zig is an open-source programming language designed for "robustness, optimality, and clarity".[4][5][7] The language is intended to compete directly with C and libc is not a dependency, although you can still directly import C header files.[5][6][7] The founder and main designer of Zig is Andrew Kelley.[7] Language DesignSpecific inspirations for Zig's design include the following:
The syntax takes cues from C, Rust, and Go. Zig is designed with thorough safety in mind, and as such manual memory management is critical feature, holding the principal that "edge cases matter."[6][8] Zig purposefully discards C's preprocessor, instead focusing on other compile-time code possibilities. The language is designed to make cross-compilation easy.[5] Zig utilizes LLVM currently.[9] The standard library has been influenced by musl, libc, and wine. ExamplesHello Worldconst debug = @import("std").debug; pub fn main() void { } Importing C Header Filesconst c = @cImport({ }); Enumerationsconst CatBreed = enum { Siamese, Bengal, Shorthair, Other, }; You can also clarify the integers associated with each name. const CatBreed = enum(u8) { Siamese = 0, Bengal = 1, Shorthair = 5, Other = 10, }; FactorialThe code below is an implementation of the factorial function in Zig. Marking a parameter with comptime indicates that the value must be known at compile-time, something that Zig places importance on.[10] const std = @import("std"); pub fn factorial(comptime n: comptime_int) comptime_int { } pub fn main() void { } References1. ^{{cite web |url=https://github.com/ziglang/zig/releases |title=GitHub Releases |website=Github.com |access-date=2018-11-12}} 2. ^{{Cite web |url=https://github.com/ziglang/zig/blob/master/README.md |title=GitHub Readme |website=Github.com |access-date=2018-11-12}} 3. ^{{cite web |url=https://github.com/ziglang/zig/blob/master/LICENSE |title=GitHub License File |website=Github.com |access-date=2018-11-12}} 4. ^1 {{Cite web |url=https://jaxenter.com/replace-c-zig-language-138242.html |title=New programming language Zig aims to be more pragmatic and readable |last=Elizabeth |first=Jane |date=2017-10-19 |website=Jaxenter.com |access-date=2018-11-12}} 5. ^1 2 {{Cite web |url=https://sdtimes.com/ar/mozillas-observatory-zig-programming-language-usens-vrar-sdk-sd-times-news-digest-aug-29-2016/ |title=SD Times news digest |last1=Cardoza |first1=Christina |last2=Moore |first2=Madison |date=2016-08-29 |website=Sdtimes.com |access-date=2018-11-12}} 6. ^1 {{cite web |url=https://ziglang.org/ |title=Ziglang Website |website=Ziglang.org |access-date=2018-11-12}} 7. ^1 2 {{Cite web |url=https://www.infoworld.com/article/3113083/application-development/new-challenger-joins-rust-to-upend-c-language.html |title=New challenger joins Rust to topple C language |last=Yegulalp |first=Serdar |date=2016-08-29 |website=Infoworld.com |access-date=2018-11-12}} 8. ^{{cite web |url=https://www.recurse.com/events/localhost-andrew-kelley |title=Recurse Center Presentation |website=Recurse.com |access-date=2018-11-12}} 9. ^{{cite web |url=http://llvmweekly.org/issue/232 |title=LLVM Weekly News |website=LLVMweekly.org |access-date=2018-11-19}} 10. ^{{cite web |url=https://ziglang.org/documentation/master/ |title=Ziglang Documentation |website=Ziglang.org |access-date=2018-11-12}} External links
|
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。