You can edit almost every page by Creating an account and confirming your email.

Zig (programming language)

From EverybodyWiki Bios & Wiki


Zig
File:Zig programming language logo.svg
ParadigmsMulti-paradigm: imperative, concurrent, procedural, functional
Designed byAndrew Kelley
DeveloperAndrew Kelley, Open source
First appeared8 February 2016; 10 years ago (2016-02-08)[1]
Preview release
Lua error in Module:Wd at line 2189: attempt to index field 'wikibase' (a nil value). / Lua error in Module:Wd at line 2189: attempt to index field 'wikibase' (a nil value).; Error: first parameter cannot be parsed as a date or time. (Lua error in Module:Wd at line 2189: attempt to index field 'wikibase' (a nil value).)
Typing disciplineStatic, Strong, Inferred, Structural, Generic
Platformx86 64, ARM, MIPS, x86, WebAssembly, RISC-V
OSCross-platform
LicenseMIT License
Filename extensions.zig, .zir
Websiteziglang.org
Influenced by
C, C++, LLVM IR, Go, Rust, JavaScript

Search Zig (programming language) on Amazon.

Zig is an imperative, general-purpose, statically typed, compiled system programming language designed by Andrew Kelley.[2][3] The language is designed for "robustness, optimality and maintainability"[4] [5] , supporting compile-time generics and reflection, cross-compilation and manual memory management.[6] A major goal of the language is to compete with (and improve upon) C,[7][8] while also taking inspiration from Rust,[9][10] among others.

Zig has many features for low level programming, notably: packed structs (structs with zero padding between fields), arbitrary width integers[11] and multiple pointer types.[12]

The compiler is written in Zig and C++, using LLVM 11[13] as a back-end,[14][15] supporting many of its native targets.[16] The compiler is free and open source software under the MIT License.[17] The Zig compiler exposes the ability to compile C and C++, similar to Clang by using the command "zig cc" and "zig c++", respectively.[18] The Nim programming language supports the use of zig cc as a C compiler.[19]

Examples

Hello World

const std = @import("std");

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

Generic linked list

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,
    };
}

See also

References

  1. Kelley, Andrew. "Introduction to the Zig Programming Language". andrewkelley.me. Retrieved 8 November 2020.
  2. "Zig has all the elegant simplicity of C, minus all the ways to shoot yourself in the foot". JAXenter. 2017-10-31. Retrieved 2020-02-11.
  3. "Tired of C? New programming language Zig aims to be more pragmatic and readable". 2017-10-19. Retrieved 2020-04-22.
  4. Yegulalp, Serdar (2016-08-29). "New challenger joins Rust to topple C language". InfoWorld. Retrieved 2020-02-11.
  5. "Zig language and C". Sina Corp. 2020-07-12. Retrieved 2020-08-12.
  6. "The Zig Programming Language". ziglang.org. Retrieved 2020-02-11.
  7. "Mozilla's Observatory, the Zig programming language, and uSens' VR/AR SDK—SD Times news digest: Aug. 29, 2016". SD Times. 2016-08-29. Retrieved 2020-02-11.
  8. "The Zig Programming Language". ziglang.org. Retrieved 2020-02-11.
  9. Company, Sudo Null. "Sudo Null - IT News for you". SudoNull. Retrieved 2020-02-11.
  10. Kelley, Andrew. "Unsafe Zig is Safer Than Unsafe Rust". andrewkelley.me. Retrieved 2020-02-11.
  11. Tim Anderson 24 Apr 2020 at 09:50. "Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers". www.theregister.co.uk. Retrieved 2020-04-24.
  12. "Documentation - The Zig Programming Language". ziglang.org. Retrieved 2020-04-24.
  13. "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. 2020-04-14. Retrieved 2020-04-19.
  14. "A Reply to _The Road to Zig 1.0_". www.gingerbill.org. 2019-05-13. Retrieved 2020-02-11.
  15. ziglang/zig, Zig Programming Language, 2020-02-11, retrieved 2020-02-11
  16. "The Zig Programming Language". ziglang.org. Retrieved 2020-02-11.
  17. "ziglang/zig". GitHub. Retrieved 2020-02-11.
  18. "0.6.0 Release Notes · The Zig Programming Language". ziglang.org. Retrieved 2020-04-19.
  19. "Add support for 'zig cc' as C compiler. by hessammehr · Pull Request #13757 · nim-lang/Nim". GitHub. Retrieved 2020-04-19.

External links


This article "Zig (programming language)" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Zig (programming language). Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.

Page kept on Wikipedia This page exists already on Wikipedia.