Fork me on GitHub
#clojure-uk
<
2018-11-22
>
alexlynham08:11:41

If somebody could contact the management and get them to turn up the thermostat for the UK that would be ace rn

😆 12
agile_geek08:11:45

I think ownership passes to the EU in the divorce

Ben Hammond09:11:14

perhaps you are sittting underneath the air conditioning outlet; everyone else is too hot

alexlynham10:11:44

now I'm picturing jean claude junker drunkenly turning the thermostat down with a 'tut' sound

😀 4
3Jane08:11:00

...and companionable morning shivers to you as well!

benedek09:11:51

morning. re otform a cpl days ago: just got off my bike. wasn't that bad actually

Ben Hammond09:11:00

what part of the world do you live in?

jasonbell09:11:26

Well I got a strange not-sure-if-its-100%-true feedback from my Strictly blog post. Twas a comment on FB, “I’ve just bet my house on this.” Then a DM from a friend, “Chances are he’s bet the value, he’s the director of Aston Martin” 🤢

yogidevbear11:11:27

Hopefully you get a cut of the winnings in return 😉

yogidevbear11:11:40

Feels fair to me

jasonbell11:11:50

Doubt it highly 🙂

yogidevbear11:11:59

#CardsAgainstHumanity in action

jasonbell09:11:44

So glad I put that disclaimer in now.

Ben Hammond09:11:33

only bet the houses that you can afford to lose

thomas09:11:13

that is what I always do.

jasonbell09:11:36

Monopoly houses don’t count @thomas

thomas09:11:05

but those are the only houses I own!!!

thomas09:11:19

and the utilities as well.. I like those!

maleghast11:11:14

Morning All 🙂

👋 4
maleghast11:11:15

Anyone got a good recommendation for a primer on Java Interop with existing libraries..? I am not well versed in the Java ecosystem / toolchain but I want to figure out how to reference / depend on a library I've found and figure out how to use the bit I am interested in which is reasonably deep inside the object hierarchy

fmjrey11:11:03

clojure 1.10 is supposed to come out with a new datafy library that may help. Maybe more info will be given at the conj later this month. https://clojure.github.io/clojure/branch-master/clojure.datafy-api.html

fmjrey11:11:55

I never used it but always heard good things about the seesaw library to integrate with Java swing. https://github.com/daveray/seesaw

fmjrey11:11:22

Only mentioning these two because you seem to have a "deep nested object hierarchy" to deal with

maleghast11:11:00

Thanks - I will have a look…

Rachel Westmacott11:11:15

well ideally you’d only be using bits from the API layer of the library, if you’re rummaging in the internals then that might not end well

Rachel Westmacott11:11:24

actual syntactic level Java interop is pretty straightforward (unless you want Java 8 lambdas or varargs method invocations) probably start here: https://clojure.org/reference/java_interop

mccraigmccraig11:11:12

are you just wanting to pull some data out from an object hierarchy @maleghast ? you can go a long way by hiding the java objects in a record or deftype and accessing with a protocol and a sensible clojurey api - converting to/from clojure structures to java structures in the protocol impl as required

Ben Hammond11:11:02

'exciting' place to cycle

maleghast11:11:45

@peterwestmacott @mccraigmccraig - I may be explaining badly (due to extreme Java ignorance) I want to be able to import the right bit of the library to use the following bits: http://icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html

maleghast11:11:21

There seems__ to my Java ignorant eye to be a lot of OO hierarchy “above” the bit I want, but I may be misunderstanding what I am seeing

mccraigmccraig11:11:33

uh, that doesn't look like java @maleghast?

jasonbell11:11:19

Main page says C++/C

mccraigmccraig11:11:53

all those virtuals and & reference params would lead me to guess c++

3Jane11:11:55

yeah, the include kinda gives it away

jasonbell11:11:01

#include <rbnf.h>

maleghast11:11:33

I appear to have gone down the wrong rabbit hole in my haste - there is a Java implementation - ICU4J

3Jane11:11:20

ah 🙂 is that for internationalisation?

maleghast11:11:27

Amongst other things…

maleghast11:11:31

But mostly, aye

maleghast11:11:56

There is a specific use-case I am finding myself interested by right now__ but I am also thinking about I18n

Rachel Westmacott11:11:51

so are you trying to use the NumberFormatter?

maleghast11:11:56

Sorry, this one

