Live data from Hacker News

Zig as an alternative to writing unsafe Rust

zackoverflow.dev

51–60 of 230 posts

Re: Zig as an alternative to writing unsafe Rust

#51

Earlier quoted context omitted.

Agreed, using Rust is like switching a monster (C++) for another even worse. And notice that Rust is not even a mature language, it will get much worse. I will stay with C, thank you.

At least C++ is enormous and you can find a sane subset that you enjoy using. And C++ can be pretty safe with smart pointers.

Unfortunately there is always that clever one than can't let go of writing C style code, regardless of what kind of pointers are being used.

It is one of my favourite languages, but I also acknowledge that C compatibility is a big pain point for security.

Re: Zig as an alternative to writing unsafe Rust

#52

Earlier quoted context omitted.

Agreed, using Rust is like switching a monster (C++) for another even worse. And notice that Rust is not even a mature language, it will get much worse. I will stay with C, thank you.

'constexpr' and 'auto' in modern C++ can eliminate a large portion of the ugliness. In some cases it can be much more ergonomic than the equivalent Rust.

Indeed, one gets to write macro like code on the same language.

Re: Zig as an alternative to writing unsafe Rust

#53
post #46
post #17

Earlier quoted context omitted.

It's intentionally using the naive 2^N solution to stress test lots of tiny function calls.

There is no way it will take a whole second regardless. Even when compiled in debug mode, it takes about 100 ms. Try it here, I had Bing AI write it out - https://play.rust-lang.org/?version=stable&mode=release&edit...

OP isn't talking about the performance of Rust code to calculate fib(35), but rather the performance of a Rust implementation vs a Zig implementation of an interpreted language executing code to calculate fib(35). They are saying that the Rust VM they wrote is slower than the Zig VM they wrote.

Re: Zig as an alternative to writing unsafe Rust

#54
post #37

Earlier quoted context omitted.

On top of that Rust might be the ugliest modern language.

People keep saying this and I just do not get it . It's just… not that bad?

It's not about actual ugliness, it's just something that is hard to articulate as something other than ugliness. https://matklad.github.io/2023/01/26/rusts-ugly-syntax.html

Re: Zig as an alternative to writing unsafe Rust

#55
post #37

Earlier quoted context omitted.

People keep saying this and I just do not get it . It's just… not that bad?

The core language is fine, but when you actually start building things you need to introduce lifetimes, all the traits that you polluted your interface with and then add on async, it gets out-of-hand quickly.

The top comment gave a perfect example: #![feature(strict_provenance)]

These feature enablement blocks drive me crazy. You could go from codebase to codebase and it's almost like you are working in a different language depending on how many of these are enabled or not. I've been trying rust on and off since it's release, and I still have yet to feel like I have a grasp on some "core" subset of the language I can fall back on to solve most of my problems. I always have to scour documentation for the hot new thing to turn on or do, and this isn't to scorn innovation and change, but it does get exhausting at some point.

(Please release a spec)

Re: Zig as an alternative to writing unsafe Rust

#56
post #16

Earlier quoted context omitted.

UB in unsafe rust sometimes "leaks" outside the unsafe scope and cause crashing elsewhere. If rust can pair with a proof checker and let user write some correctness proof, it can be way more useful than the current borrow checker.

Are you talking about Miri, or something even stronger?

Miri doesn't do proofs. It only checks the test cases that you run under it.

Re: Zig as an alternative to writing unsafe Rust

#57

Earlier quoted context omitted.

> Rust is the inverse of Perl: It makes the easy stuff hard. It's a bargain. Rust is pretty great, but it doesn't make some things easy because it would make everything else hard. This comment is amusing, mostly because Perl is so full of tradeoffs. Do you want to write something to do some string parsing quickly? Great language, maybe. Do you want to understand what you've written later? Maybe not so great. > Writin…

> And I'm not sure anyone loves this attitude either. Keep it technical. Still, we, the Rust community, should take the high road and respond to the criticism by assuming that it's valid and asking what we can do better. I, for one, don't want developers to reject my Rust-based library because of the community's reputation, especially once my library has a C API.

> Still, we, the Rust community, should take the high road and respond to the criticism by assuming that it's valid and asking what we can do better.

I have to disagree. I think this meme/issue has been talked to death. And I'm sure I find retrograde, sour-pussing about Rust just as distasteful as others find dewy Rust optimism. The answer is -- they're both silly. Draw the line at speaking about the tech or the comment or person in front of you. Speaking about stereotypes in "communities" is about as vacuous as a Valley Girl's/Perl programmer's head[0].

[0]: a joke!

Re: Zig as an alternative to writing unsafe Rust

#58

Earlier quoted context omitted.

Writing data structures is trivial in C/C++.

As long as you don't care about UB or edge cases. Every time Rust makes something hard, it's forcing you to handle an edge case up front.

It's blowing my mind how many commenters here don't understand this.

Rust isn't hard just for fun. It's hard because the code you've been writing for so long is actually bad and you've not been thinking it through appropriately. This is why we keep finding serious bugs in code that is decades-old, despite the belief that code so old must be well-tested by now.

Re: Zig as an alternative to writing unsafe Rust

#59
post #33

Earlier quoted context omitted.

> And I'm not sure anyone loves this attitude either. Keep it technical. If I didn't include that proviso, I'd have someone arguing with me to the death about how I'm completely wrong and an idiot who doesn't understand the Correct Way of doing things.

This is the same as people behaving as jerks claiming that other people are jerks.

If you define "being a jerk" to include "calling out someone for being a jerk" then you will never be able to improve the situation.

Re: Zig as an alternative to writing unsafe Rust

#60

Earlier quoted context omitted.

Are you talking about Miri, or something even stronger?

Miri doesn't do proofs. It only checks the test cases that you run under it.

Interesting, I wonder if there are any good proof verifiers for Rust.
Post reply on HN