Live data from Hacker News

When Zig Is Safer and Faster Than Rust

zackoverflow.dev

51–58 of 58 posts

Re: When Zig Is Safer and Faster Than Rust

#51
post #28
post #7

Apart from syntax sugar over which I agree should be improved, the argument sells to boil down to: my language doesn't enforce a borrow checker so it is UB safe. Which in my book is just not true. The allocator example the user gives is not really good since if he had another try in between the alloc/free I assume the memory would not be freed, Drop semantic is better in that regard. You can also set a global alloc t…

> try between the alloc/free The idiomatic way to handle that is with some combination of `defer` and `errdefer`. Then, in code, there are no lines between alloc/free, and if a try would exit before the free then you would instead first free anyway. > drop semantic is better in that regard The drop trait has its warts too. Zig's version sets up a point in time where the given cleanup code _will_ run (ignoring power o…

>The idiomatic way to handle that is with some combination of `defer` and `errdefer`. Then, in code, there are no lines between alloc/free, and if a try would exit before the free then you would instead first free anyway.

Do I understand correctly, that talking about idiomatic way is the same as talking about programming style, but not about language semantic?

Re: When Zig Is Safer and Faster Than Rust

#52
post #28

Earlier quoted context omitted.

> try between the alloc/free The idiomatic way to handle that is with some combination of `defer` and `errdefer`. Then, in code, there are no lines between alloc/free, and if a try would exit before the free then you would instead first free anyway. > drop semantic is better in that regard The drop trait has its warts too. Zig's version sets up a point in time where the given cleanup code _will_ run (ignoring power o…

>The idiomatic way to handle that is with some combination of `defer` and `errdefer`. Then, in code, there are no lines between alloc/free, and if a try would exit before the free then you would instead first free anyway. Do I understand correctly, that talking about idiomatic way is the same as talking about programming style, but not about language semantic?

Correct. Much like in Python or C, you can explicitly handle every error/break/early-return condition and manually free the resource. Each language offers a tool to make that easier (and more likely to be correct, especially as the code changes) in most cases though. In Python it's try/finally, in C it's `goto ERR`, and in Zig it's defer/errdefer.

Re: When Zig Is Safer and Faster Than Rust

#53
post #52

Earlier quoted context omitted.

>The idiomatic way to handle that is with some combination of `defer` and `errdefer`. Then, in code, there are no lines between alloc/free, and if a try would exit before the free then you would instead first free anyway. Do I understand correctly, that talking about idiomatic way is the same as talking about programming style, but not about language semantic?

Correct. Much like in Python or C, you can explicitly handle every error/break/early-return condition and manually free the resource. Each language offers a tool to make that easier (and more likely to be correct, especially as the code changes) in most cases though. In Python it's try/finally, in C it's `goto ERR`, and in Zig it's defer/errdefer.

So, you can't rely that someone will follow that style in Zig. That is my point.

Re: When Zig Is Safer and Faster Than Rust

#54
post #37
post #27

Earlier quoted context omitted.

Then there's Nim which is great as a general purpose language and has great ergonomics too.

But, ran by a BDFL that doesn't ever want to become a foundation and share power, is known to throw tempter tantrums, and freaks about LGBTQ people and creators.

I would ask for a source for your claim but we both know it's bull.

Re: When Zig Is Safer and Faster Than Rust

#55

I feel like there's space for imperative, garbage collected, pattern matching, and ADT language. Just Golang + pattern matching + ADT. I would be sooooooooooooooooooooooooo happy. I think there ought to be a subset of Rust that uses Arc for everything, maybe with a language feature that desugars into it. Obviously this requires compilers to be able to reason and optimize out atomics.

C# is headed this way. Typescript is there but only if you can ignore the fact that it is JavaScript masquerading as a more serious language for halloween.

Re: When Zig Is Safer and Faster Than Rust

#56

I feel like there's space for imperative, garbage collected, pattern matching, and ADT language. Just Golang + pattern matching + ADT. I would be sooooooooooooooooooooooooo happy. I think there ought to be a subset of Rust that uses Arc for everything, maybe with a language feature that desugars into it. Obviously this requires compilers to be able to reason and optimize out atomics.

Borgo https://news.ycombinator.com/item?id=40211891

Re: When Zig Is Safer and Faster Than Rust

#57
post #37

Earlier quoted context omitted.

But, ran by a BDFL that doesn't ever want to become a foundation and share power, is known to throw tempter tantrums, and freaks about LGBTQ people and creators.

I would ask for a source for your claim but we both know it's bull.

I wrote this on Mastodon, but I will copy it over here. Because he spouts nonsense all across the forum on a fairly regular basis.

The creator is a BDFL but they are against setting up a foundation because they "lost faith in mankind" and then ranted about "master vs main" on git, and used that to segue into a mini-rant on essentially "woke" ideology. In less than 500 characters.

> Here is a hint: If you are obsessed with racism and sexism it's because you're a racist and sexist. Now go and cancel "He-Man - Masters of the Universe" because obviously He-Man is a slave owner.

I get the vibe they might be racist, sexist, and just a bit out-of-touch with reality. I wouldn't trust having corporate code, or any code, built on it. Dude is a bit unhinged in that regard.

["Nim Forum: Nim Succession Plan, 2023"](https://forum.nim-lang.org/t/10312)

Re: When Zig Is Safer and Faster Than Rust

#58
post #57

Earlier quoted context omitted.

I would ask for a source for your claim but we both know it's bull.

I wrote this on Mastodon, but I will copy it over here. Because he spouts nonsense all across the forum on a fairly regular basis. The creator is a BDFL but they are against setting up a foundation because they "lost faith in mankind" and then ranted about "master vs main" on git, and used that to segue into a mini-rant on essentially "woke" ideology. In less than 500 characters. > Here is a hint: If you are obsessed…

He's not unhinged, just a right-wing politically. If you believe it's a crime or that we should all ignore software based on political alignment of their creators, thats telling me more about you, than Nim's BDFL.

> all across the forum on a fairly regular basis.

Two times, more than 2 years ago is not "all across" and neither it's "regular". I am a regular user on the forum, and I haven't seen any rants apart from two you referenced here.

> and just a bit out-of-touch with reality.

*a bit out of touch with american politics

Post reply on HN