maleghast11:11:04

a subclass of NumberFormatter

rickmoynihan12:11:18

@maleghast: that looks pretty straightforward from an interop perspective. The most exotic thing there are probably the multidimensional arrays for localisations

rickmoynihan12:11:13

if you don’t care for the arrays just call seq on them

maleghast12:11:56

Yeah, that’s reassuring, thanks 🙂 Having next to no Java experience (and all of it being over 15 years old) I just don’t know my way around the Java ecosystem, so I get a bit “deer in the headlights” about how to interop and what I need etc.

benedek12:11:22

@ben.hammond haha i was "trained" for city cycling in Budapest in the 90s and early 2000s. some drivers were explicitly hostile. ldn is an easy ride so far, touch wood.

maleghast12:11:27

@peterwestmacott has just done a very good job of demystifying it for me, so I think I know what I need to for now… 😉

rickmoynihan12:11:05

some maybe helpful snippets:

(ns foo.bar 
  (:import [com.ibm.icu.text RuleBasedNumberFormat]))

;; creation probably something like

(RuleBasedNumberFormat. RuleBasedNumberFormat/SPELLOUT)

rickmoynihan12:11:23

(btw I have no idea what that class does… haven’t read any of the text docs)

maleghast12:11:55

@rickmoynihan @peterwestmacott - Thanks both very much - nailed it.

rickmoynihan12:11:14

easy in the end then?

maleghast12:11:51

Yeah. Your help and Peter’s basically demystified the “what’s the magical incantation” aspect of my Java-n00b paralysis and then it was easy-peasy. Thanks very much indeed

rickmoynihan12:11:51

Great… I can appreciate its a bit daunting if you’ve not done java, but there wasn’t much in that class that was exotic in terms of interop… main things were the multi-dim arrays (but you may not need to use those), the class level constants, and probably the difference between string and StringBuffer… FYI str on a StringBuffer will convert it back into a string.

rickmoynihan12:11:38

more difficult things to interop with are java 8 lambdas, java vararg methods, and libraries that require you to subclass existing classes. Most of those are also perfectly doable too… just require a bit of boilerplate… the problem comes when you have to do a lot of the more exotic interop; in which case you might just be better doing it in java; and presenting a cleaner java interface for the clojure code.

rickmoynihan12:11:44

Anyway I’ve done a lot of quite complex interop over the years; and I think there’s only once when I bothered myself to write 408 lines of java.

rickmoynihan12:11:33

though IIRC the IDE wrote about 350 of those for me

👍 12
😁 4
jasonbell13:11:09

@maleghast I always look at the Clojure library for anything first, if I see it’s just wrapping a lot of Java code then I’ll make the decision to just interop the part I need. If it’s a convoluted API (naming no names Google Analytics and Google Search Console) I’m happy to shiv the whole thing in to the project in a java-src folder and call it from Clojure.

maleghast13:11:49

@jasonbell - The first bit of what you just said definitely makes sense and I did have a more than brief look around for a complete Clojure implementation / wrap-up of ICU4J, but I couldn’t find one… The second bit of what you said there has plunged me back into n00b-space / imposter syndrome territory as I wonder what the hell what you are saying would actually entail… 😞

maleghast13:11:29

Must go hunt lunch…

jasonbell13:11:50

@maleghast I can show you at ClojureX

jasonbell13:11:59

it’s easier to explain that way

maleghast13:11:11

Sounds good - thx @jasonbell 🙂

rickmoynihan13:11:49

@jasonbell do you mean copying the whole library source into java-src or putting a thin wrapper of your own in there?

jasonbell13:11:12

usually putting a thin wrapper of my own in there

jasonbell13:11:25

Depends on the project, time, budget etc

rickmoynihan13:11:37

yeah that’s what I meant above.

jasonbell13:11:49

I don’t want to spend three days trying to figure something out when I can spend two hours shivving it instead 🙂

rickmoynihan13:11:33

Agreed. lein is remarkably good at building java code too… the only disadvantage with that approach is that to write that java you can often end up forgoing java IDE tooling… which is fine if its a few lines, but if its bigger your IDE may want its own project files etc… though you can to some extent mitigate those issues by creating a pom.xml from lein and pointing the IDE at that.

jasonbell13:11:11

@rickmoynihan Oh if it’s all going to hell then I’ll crack open an IDE and do the Java bits first, then copy the source and the maven repo locations. 🙂

