clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
jiriknesl 2020-09-21T04:26:26.014600Z

Morning

seancorfield 2020-09-21T05:27:57.014800Z

Aye up! Mornin'

djm 2020-09-21T05:52:39.015Z

๐Ÿ‘‹

dharrigan 2020-09-21T06:21:05.015200Z

Good Morning!

yogidevbear 2020-09-21T06:50:25.015400Z

o/

mccraigmccraig 2020-09-21T07:35:36.016700Z

ยกmรฅnmรฅn!

alexlynham 2020-09-21T08:06:26.017600Z

morn

thomas 2020-09-21T09:56:54.019Z

Mogge

mccraigmccraig 2020-09-21T11:47:02.020700Z

anyone had any experiences (good or bad), with java reactive streams libs from clojure (i.e. not core.async or manifold, but rxjava or reactor) ?

2020-09-21T12:22:36.020900Z

Morn'

dominicm 2020-09-21T14:39:54.021Z

Malcolm has used these extensively.

mccraigmccraig 2020-09-21T14:58:03.021200Z

i need to decide which way to go to replace manifold streams on the jvm @malcolmsparks - RxJava seems like the easy choice, but any more nuanced opinions will be gratefully received ๐Ÿ˜ƒ

dominicm 2020-09-21T15:06:36.021500Z

There's something being integrated into the jvm I recall. And there's a 2 of something. But that's all I know.

mccraigmccraig 2020-09-21T15:10:44.021700Z

yeah, there's java 9 j.u.c.Flow but i don't know how that intersects with RxJava and reactor

Conor 2020-09-21T15:24:50.021900Z

That Flow is mainly a bunch of the interfaces for the reactive streams spec IIRC, it is intended as a sort of lingua franca type thing

Conor 2020-09-21T15:25:38.022100Z

In my (limited) experience Reactor tends to get used more than RxJava, which might just be because it's the Spring WebFlux default

malcolmsparks 2020-09-21T17:05:55.022300Z

Hi @mccraigmccraig - I've been playing with RxJava2 over the Summer. I can't say anything about Reactor, only that I think it's quite similar, and as @conor.p.farrell says they're both implementations of http://reactive-streams.org, which is a set of Java interfaces that have found their way into the JVM (Java 9), but not in much use in that form yet.

malcolmsparks 2020-09-21T17:08:16.022500Z

My reaction to RxJava2 is very positive (excuse the pun), Flowable has a huge amount of useful stuff in it, similar to manifold streams. The 'pull' model of back-pressure makes sense to me, whereby each 'subscriber' requests a number of items to be delivered.

malcolmsparks 2020-09-21T17:09:48.022800Z

I like the reactive-streams interfaces - for me, they are an ideal solution to the non-blocking back-pressured IO that we'd like for Ring 2.1

malcolmsparks 2020-09-21T17:11:25.023Z

They solve the problem of how to interoperate between different implementations on the JVM (e.g. RxJava, Reactor, Akka).

malcolmsparks 2020-09-21T17:12:49.023200Z

The reason I'm looking at this stuff is to research an alternative to aleph/manifold - the past 5 years or so has seen quite a lot of progress/consolidation in async on the JVM. The fact is that there are a lot more people able to contribute and maintain this JVM-wide stack, especially if you include the community around Vert.x.

malcolmsparks 2020-09-21T17:13:47.023400Z

The integration between Vert.x and RxJava is particularly nice. Many Vert.x concepts, such as AsyncFile, play nicely as both a publisher and subscriber (read and write).

malcolmsparks 2020-09-21T17:15:02.023600Z

I've been in two minds whether to retreat into the land of blocking streams or double down on async. I've chosen to keep going down the async rabbit hole for now, but feel that if you're going to do that, you've just got to handle back-pressure otherwise it's pointless.

malcolmsparks 2020-09-21T17:16:08.023800Z

A nice surprise was how well Vert.x does async back-pressured multipart/form-data, which as you know was a significant effort to implement in Clojure in yada, and never felt right at the 'yada' level of abstraction.

malcolmsparks 2020-09-21T17:16:44.024Z

Hope this helps - it would be nice to discuss somewhere that retains history ๐Ÿ™‚

malcolmsparks 2020-09-21T17:17:48.024200Z

My various code snippets can be found here: https://github.com/juxt/vext

malcolmsparks 2020-09-21T17:18:10.024500Z

All quite speculative at this point

mccraigmccraig 2020-09-21T18:02:15.024700Z

I'm looking for the the same reasons

mccraigmccraig 2020-09-21T18:03:42.024900Z

i think i must be misunderstanding something about the various backpressure strategies in rxjava though - none of them look like actual backpressure, i.e. slowing or stopping the producer when the consumer can't keep up

mccraigmccraig 2020-09-21T18:26:36.025100Z

ah, ok, i think i get it Subscriber.request - yes, i agree, handling backpressure is a necessity

malcolmsparks 2020-09-21T18:46:55.025300Z

I'm quite content using Java interop with RxJava - mostly the 'fluent' API makes this really nice with Clojure - no need to dig out doto and friends.

malcolmsparks 2020-09-21T18:48:11.025500Z

Yes, you're right. The request part of the Subscription is key. It says "I can take another 5", and then that will ripple down the publisher chain until it gets to the original publisher, which then calls 'onNext' 5 times.

malcolmsparks 2020-09-21T18:48:26.025700Z

(where 5 is any number)

dharrigan 2020-09-21T20:07:27.026600Z

Say you have a cond with N conditions, and for each of those conditions you want to eval some code and return a map

dharrigan 2020-09-21T20:07:32.026800Z

it feels a bit unweldy

dharrigan 2020-09-21T20:07:36.027Z

can it be done better...

dharrigan 2020-09-21T20:07:39.027200Z

(cond
      :foo (do (something blah) {:foo "a message"})
      :wibble (do (another wibble) {:amazing true})
      :else nil)

dharrigan 2020-09-21T20:09:15.027600Z

both something and another are interop stuff that do not return maps

seancorfield 2020-09-21T20:20:28.028Z

Seems reasonable to me.

seancorfield 2020-09-21T20:20:45.028400Z

I guess you could wrap them up as private functions if you wanted...?

dharrigan 2020-09-21T20:21:13.029100Z

kk ๐Ÿ™‚

dharrigan 2020-09-21T20:21:18.029400Z

sounds reasonable too ๐Ÿ™‚

seancorfield 2020-09-21T20:21:27.029600Z

(defn- something [x]
  (do-the-interop x)
  {:foo "a message"})
...
(cond :foo (something blah) ...)

dharrigan 2020-09-21T20:21:38.029800Z

yeah, perhaps a tad cleaner ๐Ÿ™‚

seancorfield 2020-09-21T20:21:57.030300Z

I guess it depends whether the map is always associated with that interop code?

dharrigan 2020-09-21T20:23:06.031Z

yes

dharrigan 2020-09-21T20:25:30.031200Z

much nicer as little functions

dharrigan 2020-09-21T20:25:31.031400Z

ta sean!