clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
jasonbell 2020-10-08T07:20:49.263800Z

Morning

slipset 2020-10-08T07:26:01.264100Z

Good morning!

2020-10-08T07:50:21.264300Z

morning

ordnungswidrig 2020-10-08T08:01:17.264600Z

Hallo

raymcdermott 2020-10-08T08:11:42.265400Z

Here's twisting you a good morning

2020-10-08T08:28:24.266200Z

morning!

thomas 2020-10-08T09:20:03.266400Z

morning

plexus 2020-10-08T11:24:26.266600Z

moin moin

borkdude 2020-10-08T11:36:57.266800Z

morning

2020-10-08T12:23:52.267Z

omg, I hate the packaging in R

jasonbell 2020-10-08T13:12:28.268100Z

Been ages since I even looked at R packaging.

2020-10-08T13:48:15.268500Z

does everyone here use rich comment blocks? https://betweentwoparens.com/rich-comment-blocks

1
2020-10-08T13:48:22.268800Z

(I love them and use them loads)

jasonbell 2020-10-08T13:49:44.269700Z

I use rich comments loads though I’m fairly sure that’s down to pairing with you for so long @otfrom

javahippie 2020-10-08T13:49:51.270Z

I started using them some weeks ago. A commenter on my Twitch streams was very persistent and pushed me to it. Very thankful about that!

jasonbell 2020-10-08T13:50:38.270500Z

They are handy to have test script expressions in for the REPL.

borkdude 2020-10-08T13:57:40.271Z

yes, I do use them, typically at the end of a file. at work we prepend it with ;;;; scratch

borkdude 2020-10-08T13:57:59.271400Z

clj-kondo also lints them by default, as if they are part of your normal code

borkdude 2020-10-08T13:58:58.271800Z

Clojure footgun of the week: https://twitter.com/borkdude/status/1314191092607324160

😲 2
borkdude 2020-10-08T14:06:52.273500Z

This is one of those "where FP meets the real world" things, where you need to look under the hood to see how things are implemented. Monoids... but please check the source.

raymcdermott 2020-10-08T14:15:17.274Z

are you saying this is junk

borkdude 2020-10-08T14:15:54.274600Z

no, I'm referring to the built-in one

slipset 2020-10-08T14:17:53.275700Z

So, when you see if do you think control-flow or expression?

raymcdermott 2020-10-08T14:17:53.275800Z

it's slightly annoying that they all circle around the same f'ing name

borkdude 2020-10-08T14:18:26.276100Z

@slipset that's a trick question. the only control flow in Clojure is throwing exceptions

slipset 2020-10-08T14:18:40.276500Z

πŸ˜›

slipset 2020-10-08T14:19:43.277500Z

Ok, so the thing is that years of java-damage leads me to write code like

(if foo
  (side-effecting-fn! lol)
  (side-effecting-fn! sob))

slipset 2020-10-08T14:20:04.278100Z

rather than

(side-effecting-fn! (if (foo lol sob)))

slipset 2020-10-08T14:20:24.278700Z

In the first case I use if for control-flow, in the second I use it as an expression.

borkdude 2020-10-08T14:20:49.279300Z

Honestly, I think both are fine, in different modes of thinking. Sometimes you're writing a script or task which imperatively does things, at other times you're just building up values.

2020-10-08T14:20:57.279400Z

oh, the damage I've done to you, you poor thing

slipset 2020-10-08T14:21:56.280600Z

I find that the latter helps me move difficult code away from the sideffecting code which then makes the difficult code easier to test

1
2020-10-08T14:22:33.281200Z

yeah, almost all of my refactoring is separating side effecting code from pure

1
borkdude 2020-10-08T14:27:25.281700Z

@slipset This is what your talk on ClojureD was also about right

borkdude 2020-10-08T14:27:38.282100Z

one of several of these

slipset 2020-10-08T14:27:39.282200Z

Mostly, yes

slipset 2020-10-08T14:27:55.282500Z

I guess I didn't pick up this example specifically.

slipset 2020-10-08T14:28:35.283300Z

Speaking of which. ClojureD was so important for me, knowing how this year turned out.

borkdude 2020-10-08T14:28:47.283700Z