jasonbell13:11:28

Though I’ve seen myself to that less and less now.

rickmoynihan13:11:39

eitherway I think the tools actually work quite well here… i.e. you can make do with less tools when its small… and when its a bigger (going to hell) you can scale up - but take on the extra cross project pain.

rickmoynihan13:11:46

basically you have enough options to manage it sanely.

jasonbell13:11:31

Agreed. Never had any really big issues. Lein has done most things I needed it to without any fuss at all.

danm15:11:26

We've got a number of shims wrapping Java stuff for ease of use

danm15:11:35

Mostly Kafka and AWS SDKs

otfrom18:11:42

I caught myself using as-> where I would have previously used a partial today

rickmoynihan00:11:20

I often write this sort of thing like this:

(-> (->> (zipmap allowed-settings (repeat (/ 1.0 (count allowed-settings))))
                  (merge-with + (get observations-per-ay ay)))
             (dissoc setting))
Though stuart sierra recons you shouldn’t mix -> and ->> I personally think it’s ok if it’s done on the first param… i.e. not in the middle. Which I think avoids most of the issues, and reads linearly… however I know some people would say just use a let; which is to some degree hard to argue with.

otfrom08:11:07

that works too. I think I quite like the as-> for this still. I'm not sure it is any worse than any other way (creating an anonymous fn, a partial, or #())

rickmoynihan11:11:41

yeah i think it’s pretty subjective. I certainly think as-> is better than partial or the (#(,,,) ,,,) trick. I normally struggle to read as-> code because the param jumps about — however your case is so small that I didn’t have the issue. I think my preference for (-> (->> ,,,) ,,,) is just that I’m so used to that idiom. I think the real benefit of let in these situations is that it’s completely uncontentious — if the code was written as a let we’d never have these discussions; even if the alternatives are marginally better to our eyes.

otfrom18:11:05

(it is always a bit scary that everyone can see into the guts of what we do every day in the sausage factory https://github.com/MastodonC/witan.send/pull/114/files )

maleghast18:11:19

@carr0t - You don't use Amazonica?

maleghast18:11:35

(For AWS SDKs I mean)

danm18:11:21

We do. We wrap it to provide nice core/shell, compositional structures etc for the bits we want to use, so that people don’t have to know the internals of a dynamodb request to build one, for example. Or the response to get the objects from it. And we do lazy sequences under the hood where pagination is required, so our apps don’t have to worry about it etc etc

danm18:11:08

But Amazonica is big. Really we should just pull in the bits we need, but we pull in the whole thing in our dynamo lib, which is far more than we actually want

danm18:11:47

Now that I think about it more, we probably don’t have any Java interop in there, just in lib-kafka

jasonbell18:11:16

Having the Kafka required bits in shims makes sense

danm18:11:37

Amazonica is black magic though. It seems to auto generate everything. I wonder how fast it’ll be able to support the 2.0 SDK

jasonbell19:11:54

The most of Amazonica I use is mainly for S3 things.

practicalli-johnny19:11:55

A question for everyone - who would you like to see as a keynote at ClojureX 2019. Please add suggestions as a thread.

practicalli-johnny19:11:17

Bruce Hauman, author of figwheel, figwheel.main, rebel readline, etc

1️⃣ 4
dominicm21:11:45

Rich Hickey ? 😁

1️⃣ 8
jasonbell09:11:02

As long as no one says, “Jase Bell, I’ve got all these rotten eggs to use up” then I’m cool with whoever it is.

reborg09:11:11

Whoever you ask you’ll be lucky to have them ready in 10 days! Try Ron Pressler (@pressron on formal verification and nature of abstraction), Tommy Hall (@U052CUT2Y, any of his math-related stuff are interesting and entertaining), Tomas Petricek (@tomaspetricek nice talks about the origin of mathematic and reasoning)

Richard09:11:41

Carin Meier

reborg09:11:46

Oh wait, are you asking 2019?!

practicalli-johnny09:11:09

We will ask Rich Hickey of course. I am assuming Stuart Halloway would be more likely. Stuart has been doing quite a few talks recently and I have found them all as inspiring as the amazing talks by Rich.

reborg09:11:49

Also ask the question to the audience during the panel at ClojureX

thomas10:11:49

I was thinking about suggesting a certain Jase Bell...