请输入您要查询的百科知识:

 

词条 Draft:Zig Programming Language
释义

  1. Language Design

  2. Examples

      Hello World    Importing C Header Files    Enumerations    Factorial  

  3. References

  4. External links

{{AFC submission|d|nn|u=Benji is me|ns=118|decliner=Scope creep|declinets=20181213013030|ts=20181112190803}} {{AFC submission|d|v|u=Benji is me|ns=118|decliner=AngusWOOF|declinets=20181112183003|reason2=nn|small=yes|ts=20181112182426}} {{AFC comment|1=Main documentation, language specification is not even complete. No secondary sources, bleeding edge and unsuitable for WP at the moment. scope_creepTalk 01:30, 13 December 2018 (UTC)}}{{AFC comment|1=It reads a bit like a manual page with emphasis on examples. AngusWOOF (barksniff) 19:06, 12 November 2018 (UTC)}}{{AFC comment|1=Need sources to indicate this has notability beyond appearing as one of a gazillion software items placed on github. AngusWOOF (barksniff) 18:30, 12 November 2018 (UTC)}}
{{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 Design

Specific inspirations for Zig's design include the following:

  • C: Strict outlook on language features
  • Rust: Avoiding null types
  • Go: Defer
  • Jai: Allocators, compile-time function evaluation
  • Node.js: @import, async, and await
  • LLVM IR: Builtins

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.

Examples

Hello World

const debug = @import("std").debug;

pub fn main() void {

}

Importing C Header Files

const c = @cImport({

});

Enumerations

const 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,

};

Factorial

The 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 {

}

References

1. ^{{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. ^{{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. ^{{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. ^{{cite web |url=https://ziglang.org/ |title=Ziglang Website |website=Ziglang.org |access-date=2018-11-12}}
7. ^{{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

  • {{Official website|1=https://ziglang.org/}}
  • {{GitHub|ziglang/zig}}
Category:Programming languagesCategory:Concurrent programming languagesCategory:Statically typed programming languagesCategory:Systems programming languagesCategory:Multi-paradigm programming languagesCategory:Procedural programming languagesCategory:Software using the MIT licenseCategory:Cross-platform softwareCategory:Free compilers and interpreters
随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/29 16:21:13