Yes-rs:一个快速、内存安全的经典Unix yes命令的重写版本
Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command

原始链接: https://github.com/jedisct1/yes-rs

`yes-rs` 是对经典 Unix 命令 `yes` 的 Rust 重写,目标是实现极速和内存安全,以解决原始 C 实现中被认为的不足之处。它拥有零成本抽象、无畏并发(未来特性)和易于 Cargo 集成的优点。作者强调了 Rust 相比 C 的优势,重点关注内存安全。虽然 Rust 版本的代码行数明显更多(1302 行 vs C 的 50 行),但它声称性能更优。他们鼓励贡献者遵守严格的 Rust 原则:内存安全、速度和零成本抽象。作者大力推广 Rust,并建议在 Hacker News 上分享该项目,以提高知名度并倡导 Rust 在系统编程中的应用。

Hacker News上爆发了一场关于“Yes-rs”的讨论,这是一个用Rust重写的简单的Unix“yes”命令。最初的评论强调了该项目与GNU版本相比,代码行数激增了26倍,质疑其成本效益。一些人认为“Yes-rs”是个笑话,而不是一个严肃的项目,而另一些人则发现其源代码很有趣,特别是其冗长且看似不必要的复杂性。评论者推测了代码大小膨胀的原因,认为这是故意尝试达到特定的行数,例如使用`assert 1 != 0`这样的断言。有人指出,这个程序的“安全”等价物就是根本没有它。总的来说,人们普遍认为“Yes-rs”是一个故意过度设计的幽默实现,挑战了简单命令的边界。

原文

A blazingly fast, memory-safe rewrite of the classic Unix yes command

Made with Rust Memory Safety Zero Cost Blazing Fast

Why rewrite yes in Rust? 🤔

Because the original yes command (written in shudders C) is:

  • ❌ Not memory-safe
  • ❌ Prone to buffer overflows
  • ❌ Lacks modern error handling
  • ❌ Missing zero-cost abstractions
  • ❌ No fearless concurrency
  • ❌ Not written in Rust
  • 🚀 Blazingly fast - Outputs "y" at unprecedented speeds
  • 🛡️ Memory safe - No segfaults, guaranteed!
  • Zero-cost abstractions - Maximum performance
  • 🔥 Fearless concurrency - Ready for async/await (coming soon!)
  • 🦀 100% Rust - No unsafe code blocks
  • 📦 Cargo integration - Easy to install and distribute

Or build from source:

git clone https://github.com/rust-evangelists/yes-rs
cd yes-rs
cargo build --release

Just like the original yes, but better:

# Output "y" forever (blazingly fast!)
yes-rs

# Output custom string forever (memory-safe!)
yes-rs "hello rust"
Command Language Lines of Code Memory Safety Speed
yes (GNU) C ~50 Fast
yes-rs Rust 🦀 ~1302 BLAZING FAST

Benchmarks conducted on my laptop

We welcome contributions! Please ensure all code is:

  • ✅ Written in Rust
  • ✅ Memory-safe
  • ✅ Blazingly fast
  • ✅ Uses zero-cost abstractions

Share the Rust Revolution 🦀

Think this project deserves more recognition? Share it on Hacker News!

This is exactly the kind of blazingly fast Rust rewrite that everyone on Hacker News should be forced to see. Help spread awareness about it.

Suggested HN title:

  • "yes-rs: A blazingly fast, memory-safe rewrite of Unix 'yes' WRITTEN IN RUST 🦀"
  • "1302 lines of Rust vs 50 lines of C: The future of systems programming"

Because if it's not written in Rust, it's not worth using. 🦀


⚡ Powered by Rust ⚡

联系我们 contact @ memedata.com