Zig (programming language): Difference between revisions

Content deleted Content added
No edit summary
Goals: This not applies to the Go language.
Line 43:
In keeping with the overall design philosophy of making the code simple and easy to read, the Zig system as a whole also encompasses a number of stylistic changes compared to C and other C-like languages. For instance, the [[Rust (programming language)|Rust]] language has [[operator overloading]] which means a statement like {{code|a {{=}} b + c}} might actually be a function call to a type’s overloaded version of the plus operator. Further, that function might panic which might pre-empt any following code. In Zig, if something calls a function, it looks like a function call; if it doesn’t, it doesn’t look like a function call. If it can raise an error, it is explicit in the syntax,{{sfn|Yegulalp|2016}} error handling is handled through error types and can be handled with {{code|catch}} or {{code|try}}.
 
The goals of Zig are in contrast to those of many other languages designed in the same time period, like [[Go (programming language)|Go]], [[Rust (programming language)|Rust]], [[Carbon (programming language)|Carbon]], and [[Nim (programming language)|Nim]]. Generally, these languages are more complex with added features like [[operator overloading]], functions that masquerade as values (properties), and many other features intended to aid in building large programs. These sorts of features have more in common with C++’s approach, and these languages are more along the lines of that language.{{sfn|Yegulalp|2016}} Zig has a more conservative extension of the type system, supporting compile time generics and accommodating a form of [[duck typing]] with the {{code|comptime}} directive.
 
===Memory handling===