I'm at the point of being bothered that so many languages don't default to pure functions with required indication for impure. Like, why make me think about whether I'm writing an actual function or not?
Conversation
And maybe basic logging should count as introspection rather than an actual side effect, so maybe can call it pure? If so, logging is more fundamental than printing to stdout, which is user interface.
2
3
Replying to
I guess it might be tricky to have a general rule for this (lots of types of applications with different needs), but I thought this was an interesting perspective:
Quote Tweet
Replying to @alpha_convert
Not sure about modules, but one thing I've found is that most modules in most projects shouldn't be logging at all.
Logging makes sense in the parts of the code that actually do stuff (IO) and have the full context. The pure logic parts of the code shouldn't know about logging.
Effects and handlers (like in Koka, Effekt, Frank, Unison) also allow you to 'intercept' effectful operations with effect handlers, potentially letting you add new effects, which could be helpful for adding logging separate to application logic?
1
1
1
I do think adding 'printf debugging' should be ok (in development) however, similar to this train of thought by Jon Sterling, in this case about how it should be possible to break abstraction boundaries for debugging purposes: twitter.com/jonmsterling/s
This Tweet is unavailable.
2
Replying to
I like to think of logging from an aspect oriented perspective. Turning on tracing or putting in breakpoints, for example. A log call can be viewed like a hook for an AOP injection but with formatting details sometimes. In case simple tracing isn't enough. Just rough thoughts.
1
Yeah, I'm not sure the relationship between AOP and effects and handlers, but I feel like there might be _some_ relationship there? Like, you could yield a logging effect where necessary, and then those can be handled in a centralised place, elsewhere.
Quote Tweet
Replying to @brendanzab and @contextfreeinfo
Effects and handlers (like in Koka, Effekt, Frank, Unison) also allow you to 'intercept' effectful operations with effect handlers, potentially letting you add new effects, which could be helpful for adding logging separate to application logic?
1


