3 ms·
Functional orgami is hella hard to debug. Their is a reason functional programming relies so heavily on equational reason and pure FP relies heavily on static t
by seanmcdirmid 13y ago
Functional orgami is hella hard to debug. Their is a reason functional programming relies so heavily on equational reason and pure FP relies heavily on static typing: the alternative, actually debugging programmers, is so painful that you just want to avoid that at all costs.
A loop is way easier to debug than a filter or a map, you just step through it. Who cares about code length? Haskell doesn't become a usable language until someone comes up with a decent dataflow debugger, if that's even possible.
- icebraining 13y agoA loop is way easier to debug than a filter or a map, you just step through it. Why can't you just step through the function being called by map/filter? You set a breakpoint on the function and examine the values when it is called.
- seanmcdirmid 13y agoSometimes you don't have a line to break on, sometimes the code that is actually mapping and filtering is very generic and used in lots of places, sometimes you simply lack out per context when the break occurs because of laziness. When control flow becomes more indirect, debugging becomes more difficult, and functional orgami is all about making control flow indirect to rather emphasize dataflow. Someday, someone might discover how to do good dataflow debuggers that could work well for time-intensive (read: stateful) programs, and in that case, I would be happy to indirect my control flow a lot more than I do. But no one has figured out how to really do that yet.
- loup-vaillant 13y agoHere is my guess: debuggers aren't the answer. We need to look somewhere else.
- infruset 13y agoI don't agree with this. Usually, the typing does half the debugging for you and when you have a real bug (as in, the program does something but not what you intended), you debug at the reasoning level, not at the "is there an overflow here?" level.
- loup-vaillant 13y agoSome people tend to reach for the symbolic debugger the instant their program behaves funny. I hear Haskell is at a disadvantage here, being non-strict and all. Though I wouldn't know, I never tried Haskell's symbolic debugger.
- seanmcdirmid 13y agoSome people think to program, others program to think. What kind of person you are greatly determines if you prefer programming in Python or Haskell.
- loup-vaillant 13y ago> Some people think to program, others program to think. That one needs to be framed on a wall. I'm definitely in the first camp (think to program), and have no problem with paranoid type systems, and I seldom need a debugger. Now I understand why other people do.
- seanmcdirmid 13y agoThe types have to do most of the work, because Haskell debuggers aren't that great in the face of its laziness, and making your code strict for debugging purposes can lead to some heisenbugs. The mantra "well typed programs can't go wrong" actually means "our well typed programs can't go wrong, or we are so screwed."