This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-01
Channels
- # 100-days-of-code (2)
- # beginners (83)
- # calva (3)
- # cider (98)
- # clara (3)
- # clj-kondo (2)
- # clojure (84)
- # clojure-dev (59)
- # clojure-europe (11)
- # clojure-italy (22)
- # clojure-madison (4)
- # clojure-nl (3)
- # clojure-spec (24)
- # clojure-uk (80)
- # clojurescript (33)
- # clr (3)
- # datomic (59)
- # events (2)
- # fulcro (20)
- # interop (35)
- # jobs (6)
- # jobs-rus (1)
- # joker (3)
- # kaocha (2)
- # luminus (3)
- # off-topic (16)
- # other-languages (2)
- # pathom (17)
- # planck (2)
- # reagent (1)
- # shadow-cljs (1)
- # test-check (1)
- # tools-deps (49)
- # vim (16)
morning all!
måning
I'm having an interop issue. Something that is a oneliner in Kotlin, doesn't work in Clojure, getting an IllegalAccessError in Clojure 😞
A protobuf object that I call toByteArray
on, i.e., message.toByteArray()
. Works perfectly in Kotlin. The same in clojure (.toByteArray message)
throws me an IllegalAccessException (JVMs in both cases is OpenJDK 12) and I'm on Clojure 1.10.1), here's what clojure is telling me...
Execution error (IllegalAccessError) at com.foo.Foo$Bar/getSerializedSize (Bar.java:7881).
class com.foo.Foo$Bar tried to access private field com.google.protobuf.AbstractMessage.memoizedSize (com.foo.Foo$Bar and com.google.protobuf.AbstractMessage are in unnamed module of loader 'app')
I'm even considering just writing a tiny kotlin/java library/jar that does that for me, but I thought that clojure/java interop would come to my rescue 🙂
and I would hazard a guess that if I did the same in plain old java, it would be the same, after all, .toByteArray is a valid, legal method on the protobuf object, not hidden.
morning
@dharrigan at a guess, clojure is attempting to reflectively access the field, and kotlin is linking - there are some JVM bugs around reflective access not implementing precisely the same access semantics as linking. i have encountered similar before, and the only solutions were either [a] a compiled proxy or [b] dynamically removing the access restriction if your security manager permits it
@mccraigmccraig that's very useful information! thank you 🙂
I have done this as well (set! *warn-on-reflection* true)
and not seeing any warnings
dunno @dharrigan, it's been a while
i was just looking for the issue in the 3rd party java library where i encountered the problem, but i can't even remember which lib it was in ...
There are days @dharrigan than the ease of writing some Java to do all the nasty stuff you’re trying to interop and shimming in you Clojure code just wins.
All depends on the assumption that others will be able to maintain it all going forward.
(also... I know Google has a huge reputation, but has there been anything Googley that is not a pain / works well released recently?)
Let me think: BigQuery Java API, an utter pain….. GoogleAds Java API, an utter pain….. nope can’t think of anything else.
the biggest upside with golang imo is that there is only one way of doing things generally, and golang doesnt give you very much rope to hang yourself with
@jasonbell Yes, I think so to. Clojure interop gets you there most of the time, but sometimes, a bit of java/kotlin to ease things isn't bad
I'm doing protobuf stuff and man, the sooner we move to a more reasonable dataformat the better
what is the problem with Protobuf @dharrigan (sorry if I missed this earlier on) and what you prefer instead?
@lady3janepl GKE is very nice (mostly)
Internally, we're discussing using other formats such as messagepack, cap'n proto (by the original other of protobu (https://capnproto.org/)), CBOR (since we deal with IoT devices and it's RFC spec'ed), Flatbuffers etc..
We find protobuf a bit clunky for our needs and other formats can encode more efficiently thesedays
We're also still consdiering doing everything (internally) as JSON, since it's ubiquitous.
Morning 🙂 New Clojure In article with the team at AppsFlyer is finally live. I hope you enjoy reading. Please share some retweet love if you can ❤️ https://twitter.com/yogidevbear/status/1145647419989925888
for those with a passing interest, @alexmiller helped me solve my problem with the interop with protobuf
> I had a rogue import of a protobuf library all the way from rebel readline which included the cljs libraries which included the closure compiler which included a version of protobuf that I am not using!
:rebel {:extra-deps {com.bhauman/rebel-readline {:mvn/version "RELEASE" :exclusions [org.clojure/google-closure-library
rewrite-cljs/rewrite-cljs]}}
always painful!
I'm outputting things to charts, csv, and excel files atm. For each thing I need to do some manipulation to get the data into the right shape
for excel and csv, the shapes are the same. It is a vector of vectors where the first vector is the header
for the charts it varies a lot more, there are different ways of pivoting the data to create grouped or stacked bar charts. I'm moving on to some multi line charts and heatmaps soon that will have even yet more shapes.
I've been struggling quite a bit with good names (and looking at some d3 examples where things like x0 and x1 are used for domain and subdomains on charts, I can see that even Mike Bostock is too)
as compact and icky as x0
and x1
are, they kind of are in the natural language of the domain if you are trying to talk about a chart...
interesting. I've been looking at d3, grammar of graphics, and pivot tables to try to get some of the language and haven't been that happy, but x0 (for the main labelled x axis grouping) and x1 for the grouping on top of each x0 label is the way to go?
I guess so - if you're plotting data on a 2D chart, then you have an x-axis and a y-axis
On a given axis, you plot the variable which corresponds to that axis. The most general name you can give that is x
/ y
respectively. If you want to plot more than one variable you introduce numerical count.
Perhaps you could try horizontal-variable
or horizontal-var
but if you are expecting the reader of the code to be familiar with charts, and the local context of the code corresponds to axes/charts then x0
x1
etc probably is the most natural choice
It would be useful to describe the shape of the argument data and return data in a doc string. This would help others and of course future Bruce 😁
Your so evil Bruce when not hugging people 😂
anyone got any good ways of thinking about these output, but not domain specific manipulations?
sometimes I can fake it by doing anonymous functions, but some of these I want to re-use or are too big to go in as an anon-fn
if you are at all interested in the concrete detail you can see it in a public repo here: https://github.com/MastodonC/witan.send.ingest