Zig (programming language): Difference between revisions

Content deleted Content added
Add 'citation needed' template to claim of modernity. (Note: Other languages have had 'maybe', 'optional', and 'nullable' types for many years. E.g. Haskell's 'Maybe' type has been around since at least 2006.)
Rescuing 2 sources and tagging 0 as dead.) #IABot (v2.0.9.5
 
(14 intermediate revisions by 9 users not shown)
Line 11:
| latest preview version =
| latest preview date =
| typing = [[Static typing|Static]], [[Strong and weak typing|strong]], [[Type inference|inferred]], [[StructuralNominal type system|structuralnominal]], [[Generic programming|generic]]
| memory management = [[Manual memory management|Manual]]
| programming language = Zig
Line 29:
}}
 
'''Zig''', also known as Ziglang, <ref>{{Cite web |title=Home ⚡ Zig Programming Language |url=https://ziglang.org/ |access-date=2024-12-31 |website=ziglang.org}}</ref> is an [[Imperative programming|imperative]], [[General-purpose programming language|general-purpose]], [[statically typed]], [[Compiled language|compiled]] [[System programming language|system]] [[programming language]] designed by Andrew Kelley.<ref>{{Cite web |date=2021-10-19 |title=Taking the warts off C, with Andrew Kelley, creator of the Zig programming language |url=https://sourcegraph.com/podcast/andrew-kelley |access-date=2024-04-18 |website=Sourcegraph |language=en |archive-date=2025-01-05 |archive-url=https://web.archive.org/web/20250105083326/https://sourcegraph.com/podcast/andrew-kelley |url-status=dead }}</ref> It is [[free and open-source software]], released under an [[MIT License]].<ref>{{Cite web|url=https://github.com/ziglang/zig|title=ziglang/zig|website=GitHub|language=en|access-date=2020-02-11}}</ref>
 
A major goal of the language is to improve on the [[C (programming language)|C language]]<ref name="roadtozig1.0" /><ref>{{Cite web|url=https://ziglang.org/#Zig-competes-with-C-instead-of-depending-on-it|title=The Zig Programming Language|website=Ziglang.org|access-date=2020-02-11}}</ref> (also taking inspiration from [[Rust (programming language)|Rust]]<ref>{{Cite web |title=Zig programming language |url=https://sudonull.com/post/3683-Zig-programming-language |access-date=2020-02-11 |website=SudoNull |language=en}}</ref>{{sfn|Yegulalp|2016}}), with the intent of being even smaller and simpler to program in, while offering more functionality.<ref>{{Cite web |date=2017-10-31 |title=Zig has all the elegant simplicity of C, minus all the ways to shoot yourself in the foot |url=https://jaxenter.com/zig-language-kelley-interview-138517.html |archive-url=https://web.archive.org/web/20171101231710/https://jaxenter.com/zig-language-kelley-interview-138517.html |archive-date=2017-11-01 |access-date=2020-02-11 |website=JAXenter |language=en-US}}</ref> The improvements in language simplicity relate to flow control, [[Function (computer programming)|function calls]], [[Library (computing)|library]] imports, [[Declaration (computer programming)|variable declaration]] and [[Unicode]] support. Further, the language makes no use of [[Macro (computer science)|macros]] or [[preprocessor]] instructions. Features adopted from modern languages include the addition of [[compile time]] [[generic programming]] [[data type]]s, allowing functions to work on a variety of data, along with a small set of new [[compiler]] directives to allow access to the information about those types using [[reflective programming]] (reflection).<ref name=zig>{{Cite web|url=https://ziglang.org/|title=The Zig Programming Language|website=Ziglang.org|access-date=2020-02-11}}</ref> Like C, Zig omits [[Garbage collection (computer science)|garbage collection]], and has [[manual memory management]].<ref name=zig /> To help eliminate the potential errors that arise in such systems, it includes [[option type]]s, a simple [[Syntax (programming languages)|syntax]] for using them, and a [[unit testing]] framework built into the language. Zig has many features for [[Low-level programming language|low-level programming]], notably packed structs (structs without padding between fields), arbitrary-width integers<ref>{{Cite web |url=https://www.theregister.co.uk/2020/04/24/llvm_project_adds_support_for/ |title=Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers |last1=Anderson |first1=Tim |date=2020-04-24 |website=www.theregister.co.uk |language=en |access-date=2024-12-30}}</ref> and multiple pointer types.<ref name="zigdocumentation">{{Cite web|url=https://ziglang.org/documentation/master/|title=Documentation|website=Ziglang.org|access-date=2020-04-24}}</ref>
 
The main drawback of the system is that, although Zig has a growing community, as of 2025, it remains a new language with areas for improvement in maturity, ecosystem and tooling.<ref name="logrocket">{{cite web |last=Chigozie |first=Oduah |title=Comparing Rust vs. Zig: Performance, Safety, and More |url=https://blog.logrocket.com/comparing-rust-vs-zig-performance-safety-more/ |website=LogRocket Blog |date=2024-06-04 |access-date=2024-07-16}}</ref> Also the learning curve for Zig can be steep, especially for those unfamiliar with low-level programming concepts.<ref name="logrocket"/> The availability of learning resources is limited for complex use cases, though this is gradually improving as interest and adoption increase.<ref name="logrocket"/> Other challenges mentioned by the reviewers are interoperability with other languages (extra effort to manage data marshaling and communication is required), as well as manual memory deallocation (disregarding proper memory management results directly in memory leaks).<ref name="logrocket"/>
Line 254:
=== Versions ===
All releases, along with their release dates and pre-built platforms. <ref>{{Cite web|title=Download ⚡ Zig Programming Language|url=https://ziglang.org/download/|access-date=2025-05-06|website=ziglang.org}}</ref>
{|class="wikitable" style="text-align:center;"
!rowspan="2"|Name!!rowspan="2"|Date!!colspan="3"|Windows!!colspan="9"|Linux!!colspan="2"|macOS!!FreeBSD
|-
!x86_64!!x86!!aarch64!!x86_64!!x86!!aarch64!!armv6kz!!arm7a!!riscv64!!powerpc64le!!powerpc!!loongarch64!!x86_64!!aarch64!!x86_64
|-
|0.1.1||2017 Q4||{{ya}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}
|-
|0.2.0||2018 Q1||{{ya}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}
|-
|0.3.0||2018 Q3||{{ya}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}
|-
|0.4.0||2019 Q2||{{ya}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{ya}}
|-
|0.5.0||2019 Q3||{{ya}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{ya}}
|-
|0.6.0||2020 Q2||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}
|-
|0.7.0||2020 Q4||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.7.1||2020 Q4||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{ya}}
|-
|0.8.0||2021 Q3||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.8.1||2021 Q3||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.9.0||2021 Q4||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.9.1||2022 Q1||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.10.0||2022 Q4||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.10.1||2023 Q1||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{ya}}||{{na}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{na}}
|-
|0.11.0||2023 Q3||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.12.0||2024 Q2||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.12.1||2024 Q3||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.13.0||2024 Q3||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{na}}||{{ya}}||{{ya}}||{{ya}}
|-
|0.14.0||2025 Q1||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}{{Efn|This version of prebuilt binary is broken due to a regression in the LoongArch backend of LLVM.<ref>{{Cite web |title=Zig crashes on LoongArch64 · Issue #22859 · ziglang/zig |url=https://github.com/ziglang/zig/issues/22859 |access-date=2025-06-20 |website=GitHub |language=en}}</ref>|name=loongarch0.14}}||{{ya}}||{{ya}}||{{na}}
|0.14.0||2025 Q1||✅||✅||✅||✅||✅||✅||❌||✅||✅||✅||❌||✅||✅||✅||❌
|-
|0.14.1||2025 Q2||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}||{{ya}}||{{ya}}||{{na}}||{{ya}}{{Efn|name=loongarch0.14}}||{{ya}}||{{ya}}||{{na}}
|-
|}
{{Notelist}}
 
== Projects ==
Line 304 ⟶ 307:
* The TigerBeetle<ref>{{Cite web |title=tigerbeetle/tigerbeetle |url= https://github.com/tigerbeetle/tigerbeetle |access-date=2024-12-30 |website=Github |language=en}}</ref> financial transaction database is written in Zig.
* [https://github.com/Senryoku/Deecy Deecy], an up-and-coming (latest release as of this writing is version 0.3.0) [[emulator]] of [[Sega|Sega's]] [[Dreamcast]] home video gaming console platform, completely written in Zig from scratch.
* See a more comprehensive list of [https://linuxlock.org/blog/companies-using-zig/ companies and projects utilizing Zig in production].
 
==See also==
{{Portal|Free and open-source software|Computer programming}}
 
*[[C (programming language)|C]]
*[[C++]]
*[[D (programming language)|D]]
*[[Nim (programming language)|Nim]]
*[[Go (programming language)|Go]]
*[[Rust (programming language)|Rust]]
*[[Carbon (programming language)|Carbon]]
*[[V (programming language)|V]]
 
Line 364 ⟶ 360:
*[https://www.youtube.com/watch?v=Z4oYSByyRak Movie: Introducing Zig]
*[https://www.youtube.com/watch?v=Gv2I7qTux7g Movie: The Road to 1.0]
*[https://discu.eu/weekly/zig/ Zig Weekly] {{Webarchive|url=https://web.archive.org/web/20250114161926/https://discu.eu/weekly/zig/ |date=2025-01-14 }}
 
{{Programming languages}}
Line 381 ⟶ 377:
[[Category:Statically typed programming languages]]
[[Category:Systems programming languages]]
[[Category:Compiled programming languages]]