Likewise, I'm thankful I could be there

slipset 2020-10-08T14:29:53.284900Z

It ended up being this years only conference, and it helped me get on the defn-podcast, which I must say, the recording Saturday-night was one of the best Saturdays this year.

slipset 2020-10-08T14:30:46.285900Z

And ClojureD showed how important the community is to me, and and how valuable I think it is to meet you guys IRL.

slipset 2020-10-08T14:31:27.286200Z

I guess we're closing in on Thanksgiving πŸ™‚

borkdude 2020-10-08T14:32:09.286500Z

🍻 cheers to that

2020-10-08T14:38:04.287200Z

@borkdude thx to clj-kondo I can't look at https://clojurians.slack.com/archives/CBJ5CGE0G/p1602166804278100 w/o thinking that it should be a when

2020-10-08T14:38:29.287800Z

unless it was

(side-effecting-fn! (if foo lol sob))

2020-10-08T15:04:12.288Z

Hmmm... Hailing in Dundee

2020-10-08T16:23:26.288700Z

why would I want to use mapv rather than (into []...)?

borkdude 2020-10-08T16:24:49.289200Z

@otfrom looking at the source, mapv is implemented using (into [] (map f ...))

borkdude 2020-10-08T16:25:16.289500Z

hmm, only when using multiple colls

borkdude 2020-10-08T16:26:31.289900Z

I think it comes down to pretty much the same thing

borkdude 2020-10-08T16:27:07.290300Z

except when using mapv, you won't create that much garbage (compared to using a lazy seq as the last arg of into)

2020-10-08T16:28:02.291Z

do you get an extra lazy seq if your map transducer is doing the work of the f in your mapv?

borkdude 2020-10-08T16:28:35.291900Z

no

2020-10-08T16:28:49.292400Z

(mapv do-my-funky-think my-seq)

vs

(into []
  (map do-my-funky-think)
 my-seq)

borkdude 2020-10-08T16:29:09.292800Z

(into [] (map f) coll)
is probably the same-ish as
(mapv f coll)

2020-10-08T16:29:49.293100Z

so, just a matter of taste then?

borkdude 2020-10-08T16:30:11.293500Z

you could try to do some informal perf tests, I expect not to see a difference

2020-10-08T16:30:38.294Z

there is always my law (can I say that?) of "you are gonna need to comp in something else eventually"

2020-10-08T16:31:05.294400Z

YAGNTCINSEE

borkdude 2020-10-08T16:31:10.294700Z

you can also use eductions in that case

2020-10-08T16:31:10.294800Z

πŸ˜›

2020-10-08T16:31:34.295200Z

I admit that I struggle a bit with when to use eductions

2020-10-08T16:31:44.295500Z

I'm pretty comfortable with transduce and into

borkdude 2020-10-08T16:31:58.296100Z

eductions just couple the transformations with an input source

2020-10-08T16:32:01.296300Z

but cat, eductions and sequence are things I reach for only occastionally

borkdude 2020-10-08T16:32:05.296400Z

and you can do other xforms on top of those

borkdude 2020-10-08T16:32:29.296600Z

before realizing it into a target

2020-10-08T16:32:44.297Z

not entirely sure I follow how that would be used. Have you got an example you can point me at?

borkdude 2020-10-08T16:34:38.297400Z

(def src [1 2 3])
(def ed (eduction (map inc) src))
(def ed2 (eduction (map inc) ed))
(into [] ed2) ;; => [3 4 5]

borkdude 2020-10-08T16:35:41.297900Z

in our app we have a SqlReducible, so in the example the src would be a result set from a database

borkdude 2020-10-08T16:35:50.298200Z

we can then do some transformations on that, and then read out the result later

borkdude 2020-10-08T16:36:33.298800Z

this allows you to just pass the thing around, while not having one giant transducer

πŸ’‘ 1
2020-10-08T16:36:39.299Z

ah, I think I know a place in my code where I can use that

2020-10-08T16:36:50.299200Z

thx @borkdude!

2020-10-08T16:37:35.300Z

atm, I've got a function that returns a transducer where you pass in some early steps to do the client specific things before you get to the standard flow