This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-22
Channels
- # 100-days-of-code (1)
- # adventofcode (21)
- # announcements (2)
- # beginners (44)
- # calva (1)
- # cider (2)
- # cljdoc (16)
- # cljs-dev (70)
- # cljsrn (29)
- # clojure (66)
- # clojure-austria (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-nl (3)
- # clojure-uk (127)
- # clojurescript (30)
- # core-typed (3)
- # cursive (34)
- # data-science (2)
- # datomic (16)
- # duct (17)
- # editors (1)
- # emacs (4)
- # figwheel-main (4)
- # fulcro (40)
- # hoplon (2)
- # instaparse (5)
- # kaocha (4)
- # leiningen (1)
- # luminus (4)
- # nrepl (46)
- # off-topic (5)
- # onyx (2)
- # other-languages (55)
- # parinfer (3)
- # protorepl (4)
- # re-frame (33)
- # reagent (6)
- # reitit (13)
- # ring-swagger (5)
- # shadow-cljs (26)
- # spacemacs (4)
- # sql (8)
- # testing (27)
- # tools-deps (21)
- # yada (1)
Morning
måning
If somebody could contact the management and get them to turn up the thermostat for the UK that would be ace rn
I think ownership passes to the EU in the divorce
perhaps you are sittting underneath the air conditioning outlet; everyone else is too hot
now I'm picturing jean claude junker drunkenly turning the thermostat down with a 'tut' sound
Bore da
what part of the world do you live in?
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” 🤢
Hopefully you get a cut of the winnings in return 😉
Feels fair to me
#CardsAgainstHumanity in action
only bet the houses that you can afford to lose
Morning 🙂
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
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
I never used it but always heard good things about the seesaw library to integrate with Java swing. https://github.com/daveray/seesaw
Only mentioning these two because you seem to have a "deep nested object hierarchy" to deal with
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
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
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
'exciting' place to cycle
@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
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
uh, that doesn't look like java @maleghast?
all those virtual
s and &
reference params would lead me to guess c++
I appear to have gone down the wrong rabbit hole in my haste - there is a Java implementation - ICU4J
There is a specific use-case I am finding myself interested by right now__ but I am also thinking about I18n
so are you trying to use the NumberFormatter?
@maleghast: that looks pretty straightforward from an interop perspective. The most exotic thing there are probably the multidimensional arrays for localisations
if you don’t care for the arrays just call seq
on them
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.
@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.
@peterwestmacott has just done a very good job of demystifying it for me, so I think I know what I need to for now… 😉
some maybe helpful snippets:
(ns foo.bar
(:import [com.ibm.icu.text RuleBasedNumberFormat]))
;; creation probably something like
(RuleBasedNumberFormat. RuleBasedNumberFormat/SPELLOUT)
(btw I have no idea what that class does… haven’t read any of the text docs)
Thanks very much @rickmoynihan
@rickmoynihan @peterwestmacott - Thanks both very much - nailed it.
easy in the end then?
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
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.
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.
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.
@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.
@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… 😞
@maleghast I can show you at ClojureX
Sounds good - thx @jasonbell 🙂
@jasonbell do you mean copying the whole library source into java-src
or putting a thin wrapper of your own in there?
yeah that’s what I meant above.
I don’t want to spend three days trying to figure something out when I can spend two hours shivving it instead 🙂
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.
@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. 🙂
ditto
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.
basically you have enough options to manage it sanely.
Agreed. Never had any really big issues. Lein has done most things I needed it to without any fuss at all.
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.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 #())
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.
(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 )
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
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
Now that I think about it more, we probably don’t have any Java interop in there, just in lib-kafka
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
A question for everyone - who would you like to see as a keynote at ClojureX 2019. Please add suggestions as a thread.
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.
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)
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.
Good idea Renzo.