3 ms·
I like the idea of zero-cost abstractions very much. I think that eventually, we will move to functionally proven code - which is, of course, also a zero-cost a
by kutkloon7 10y ago
I like the idea of zero-cost abstractions very much. I think that eventually, we will move to functionally proven code - which is, of course, also a zero-cost abstraction, since functional verification is normally done at compile-time.
The snippet presented is completely unreadable to me though, and I think that in general, Rust is too hard to understand (and has some syntax which seems quite arbitrary).
- Manishearth 10y ago> The snippet presented is completely unreadable to me though I suspect this is just a matter of being used to things. For me, the corresponding imperative code is harder to disentangle. Whereas, knowing what zip/map/sum do, both the intent and the behavior of the code is abundantly clear to me.
- khedoros1 10y agoI suspect that's right. I can describe what zip, map, and sum do, but I don't have an intuitive feel for what each one does or the patterns that they're usually used in because I haven't ever really done any functional programming. I've seen side-by-side imperative and functional comparisons, written in Rust. Reading through the functional version of the code always gave me a very rough idea of what was happening, and reading the imperative version was always immediately clear to me. I think that it's almost certainly a function of familiarity.
- yazaddaruvala 10y agoHave you ever learned a new spoken language? At first, the learner understands by translating to primary language. Only later, with repeated experience does the learner stop doing so and become "fluent". Its very similar when learning the functional style of programming. Even today having most of this functional style be intuitive, when I see a complex iterator chain (usually only when constructing a `Map`), I need to mentally unfold it into a loop.
- khedoros1 10y ago> Have you ever learned a new spoken language? At first, the learner understands by translating to primary language. That seems like a good analogy. I underwent that process a few years ago while teaching myself to read assembly, and in the past, other spoken languages.
- kibwen 10y agoWhich syntax seems arbitrary? I've been reading Rust since its primordial days, and I'm happy to help explain the ultimate reason behind any bit of syntax. :)