Zig
linguaggio di programmazione
AutoreAndrew Kelley
Data di origine8 febbraio 2016[1]
Ultima versione0.16 (14 aprile 2026)
Utilizzogeneral purpose
Paradigmiimperativo procedurale, funzionale
Tipizzazionestatica, forte
Estensioni comuni.zig
Influenzato daC, C++, LLVM IR, Go, Rust, JavaScript
Implementazione di riferimento
LicenzaLicenza MIT
Sito webziglang.org/

Zig è un linguaggio di programmazione imperativo general purpose.

Ideato come alternativa moderna al C[2][3][4][5][6][7] e parzialmente ispirato a Rust,[8][9] Zig include diverse funzionalità a basso livello (come puntatori,[10] packed structs, interi di dimensione arbitraria[11]). Zig è un linguaggio compilato e fa uso di tipizzazione statica, con inferenza di tipi, tipi generici, e riflessione.[12]

Il compilatore Zig è software libero distribuito sotto licenza MIT.[13] È un compilatore self-hosting, essendo implementato in Zig e C++, e usa LLVM come back-end.[14][15][16][17] Il compilatore Zig permette anche la generazione di codice C e C++[18] (Nim supporta l'uso di Zig come back-end per la generazione di codice in questi linguaggi).[19]

Esempi

modifica

Hello World

modifica
// zig version 0.15.*
const std = @import("std");

pub fn main() !void {
    var buffer: [1024]u8 = undefined;
    var writer = std.fs.File.stdout().writer(&buffer); // or writer(&.{}) for unbuffered
    const stdout = &writer.interface;
    try stdout.print("Hello, world!", .{});
    try stdout.flush(); // noop if unbuffered
}

Lista concatenata

modifica
fn LinkedList(comptime T: type) type {
    return struct {
        pub const Node = struct {
            prev: ?*Node,
            next: ?*Node,
            data: T,
        };

        first: ?*Node,
        last:  ?*Node,
        len:   usize,
    };
}

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

Note

modifica
  1. ^ Andrew Kelley, Introduction to the Zig Programming Language, su andrewkelley.me. URL consultato l'8 novembre 2020.
  2. ^ (EN) Zig has all the elegant simplicity of C, minus all the ways to shoot yourself in the foot, su JAXenter, 31 ottobre 2017. URL consultato l'11 febbraio 2020.
  3. ^ (EN) Tired of C? New programming language Zig aims to be more pragmatic and readable, su jaxenter.com, 19 ottobre 2017. URL consultato il 22 aprile 2020.
  4. ^ (EN) Serdar Yegulalp, New challenger joins Rust to topple C language, su InfoWorld, 29 agosto 2016. URL consultato l'11 febbraio 2020.
  5. ^ Zig language and C, su Sina Corp, 12 luglio 2020. URL consultato il 12 agosto 2020.
  6. ^ (EN) Mozilla's Observatory, the Zig programming language, and uSens' VR/AR SDK—SD Times news digest: Aug. 29, 2016, su SD Times, 29 agosto 2016. URL consultato l'11 febbraio 2020.
  7. ^ The Zig Programming Language, su ziglang.org. URL consultato l'11 febbraio 2020.
  8. ^ (EN) Sudo Null Company, Sudo Null - IT News for you, su SudoNull. URL consultato l'11 febbraio 2020.
  9. ^ Andrew Kelley, Unsafe Zig is Safer Than Unsafe Rust, su andrewkelley.me. URL consultato l'11 febbraio 2020.
  10. ^ Documentation - The Zig Programming Language, su ziglang.org. URL consultato il 24 aprile 2020.
  11. ^ (EN) Tim Anderson 24 Apr 2020 at 09:50, Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers, su theregister.co.uk. URL consultato il 24 aprile 2020.
  12. ^ The Zig Programming Language, su ziglang.org. URL consultato l'11 febbraio 2020.
  13. ^ (EN) ziglang/zig, su GitHub. URL consultato l'11 febbraio 2020.
  14. ^ (EN) SD Times news digest: C++20 concepts in Visual Studio 2010 version 16.3, Bootstrap to drop IE support, and Zig 0.60 released, su SD Times, 14 aprile 2020. URL consultato il 19 aprile 2020.
  15. ^ (EN) A Reply to _The Road to Zig 1.0_, su gingerbill.org, 13 maggio 2019. URL consultato l'11 febbraio 2020.
  16. ^ ziglang/zig, Zig Programming Language, 11 febbraio 2020. URL consultato l'11 febbraio 2020.
  17. ^ The Zig Programming Language, su ziglang.org. URL consultato l'11 febbraio 2020.
  18. ^ 0.6.0 Release Notes · The Zig Programming Language, su ziglang.org. URL consultato il 19 aprile 2020.
  19. ^ (EN) Add support for 'zig cc' as C compiler. by hessammehr · Pull Request #13757 · nim-lang/Nim, su GitHub. URL consultato il 19 aprile 2020.

Altri progetti

modifica

Collegamenti esterni

modifica
  Portale Informatica: accedi alle voci di Wikipedia che trattano di informatica

📚 Artikel Terkait di Wikipedia

Programmazione neurolinguistica

La programmazione neurolinguistica (PNL; in inglese neuro-linguistic programming, NLP) è un approccio pseudoscientifico alla comunicazione e un sistema

Lista concatenata

(1957). Programming the Logic Theory Machine. Proceedings of the Western Joint Computer Conference. pp. 230–240. Parlante, Nick (2001). Linked list basics

Tcl

Addison-Wesley, 2010, ISBN 978-0-321-33633-0. (EN) Ashok P. Nadkarni, The Tcl Programming Language: A Comprehensive Guide, 2017, ISBN 978-1548679644. Eggdrop Expect

Salvatore Sanfilippo (programmatore)

- YouTube, su YouTube. URL consultato il 10 febbraio 2026. ^ (EN) C programming language course, su YouTube. URL consultato il 10 febbraio 2026. ^ Wohpe

Python

org. ^ IronPython: the Python programming language for the .NET Framework, su ironpython.net. ^ The Python programming language for S60 mobile phones

Fortran

Disponibile con licenza GFDL (EN) User notes on Fortran programming (UNFP), su ibiblio.org. (EN) Clive Page's list of Fortran Resources, su star.le.ac.uk. Portale

Episodi di Elsbeth (seconda stagione)

Gives CBS Victory Among Broadcast Networks, su programminginsider.com, Programming Insider, 18 ottobre 2024. URL consultato il 18 ottobre 2024. Antonio

Programmazione generica

introdotte da Andrei Alexandrescu nel suo libro Modern C++ Design: Generic Programming and Design Patterns Applied del 2001. Successivamente il linguaggio D