Content deleted Content added
No edit summary |
No edit summary |
||
Line 28:
<ref>{{cite web | url=https://blog.lohr.dev/after-a-day-of-programming-in-zig | title=After a day of programming in Zig | date=29 December 2023 }}</ref>
}}
'''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}}</ref> It is intended as a successor to the language [[C (programming language)|C]], 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> 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>
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>
Line 100:
==Compiler==
▲The Zig compiler 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> The Zig compiler exposes the ability to compile C and C++ similarly to [[Clang]] with the commands <code>zig cc</code> and <code>zig c++</code>,<ref>{{Cite web|url=https://ziglang.org/download/0.6.0/release-notes.html#zig-cc|title=0.6.0 Release Notes|website=Ziglang.org|access-date=2020-04-19}}</ref> providing many headers including the [[C standard library]] (libc) and [[C++ Standard Library]] (libcxx) for many different platforms, allowing Zig’s <code>cc</code> and <code>c++</code> sub-commands to act as [[cross compiler]]s out of the box.<ref>{{Cite web|title='zig cc': a Powerful Drop-In Replacement for GCC/Clang - Andrew Kelley|url=https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html|access-date=2021-05-28|website=andrewkelley.me}}</ref><ref>{{Cite web|title=Zig Makes Go Cross Compilation Just Work|url=https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho|access-date=2021-05-28|website=DEV Community|date=24 January 2021 |language=en}}</ref>
Zig treats cross-compiling as a first-class use-case of the language.<ref name=zig /> This means any Zig compiler can compile runnable binaries for any of its target platforms, of which there are dozens. These include not only widely-used modern systems like [[ARM architecture family|ARM]] and [[x86-64]], but also [[PowerPC]], [[SPARC]], [[MIPS architecture|MIPS]], [[RISC-V]] and even the IBM [[z/Architecture]]s (S390). The toolchain can compile to any of these targets without installing additional software, all the needed support is in the basic system.<ref name=zigo/> The experimental support is also provided for less known platforms like AMD and Nvidia GPUs or PlayStation 4 and 5 (with various degree of support).
Line 109 ⟶ 107:
Zig uses [[LLVM]] (written in C++) as a backend for optimization. Since version 0.10 the Zig compiler is written in the Zig programming language, i.e., it is a [[self-hosting compiler]]. The self-hosted linker is tightly coupled with the self-hosted compiler.
The previous [[Bootstrapping (compilers)|bootstrapping]] compiler, written in Zig and C++ using [[LLVM]] as a back-end,<ref>{{Cite web|url=https://www.gingerbill.org/article/2019/05/13/a-reply-to-the-road-to-zig/|title=A Reply to _The Road to Zig 1.0_|date=2019-05-13|website=www.gingerbill.org|language=en-gb|access-date=2020-02-11}}</ref><ref>{{Cite web|title=ziglang/zig|date=2020-02-11|url=https://github.com/ziglang/zig|website=GitHub|publisher=Zig Programming Language|access-date=2020-02-11}}</ref> supporting many of its native targets<ref>{{Cite web|url=https://ziglang.org/#Tier-System|title=The Zig Programming Language|website=Ziglang.org|access-date=2020-02-11}}</ref>, was removed in version 0.11.▼
==Packages==
Line 250 ⟶ 246:
</syntaxhighlight>
==
The name “Zig” was reportedly chosen through a process involving a [[Python (programming language)|Python]] script that randomly combined letters, starting with the letter “Z” and followed by a vowel or “Y”, in order to generate four-letter words. Despite the intended length, “Zig”, a three-letter word, was ultimately selected from the various combinations produced by the script.<ref>{{cite web |url=https://gist.github.com/andrewrk/73742bf4b8ed795c85ce |title=origin of the zig programming language name. by @andrewrk |author=andrewrk |date=2024-03-13 |access-date=2024-03-13}}</ref>
▲The previous [[Bootstrapping (compilers)|bootstrapping]] compiler, written in Zig and C++ using [[LLVM]] as a back-end,<ref>{{Cite web|url=https://www.gingerbill.org/article/2019/05/13/a-reply-to-the-road-to-zig/|title=A Reply to _The Road to Zig 1.0_|date=2019-05-13|website=www.gingerbill.org|language=en-gb|access-date=2020-02-11}}</ref><ref>{{Cite web|title=ziglang/zig|date=2020-02-11|url=https://github.com/ziglang/zig|website=GitHub|publisher=Zig Programming Language|access-date=2020-02-11}}</ref> supporting many of its native targets<ref>{{Cite web|url=https://ziglang.org/#Tier-System|title=The Zig Programming Language|website=Ziglang.org|access-date=2020-02-11}}</ref>, was removed in version 0.11.
== Community ==
|