Live data from Hacker News

Zig feels more practical than Rust for real-world CLI tools

dayvster.com

81–90 of 412 posts

Re: Zig feels more practical than Rust for real-world CLI tools

#81

The fact that your app crashes when you run out of stack is a compiler bug, not a feature. Memory is memory. The fact that languages in the 40s split in it to stack and heap, doesn't make it a foundational mathematical law. Yes, safety isn't correctness but if you can't even get safety then how are you supposed to get correctness? For small apps Zig probably is more practical than Rust. Just like hiring an architect…

Behold, I've brought you a compiler bug.

https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re: Zig feels more practical than Rust for real-world CLI tools

#82
post #67
post #33

Earlier quoted context omitted.

> Seasoned Rust coders don’t spend time fighting the borrow checker My experience is that what makes your statement true, is that _seasoned_ Rust developers just sprinkle `Arc` all over the place, thus effectively switching to automatic garbage collection. Because 1) statically checked memory management is too restrictive for most kinds of non trivial data structures, and 2) the hoops of lifetimes you have to go to t…

> _seasoned_ Rust developers just sprinkle `Arc` all over the place No, this couldn't be further from the truth.

If they aren't sprinkling `Arc` all over, what are they seasoning with instead?

Re: Zig feels more practical than Rust for real-world CLI tools

#83
post #82
post #67

Earlier quoted context omitted.

> _seasoned_ Rust developers just sprinkle `Arc` all over the place No, this couldn't be further from the truth.

If they aren't sprinkling `Arc` all over, what are they seasoning with instead?

'a

Re: Zig feels more practical than Rust for real-world CLI tools

#84

I want to like Zig, but D still exists and feels like everything I want from a C-like alternative to C++ I just wish the rest of the industry had adopted it long ago. Zig has a strange syntax, and Rust is basically eating chunks of the industry, especially in programmer tooling across various languages as is Go (it powers most cloud providers and is the 2nd top choice for AI right after Python).

I remember before Rust when Go vs. D was the topic of the day. I even bought a D book and was working through it when Go was announced, and it won me over. The difference maker for me was the standard library; working with Go was just easier, full stop. That and using names like 'int64' instead of 'double', because that's what my brain likes apparently.

100% agree. I really love D the language, if I could go back in time I would find Walter and challenge him that he couldn't write {insert half of the Go std lib packages} into the STD lib for D because its too hard and impossible, in the hopes he takes the bait. I would love to see something like a 'Framework' for D that is maintained by the maintainers, but isn't necessarily the standard library, because people get really touchy when you mess with the STD lib, maybe a way to test the waters before actually adding new packages to it, having an HTTP server OOTB with D would be amazing.

Re: Zig feels more practical than Rust for real-world CLI tools

#85

"All it took was some basic understanding of memory management and a bit of discipline." The words of every C programmer who created a CVE.

are you saying that such understanding isn't enough or that every C programmer who said that didn't understand those things? C and Zig aren't the same. I would wager that syntax differences between languages can help you see things in one language that are much harder to see in another. I'm not saying that Zig or C are good or bad for this, or that one is better than the other in terms of the ease of seeing memory pr…

Just understanding the rules are not enough, you also need to be consistently good so that you never make a mistake that gets into production.

On both your average days and your bad days.

Over the 40 to 50 years that your carer lasts.

I guess those kind of developers exist, but I know that I'm not one of them.

Re: Zig feels more practical than Rust for real-world CLI tools

#86
post #82

Earlier quoted context omitted.

If they aren't sprinkling `Arc` all over, what are they seasoning with instead?

'a

Can't be. Lifetime annotations are present in unseasoned Rust. The question was about what seasoning are being added, if not `Arc`?

Re: Zig feels more practical than Rust for real-world CLI tools

#87

What are your thoughts on nim, odin and v-lang, D-lang? I feel like I am most interested about nim given how easy it was to pick up and how interoperable it is with C and it has a garbage collector and can change it which seems to be great for someone like me who doesn't want to worry about manual memory management right now but maybe if it becomes a bottleneck later, I can atleast fix it without worrying too much..

I have not given any of those 3 a fair enough shot just yet to make a balanced and objective decision. Out of all of them from what little I know and my very superficial knowledge Odin seems the most appealing to me, it's primary use case from what I know is game development I feel like that could easily pivot into native desktop application development was tempted to make a couple of those in odin in the past but ne…

Odin has no primary use case, it just happens that a lot of the members in the community have made or are interested in game making

Re: Zig feels more practical than Rust for real-world CLI tools

#88
post #33

Earlier quoted context omitted.

> Seasoned Rust coders don’t spend time fighting the borrow checker My experience is that what makes your statement true, is that _seasoned_ Rust developers just sprinkle `Arc` all over the place, thus effectively switching to automatic garbage collection. Because 1) statically checked memory management is too restrictive for most kinds of non trivial data structures, and 2) the hoops of lifetimes you have to go to t…

This is exactly the opposite of what he’s saying, using Arc everywhere is hacking around the borrow checker , a seasoned rust developer will structure their code in a way that works with the borrow checker; Arc has a very specific use case and a seasoned rust developer will rarely use it

This is awkward. I've written a fair amount of rust. I reach for Arc frequently. I see the memory layout implications now.

Do you tend to use a lot of Arenas?

Re: Zig feels more practical than Rust for real-world CLI tools

#89

The benefit of Zig seems to be that it allows you to keep thinking like a C programmer. That may be great, but to a certain extent it’s also just a question of habit. Seasoned Rust coders don’t spend time fighting the borrow checker - their code is already written in a way that just works. Once you’ve been using Rust for a while, you don’t have to “restructure” your code to please the borrow checker, because you’ve a…

> Seasoned Rust coders don’t spend time fighting the borrow checker I like the fact that "fighting the borrow checker" is an idea from the period when the borrowck only understood purely lexical lifetimes. So you have to fight to explain why the thing you wrote, which is obviously correct, is in fact correct. That's already ancient history by the time I learned Rust in 2021. But, this idea that Rust will mean "fighti…

I think the phrase _emotionally_ resonates with people who write code that would work in other languages, but the compiler rejects.

When I was learning rust (coming from python/java) it certainly felt like a battle because I "knew" the code was logically sound (at least in other languages) but it felt like I had to do all sorts of magic tricks to get it to compile. Since then I've adapted and understand better _why_ the compiler has those rules, but in the beginning it definitely felt like a fight and that the code _should_ work.

Re: Zig feels more practical than Rust for real-world CLI tools

#90
post #33

The benefit of Zig seems to be that it allows you to keep thinking like a C programmer. That may be great, but to a certain extent it’s also just a question of habit. Seasoned Rust coders don’t spend time fighting the borrow checker - their code is already written in a way that just works. Once you’ve been using Rust for a while, you don’t have to “restructure” your code to please the borrow checker, because you’ve a…

> Seasoned Rust coders don’t spend time fighting the borrow checker My experience is that what makes your statement true, is that _seasoned_ Rust developers just sprinkle `Arc` all over the place, thus effectively switching to automatic garbage collection. Because 1) statically checked memory management is too restrictive for most kinds of non trivial data structures, and 2) the hoops of lifetimes you have to go to t…

I did some quick search, not sure if this supports or denies your point:

- 151 instances of "Archttps://github.com/search?q=repo%3Aservo%2Fservo+Arc%3C&type...

- 5 instances of "Archttps://github.com/search?q=repo%3Arusoto%2Frusoto%20Arc%3C&...

- 0 instances for "Archttps://github.com/search?q=repo%3Acgag%2Floc%20Arc%3C&type=...

Post reply on HN