Live data from Hacker News

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

dayvster.com

11–20 of 412 posts

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

#11

"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.

Came here to add the same comment. Had it on my clipboard already to post. You said it better

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

#14

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 never found the time.

Nim I like the concept and the idea of but the python-like syntax just irks me. haha I can't seem to get into languages where indentation replaces brackets.

But the GC part of it is pretty neat, have you checked Go yet?

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

#15

"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.

The amount of seggfaults I have seen with Ghostty did not raise my spirits.

I haven't seen a single one.

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

#16
post #4

As far as my understanding of zig goes....it can compile into C....so if you really want secure C code you can compile zig into C?

Not quite, it can translate C into zig using the `translate-c` command that it comes with. But it compiles directly into machine code

There is a C backend, so you can also compile Zig into C if you want.

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

#17

As far as my understanding of zig goes....it can compile into C....so if you really want secure C code you can compile zig into C?

While Zig prevents certain kinds of memory safety issues that C does not, it still suffers from memory-safety issues not found in safe Rust.

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

#18

"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.

Segfaults go brrr.

All jokes aside, it doesn’t actually take much discipline to write a small utility that stays memory safe. If you keep allocations simple, check your returns, and clean up properly, you can avoid most pitfalls. The real challenge shows up when the code grows, when inputs are hostile, or when the software has to run for years under every possible edge case. That’s where “just be careful” stops working, and why tools, fuzzing, and safer languages exist.

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

#19

IMO, as a C++ developer, Swift makes the most sense to me if I were looking for a safer alternative. I think people prefer what's familiar to them, and Swift definitely looks closer to existing C++ to me, and I believe has multiple people from the C++ WG working on it now as well, supposedly after getting fed up with the lack of language progress on C++. The most recent versions gained a lot in the way of cross-platf…

Can you share some swift resources so I can look into the features of swift compared to zig and C?

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

#20
post #4

Earlier quoted context omitted.

Not quite, it can translate C into zig using the `translate-c` command that it comes with. But it compiles directly into machine code

There is a C backend, so you can also compile Zig into C if you want.

yea but, that's extremely edge case, or at least I have not yet encountered a need for that personally.
Post reply on HN