Zig: programming language designed for robustness optimality and clarity [video]
1–10 of 73 posts
Re: Zig: programming language designed for robustness optimality and clarity [video]
#2How do I decide which things are important enough? I am running out of time in my life also.
I watched a video a while ago about how the universe is expanding faster than light can travel, which means the portion of the universe that we can observe is an increasingly small subset of what's out there.
Sometimes my hobbies and wish-i-had-time-for-that projects feel the same way, they're expanding faster than I'll ever catch up to.
I wonder if zig will ever pursue some sort of memory safety. I find rust very difficult and unwieldy, but I can totally grok the appeal of RAII.
Re: Zig: programming language designed for robustness optimality and clarity [video]
#3There are too many cool languages and too few weekends. It's becoming more problematic, but at the same time it would seem impractical to optimize my life around learning every single thing that I want to learn. How do I decide which things are important enough? I am running out of time in my life also. I watched a video a while ago about how the universe is expanding faster than light can travel, which means the por…
That's exactly what Zig is designed for [1].
Andrew Kelley (andrewrk) discusses this in the talk. Zig is similar to Rust, but with memory safety designed into the core, not bolted on as an afterthought. And as the SHA-256 demo tests in the talk show, Zig is as fast or faster than C.
Re: Zig: programming language designed for robustness optimality and clarity [video]
#4There are too many cool languages and too few weekends. It's becoming more problematic, but at the same time it would seem impractical to optimize my life around learning every single thing that I want to learn. How do I decide which things are important enough? I am running out of time in my life also. I watched a video a while ago about how the universe is expanding faster than light can travel, which means the por…
> I wonder if zig will ever pursue some sort of memory safety. That's exactly what Zig is designed for [1]. Andrew Kelley (andrewrk) discusses this in the talk. Zig is similar to Rust, but with memory safety designed into the core, not bolted on as an afterthought. And as the SHA-256 demo tests in the talk show, Zig is as fast or faster than C. [1] http://ziglang.org [2] https://github.com/ziglang/zig
Re: Zig: programming language designed for robustness optimality and clarity [video]
#5Earlier quoted context omitted.
> I wonder if zig will ever pursue some sort of memory safety. That's exactly what Zig is designed for [1]. Andrew Kelley (andrewrk) discusses this in the talk. Zig is similar to Rust, but with memory safety designed into the core, not bolted on as an afterthought. And as the SHA-256 demo tests in the talk show, Zig is as fast or faster than C. [1] http://ziglang.org [2] https://github.com/ziglang/zig
I don't understand. Rust has memory safety as a core design principle. Zig has manual memory allocation like C.
That being said, some other potentially interesting safety aspects that are present (or are being explored) to give some idea of the target audience:
- compile-time alignment checks [1]
- maximum compile-time stack usage/bounding [2]
I would expect safety at the end of the day in Zig will be more similar to
modern C++ and its smart pointers, alongside (optional) runtime checks,
than a full lifetime system. Will have to see what the future holds.Re: Zig: programming language designed for robustness optimality and clarity [video]
#6Zig is designed not only for robustness, optimality, and clarity, but also for great justice.
It's great that Zig is an open source project so all your codebase belongs to us.
I hope 'Zig' takes off everywhere.
Re: Zig: programming language designed for robustness optimality and clarity [video]
#7* Type inference - var name = "Bob";
* Maybe types (from Elm/Haskell) that prevent NULL ptr bugs and syntactic sugar encourages its use for function return values.
if (doit()) |result| {
// result is always a populated Struct
} else |err| {
// error is always a populated Error
}
// a return type of !Something means Error type or Something type
fn doit() !Struct {
}
* Nullable types - var ?&object = null; if you need it, and var &object = aObject; if you want the safety.* Great C interop, though there is more work to be done here. (gtk.h for instance is too much for zig today) Zig's approach is unique here too. You specify .h files in the zig source code and the zig compiler translates C in the .h into zig. Its not a function bridge or wrapper, its zig objects and zig functions available to your zig code.
const c = @cImport({
@cInclude("curl/curl.h");
});
var curl = c.curl_easy_init();
if(curl != null) {
_ = c.curl_easy_setopt(curl, c.CURLoption(c.CURLOPT_URL), url_cstr.ptr);
...
* Standard library operations that allocate memory take an 'allocator object' parameter that should give great programmer control over memory management (I didnt get into this myself), webasm is a compiler target, and lots moreRe: Zig: programming language designed for robustness optimality and clarity [video]
#8- compiles faster than C
- Produces faster machine code than C
- Seamless interaction with C libs
- robust/ergonomic error handling
- Compile-time code execution and reflection
- No hidden control flow
- No hidden memory allocations
- Ships with build system
- Out-of-the-box cross compilation
Re: Zig: programming language designed for robustness optimality and clarity [video]
#9There are too many cool languages and too few weekends. It's becoming more problematic, but at the same time it would seem impractical to optimize my life around learning every single thing that I want to learn. How do I decide which things are important enough? I am running out of time in my life also. I watched a video a while ago about how the universe is expanding faster than light can travel, which means the por…
Re: Zig: programming language designed for robustness optimality and clarity [video]
#10I've been building a toy project in zig in the last couple weeks. Zig is incredible. After only a short while working with it, it feels like deserves the title of a "better C". With no runtime overhead you get: * Type inference - var name = "Bob"; * Maybe types (from Elm/Haskell) that prevent NULL ptr bugs and syntactic sugar encourages its use for function return values. if (doit()) |result| { // result is always a…
Additionally, Swift has essentially the same approach to C FFI.