Friday, November 16, 2018 [Tweets] [Favorites]

The Zig Programming Language

Andrew Kelley (via Dan Luu):

Zig is an LLVM frontend, taking advantage of libclang to automatically import .h files (including macros and inline functions). Zig uses its own linker (LLD) combined with lazily building compiler-rt to provide out-of-the-box cross-compiling for all supported targets. Zig is intended to replace C. It provides high level features such as generics, compile time function execution, and partial evaluation, yet exposes low level LLVM IR features such as aliases. The Zig project believes that software can and should be perfect.

I liked the discussion about failed memory allocations and how Zig gives you a lot of information when an error occurs.

Why Zig:

The entire concept of the heap is strictly in userspace. There are some standard library features that provide and work with heap allocators, but those are optional standard library features, not built into the language itself. If you never initialize a heap allocator, then you can be sure your program is never going to cause heap allocations.

1 Comment

This is funny how they clam that this should be a readable and expressive language, but they are trying very hard to make thing as short as possible (and so unreadable and inexpressive).
Using 'pub' for public, 'fn' for function, '!' instead of throws, etc…

Wouldn't 'public func main() void throws' be far more readable than 'pub fn main() !void' ?

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment