Live data from Hacker News

Zig's New Relationship with LLVM

kristoff.it

241–250 of 295 posts

Re: Zig's New Relationship with LLVM

#241
post #176

Earlier quoted context omitted.

The site specifically instructs you to visit the releases page which only offers 0.6.0

This is just not true, the master build is literally the first thing you see on the download page. Don't get me wrong, it should be clarified on the ziglearn website anyway.

>This is just not true, the master build is literally the first thing you see on the download page.

"Literally the first thing" that I see on the download page is:

>Releases

>You can also [install Zig from a package manager.](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Packa...)

Going by the AUR package script and the table in the wiki itself, those instructions will install 0.6.0. This is also what gravitas said in the OP of this thread.

Anyway, I see ziglearn.org has now been fixed to make it clear, with https://github.com/Sobeston/ziglearn/commit/10b14426e26ffcdb... , so all's well now.

Re: Zig's New Relationship with LLVM

#243

Earlier quoted context omitted.

Wait doesn’t Zig compete with C, not C++? IIRC it doesn’t have any intuitive form of typeclasses.

This claims to do runtime dynamic dispatch with interfaces: https://github.com/alexnask/interface.zig

I need it to be a first-class feature because I’m a baby. My #1 complaint with C++ is that they make everything a lower-class feature to avoid breaking backwards compatibility and it makes the language more verbose, less enjoyable, and less intuitive.

All that said, I’m personally okay with the decision to omit typeclasses since the language is meant to compete with C, not C++.

Re: Zig's New Relationship with LLVM

#244

Earlier quoted context omitted.

This claims to do runtime dynamic dispatch with interfaces: https://github.com/alexnask/interface.zig

I need it to be a first-class feature because I’m a baby. My #1 complaint with C++ is that they make everything a lower-class feature to avoid breaking backwards compatibility and it makes the language more verbose, less enjoyable, and less intuitive. All that said, I’m personally okay with the decision to omit typeclasses since the language is meant to compete with C, not C++.

I think Zig competes with C++, too. But to match the expressivity of C++ you don't necessarily need to have the exact same features. C++ gives you control over generics with concepts, and Zig does it differently -- with introspection, which is very much a first-class feature. If Zig wanted to achieve what other languages do in the same way they do it, it wouldn't be radical. Instead, it offers a different way. When comparing two languages, especially those designed with drastically different aesthetics, you don't ask how easily can an expression in one language be translated to the other, but how easy it is to achieve similar general goals.

Re: Zig's New Relationship with LLVM

#245
post #44
post #36

With PIC, incremental compilation, and function calls through a GOT, can Zig patch a running binary as well?

You're totally right that at least 90% of the infrastructure is there. Andrew's been threatening to implement hot code swapping in a live stream but has been busy with other tasks it seems.

With the proper editor integration, that would sell me on Zig; that's easily in my top 5 features that keeps me with Lisp.

Re: Zig's New Relationship with LLVM

#246
post #244

Earlier quoted context omitted.

I need it to be a first-class feature because I’m a baby. My #1 complaint with C++ is that they make everything a lower-class feature to avoid breaking backwards compatibility and it makes the language more verbose, less enjoyable, and less intuitive. All that said, I’m personally okay with the decision to omit typeclasses since the language is meant to compete with C, not C++.

I think Zig competes with C++, too. But to match the expressivity of C++ you don't necessarily need to have the exact same features. C++ gives you control over generics with concepts, and Zig does it differently -- with introspection, which is very much a first-class feature. If Zig wanted to achieve what other languages do in the same way they do it, it wouldn't be radical. Instead, it offers a different way. When c…

I think Zig competes with a school of C++ that tries to stick to a simpler, limited subset of C++. Games is one area where C++ is much more common than C, but also where a lot of C++ practices (exceptions, excessive template use, many parts of the stdlib) are discouraged and things tend to be kept "simpler".

I'm sure there are a good handful of other fields that currently write "minimal C-like C++" and I think Zig competes with C++ in those cases.

Re: Zig's New Relationship with LLVM

#247

Earlier quoted context omitted.

For a while there was a link to TIO (tio.run) on the zig homepage where you could play with it online. But for some reason it has been removed.

The version that tio has is very old at this point. Godbolt stays up to date.

There wasn't any incentive to update it once Zig removed it from the homepage.

Re: Zig's New Relationship with LLVM

#248
post #109

Earlier quoted context omitted.

Again, it's not about what you are able to do in Rust vs. Zig, it's essentially about the API of the language. Zig's semantics around memory management are imperative: i.e. you are telling the compiler when to allocate and deallocate memory. Rust's are declarative: you tell the compiler how the memory for a given value should be managed, and the compiler interprets these requirements to decide when memory should be a…

> The point is there are also cases where imperative, explicit memory management is desirable. I agree that is the case, and Zigs convention of passing an allocator around and making those calls very explicit has merit. I think you are over-estimating the amount of "magic" in Rust though. The allocation-related logic is not part of the language or the compiler, but comes from the std (or alloc) crate. You just don't…

> But nothing in Zig would stop me from having a global variable with an allocator, and using that without passing it around.

That's correct and you probably should do that in your own applications, but it will be frowned upon in libraries, and people will not choose to use them if you make that choice.

There's also another pattern, where you stuff a pointer to your allocator in your struct and have your "object" carry around its allocation system, you don't have to pass around allocators that way.

Re: Zig's New Relationship with LLVM

#249
post #52

Zig is one of the most interesting languages I've seen in a very long time, and possibly the first radical breakthrough in low-level programming design in decades. Maybe it will become a big success and maybe it will tank, but after having two visions for low-level programming -- that of C's "syntax-sugared Assembly", or that of C++'s "zero-cost abstractions" whose low-level, low-abstraction code appears high level o…

> also inspires a new approach to partial evaluation, replacing generics and value templates, concepts/traits/typeclasses, constexprs/procedural macros, macros (or, at least, the "good parts" of macros) and conditional compilation with a single, simple feature. So, zig is new to me but looking at an overview of the feature in question here this feels pretty hyperbolic? I certainly agree that the approach it takes is…

It's not super revolutionary. Other languages (like elixir) have something similar.

Re: Zig's New Relationship with LLVM

#250
post #17

Earlier quoted context omitted.

If anything, Zig will have much fewer restrictions (no borrow checker) than Rust when it comes to web dev, once Zig matures to the point where there is a good standard HTTP client and server implementation and a package manager. I'm a fan of Rust for things like a missile control system or a stock exchange, but not, say, writing a CRM. I'd gladly write a CRM in Zig however, given the proper library support and toolin…

While I like what Rust is trying to achieve, I would never use something that is not formally proven. There are many, many other static analysis tools in the C and Ada world that can achieve exactly the same thing. They imply less risk, they are way more mature (~40 yo) and have bigger communities around them. Zig is a better C and C++. It should be used accordingly. It will do well in game servers, simulation server…

There is work to get Rust qualified for safety critical domains [1]. Someone else pointed out that parts of the borrow checker have been formally proven already. Still a long road ahead, but I'm glad people are looking at it.

https://ferrous-systems.com/blog/sealed-rust-the-pitch/

Post reply on HN