lambdaisland

Ben Sless 2020-03-30T08:12:48.028500Z

Since twitter isn't the most conducive forum for long form discussion I'll bring it over here

Ben Sless 2020-03-30T08:13:22.029100Z

I think the coffee grinder sort of takes us back from the benefits of functional programming

Ben Sless 2020-03-30T08:14:40.030300Z

They reintroduce state. Instead of simplifying it via composition, passing around a context map is equivalent for creating an ad-hoc namespace for every incoming message and defing everything in there

Ben Sless 2020-03-30T08:14:52.030700Z

it's the most in-place procedural solution

Ben Sless 2020-03-30T08:17:24.030900Z

See Out Of The Tarpit section 5.2.3

Ben Sless 2020-03-31T07:09:39.044500Z

To quote Scott Wlaschin > We are programmers, so when we need to bang in a nail we use a hammer, and when we need to change a light bulb we use a hammer and when we need to mow the lawn we use a hammer Slightly paraphrased but you get the gist.

2020-03-31T07:24:45.044700Z

🙂

Ben Sless 2020-03-30T08:18:51.031200Z

http://curtclifton.net/papers/MoseleyMarks06a.pdf

2020-03-30T08:36:23.031400Z

Super interesting! But what would be the alternative? You mentioned: > simplifying it via composition Do you mean having encapsulated (possibly stateful) components with that? Or how could purely functional composition solve state management? In the context of the paper to me it does not exactly read like it is a bad thing to use this pattern though. It’s more about being aware of the trade-offs. It is not a solution to every problem and you might still want to have stateful components in your bigger architecture.

dominicm 2020-03-30T08:50:19.032800Z

I didn't know the tarpit referenced this. This is known as "stamp coupling" and "God object".

Ben Sless 2020-03-30T10:36:19.032900Z

In a way it's inescapable because you always need some state in your program otherwise it doesn't do anything. I think the problems begin where you do something like chain 3 functions (f g h) and f shoves in to the map some key k which only h uses afterwards. Mentally, the code becomes an elaborate game of catch, where you have to realize why some field was set up only for a function 2 (or 30) calls down the line uses. If f modifies the collection in such a way that only h will use it afterwards and that field will be subsequently ignored, f and h should be composed, and the complexity introduced disappears. It's similar to composing typed functions for A ->B with B -> C creating a new function with type A -> C. You don't need to know about the intermediate values and can use the function "as is"

Ben Sless 2020-03-30T10:38:25.033100Z

> god object Good name. Makes you consider your choices in life 🙂

2020-03-30T11:18:15.033500Z

Yes, there is definitely a cost/tradeoff with this approach. Still, I think Clojure’s dynamic typing with open map types and namespaced keys make these kind of context objects a very attractive tool 🙂

Ben Sless 2020-03-30T11:32:32.033700Z

Attractive sounds like a synonym for "easy". It won't make you code simple, though 😉

plexus 2020-03-30T12:45:08.035Z

I'm putting out a new release of lambdaisland/glogi {:mvn/version "0.0-36"}, adds a spy macro as suggested here, and fixes an issue where lambdaisland.glogi.console was always using console.log, instead of using the most appropriate method (`warn`, error, etc)

plexus 2020-03-30T12:48:06.036100Z

looks like this

(log/spy (+ 1 1)) ;;=> 2
browser console:
[your.ns] {:spy (+ 1 1), :=> 2, :line 1}

dotemacs 2020-03-30T13:16:52.037200Z

Hi, how do you start logging a certain channel from this Slack instance so that the logs are captured in clojurians-log ? I seem to remember that you have to invite the bot, but can’t dig up the bot’s name now. If I get the answer to the above, I’ll add it somewhere in the repo (I know that about page is being worked on). Thanks

dominicm 2020-03-30T13:24:42.037700Z

@dotemacs @logbot

dotemacs 2020-03-30T13:25:44.038500Z

Thanks @dominicm and is the process to start the logging just inviting the logbot into the channel?

2020-03-30T13:26:24.039100Z

conversation settings -> add an app?

dominicm 2020-03-30T13:26:25.039200Z

I think so

2020-03-30T13:26:35.039400Z

this worked for another channel, fwiw

dotemacs 2020-03-30T13:30:50.042200Z

Why I asked in the first place: because I saw that there isn’t any logs for #interceptors channel. I’ve invited the user and now I can see that the Log Bot is there. But I didn’t check under Apps of that channel before. So I’m not sure if it was my invite that got the Log Bot into the channel or was Log Bot there all along… I can’t see any logs here https://clojurians-log.clojureverse.org/interceptors , so I’m assuming that no logging was started up until just now?

dominicm 2020-03-30T13:32:13.042500Z

No logging starts until invited and then you talk

plexus 2020-03-30T14:08:11.043100Z

can confirm all of the above, just inviting @logbot should be enough

plexus 2020-03-30T14:08:26.043400Z

note that logs don't update instantly

plexus 2020-03-30T14:09:11.043800Z

the recommended channel for this kind of stuff is #community-development btw

👍 1
2020-03-30T21:59:16.044200Z

I would definitely not advocate that the whole system should be one giant map. Having well encapsulated components with their own state management is a crucial architectural building block for software. That said, I also see the value of coffee grinders like for example interceptors to solve specific problems within components. But of course one can take it too far by trying to solve all problems with the same solution :)

👍 1