3 ms·
I've had smart people complain that they couldn't figure out how to write simple programs in Haskell after days of honest effort. One problem, I believe, is th
by pklausler 11y ago
I've had smart people complain that they couldn't figure out how to write simple programs in Haskell after days of honest effort. One problem, I believe, is that functional languages encourage more of a bottom-up approach to design, whereas many C/C++ coders naturally decompose problems in a top-down manner. So math types, who are used to building up grand structures from smaller propositions, find pure FP pretty congenial because they can write smaller independent functions and attack the parts of the problem that they know how to solve.
- chenglou 11y agoIs this true? What are the major obstacles preventing you from dividing your problem top-down in a FP? Just because you're able to better divide programs bottom-up in FP doesn't mean the other way around is harder, right?
- rntz 11y agoAnecdatally, I'm a very top-down programmer, and also a discrete math & logic nerd, and I tend to prefer FP. I'm not sure why you think "math types" tend to work bottom up. Perhaps we mean different things by top-down/bottom-up? Can you give an example of what you think of as "top down" design versus "bottom up" design, and why it seems "top down" is easier in an imperative language and "bottom up" easier in a functional one?
- pklausler 11y agoBottom-up design is the creation of little stand-alone components that can be understood in isolation and, when written abstractly, perhaps useful in multiple contexts. I find that pure FP languages ease bottom-up design because of the lack of shared mutable state and their strong support for composition.
- chriswarbo 11y ago> One problem, I believe, is that functional languages encourage more of a bottom-up approach to design Anecdotally, I tend to write Haskell "top-down", e.g. writing QuickCheck tests for top-level functions, writing dummy definitions with `undefined`, and fleshing things out as and when the tests require it.
- dreamdu5t 11y agoIt's an unrealistic expectation to start programming software in a matter of days without learning any fundamentals. You can't pick up C in a couple days and write programs if you don't understand pointers, const's, etc.
- ktRolster 11y ago>whereas many C/C++ coders naturally decompose problems in a top-down manner. That's kind of weird, considering this quote from Ken Thompson, when asked how he thinks of such good abstractions: "It is the way I think. I am a very bottom-up thinker. If you give me the right kind of Tinker Toys, I can imagine the building. I can sit there and see primitives and recognize their power to build structures a half mile high, if only I had just one more to make it functionally complete."
- pklausler 11y agomany != all
- deleted 11y ago[deleted]
- dbcurtis 11y agoInterestingly, the Haskell fans that I know happen to be mathematicians by inclination, and programmers because it seems useful. I think you are right that mathematical thinking maps quite naturally onto Haskell. I also think that most programmers are only middling-good mathematicians and aren't the type that enjoys doing air-tight proofs in their spare time as a hobby.