2 ms·
> 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 cod
by 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.