upvote
Further up he discusses that using a functional paradigm is possible, but concludes that it doesn’t feel like a practical choice because of how Zig does memory management:

> But the language quickly forces you to diverge from the functional style, mostly because you’re now dealing with allocators directly, and a genuinely pure functional approach means constantly constructing new structures. That’s either expensive in memory or expensive in the manual bookkeeping needed to avoid it.

So I don’t think he’s trying to say that it’s literally impossible. It felt more like the result of a good faith attempt to understand how Zig itself actually wants to be used, and to compare that to how he’s used to using Rust.

I actually liked that he did it. So many other comparisons want to evaluate one language against the other language’s values. But I don’t want to know how well Zig can do Rust; I want to know how well Zig accomplishes its own goals, and what those goals are.

reply
So, what you're not seeing is that even though the Rust doesn't announce mutation the implementation may be mutation anyway if that's probably faster/ cheaper.

    unsafe impl<I, U, F> InPlaceIterable for FlatMap<I, U, F> where
    I: InPlaceIterable,
    U: BoundedSize + IntoIterator,
What you're seeing is the graceful goose on the water moving forward at pace. Beneath there is frantic action to make that happen. The Rust surface was more a maintainable immutable operations, but the implementation is a frantic whirling mutation like the Zig.

In Zig you end up spending a lot of time writing How to do a thing, where in Rust you only wrote What the thing is and the machine did it. There are edge cases where Zig's explicitness wins for the best programmers, but there just aren't enough of those cases or those programmers for this to net out IMNSHO.

reply
yes people don't understand that there is often a runtime performance cost to explictness as well
reply
Or more of an opportunity cost. You are able to get to 100% performance with dedicated attention from skilled engineers. But otherwise normal gods just manage to get a bare 60% out, versus the 80% they would get in rust. (Numbers are fictional.)
reply
Monads are where flat_map came from. A monadic programming style is where flat_map is used pervasively eschewing other APIs.
reply