Zig vs. Rust - ByteScout

Zig vs. Rust

Zig vs. Rust

Zig needs only 75% of both the data that Rust needs. Zig is more quickly typed and spoken than Rust. And although Rust is much behind “C,” Zig is well behind Rust in the vocabulary. Both are LLVM-based and low-level enough for all the users to control completely. Their best-case run-time efficiency is essentially the same in this regard.

The compilation process is just where Zig is quicker. Zig’s processor has much less effort to meet because it has fewer high-level expressions and weaker safety assurances than Rust. The two collocations are comparable when using benchmarks for some elementary programming issues.

When trying to write a generic process, Rust will verify that the feature is type-safe for every appropriate value of the generic criteria. Zig will demonstrate that the quality is type-safe just for the parameters used to call it.

On the one hand, this enables Zig to use arbitrarily chosen compile-time logic, whereas Rust must limit itself to techniques work (traits, etc.) for which overall proofs can be formed. This gives Zig a lot of expressive power while also simplifying the language.

Zig also lacks the fully automated, machine-checked documentary evidence of type constraints that Rust has, and providing IDE assistance may be more difficult. When it is secure to do so, both languages will add implicit casts among primitive types and pointers; alternatively, explicit casts will be required.

Zig has no similar defense. Integrating the same logic as Send/Sync in comp time Zig is feasible, but the regulations would have to be much more rigid without the ability to track ownership. Rust prevents numerous mutable pointers to the same recollection region from existing at the very same time.

Many features used in Adhoc coding in the past (e.g., information that varies their design based on the data element) and characteristics that require extending the compiler in Rust can now be implemented directly by Zig’s compile-time reflection (ee.g.generic functions with specialized implementations for specific types).

Zig lacks a method to prevent UAF from escalating into security flaws. The new GPA can identify some types of UAF, but the detonation overhead is prohibitively expensive for manufacturing use.

Outside of UAF, Rust can best protect against many types of bugs, particularly data races, but also iterator invalidation.

Rust makes leaking memory/resources much more difficult, especially dealing with mistake paths.

Zig does have a lower cognitive overhead than Rust, and I can express myself more directly.

Zig is far more likely than Rust to achieve speedy feedback mechanisms (e.g., sub-second hot code reloading for large projects).

Conclusion

Most locations where Zig is easier than Rust are unrelated to the lifetime system, and claims that all of Rust’s other characteristics are needed to support the lifetime system are not convincing.

Promoting something like nano processes is a more promising alternative. This would not prevent UAF, but it would make it more difficult to exploit by requiring the attacker to exit several runtime environments before obtaining access to valuable features.

   

About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.  
prev
next