Rust's Macro Power vs. Python's Ease: Is Zero-Cost Abstraction Worth the Conceptual Nightmare?
Code contributors are demanding immediate structural overhauls for I/O operations, specifically insisting that functions like `get_files_in_dir` must return `Result<Vec<PathBuf>, io::Error>` instead of the softer `Option<Vec<PathBuf>>`. Additionally, developers are targeting boilerplate path manipulation, citing unnecessary `display().to_string()` calls that should be replaced by direct `&Path` usage.
The conversation fractured into deep technical weeds. One side championed Rust's low-level control, with `kornel` arguing the language forces users to grasp fundamentals by favoring `enum` over built-in nullables. The meta-programming debate raged: some lauded the macro/trait system as enabling 'zero cost abstractions' (`TehPers`, `onlinepersona`), while others pointed to the sheer complexity, comparing `println!` generation to the seamlessness of Python or Java.
The consensus is a clear directive: abandon `unwrap()`/`ok()` immediately. The community agrees error handling *must* propagate using `Result<T, E>` and the `?` operator to achieve idiomatic, robust code. The major fault line remains the language's inherent complexity—whether its meticulous compile-time safety via macros is a superpower or an unmanageable hurdle compared to other ecosystems.
Key Points
Error handling must use `Result<T, E>` propagation via `?` operator.
The core consensus demands moving away from `unwrap()`/`ok()` to make code idiomatic and robust.
File system functions must return `io::Error` instead of `Option`.
BB_C scored highly on demanding `get_files_in_dir` return `Result` to properly propagate I/O errors.
Rust's reliance on meta-programming (macros/traits) is a core strength.
Supporters point to 'zero cost abstractions' and type safety, citing macro generation as proof.
The complexity of macros makes Rust feel unnecessarily academic.
Critics point to macro overhead compared to the simpler implementations found in Python or Java.
Low-level features demand deep understanding, which is Rust's point.
kornel stated Rust emphasizes understanding low-level details by favoring `enum` over built-in nullable types.
Specific C/C++ mechanics (variadic arguments) are solved cleanly in Rust.
RavuAlHemio highlighted solving messy, historical low-level details elegantly at compile time.
Source Discussions (9)
This report was synthesized from the following Lemmy discussions, ranked by community score.