Fork me on GitHub
#clojure
<
2018-11-10
>
ag00:11:45

Can someone help me with this please: (sigh... Java is so... frustrating) https://clojureverse.org/t/abstract-java-class-confusion/3153

hiredman01:11:50

is the afterNavigateTo method going to be called on a thread where *out* is bound to something so the output of the prn will end up where you can see it?

ag01:11:56

Hmmm... yeah I haven't thought about that

ag01:11:22

also am I required to implement all the methods of the abstract class?

hiredman01:11:51

depends what you mean by required, the jvm doesn't enforce it, but the java language does, so if you don't you may violate assumptions of people doing java

ag01:11:40

for that thing to work though, I don't have to, right?

ag01:11:27

So I thought about what you said about thread, and put (throw (Exception. "shit happens")) there in the function, but it doesn't seem to be called at all

hiredman01:11:11

are you wrapping the driver in an event firing webdriver, registing with the event firing webdriver, then manipulating the regular driver?

ag01:11:38

yeah... but now I'm even more confused. There's an absctract class, there's also an interface, some examples I'm googling using the class, some using interface

ag01:11:47

damn it Java

hiredman01:11:06

double check the question I asked

hiredman01:11:25

because if you are doing what I asked if you are doing, then of course it isn't working

ag01:11:14

sigh... I need more diggin'... maybe I just need to use reify with the interface

ag01:11:41

nope... that didn't

ag01:11:08

Oh... I think I got what you're saying... Trying that now

ag01:11:35

holy... okay... I just missed that thing.. so my clojure code wrapper is correct

ag01:11:47

I just needed to read Java code a little more carefully

ag01:11:26

Thank you very much @U0NCTKEV8 Really appreciate your help. I was confused because I never had to extend abstract Java class in Clojure before

ag01:11:05

and I thought it might be something wrong with my Clojure wrapper

jwhitlark03:11:36

I can't seem to find a 1.10.0-beta5 version of the linux-install script. I'm looking at the 1.9.0.xxx version, and the core of the problem is I don't know what xxx would be in http://1.10.0-beta5.xxx, assuming it's actually built somewhere. Is it only built on full release?

jwhitlark03:11:19

I can't even find the template it's built from.

andy.fingerhut03:11:18

The linux install script probably does Clojure 1.9.0 by default, but then you can run a clj command line that specifies what Clojure version you want to override 1.9.0

andy.fingerhut03:11:48

e.g. clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-beta5"}}}'

andy.fingerhut03:11:17

Alex Miller included that sample command line in his announcement to the clojure Google group for 1.10.0-beta5

jwhitlark03:11:11

hmm. but that means you've already got a clojure installed. I'm trying to build a jdk11 + clj 1.10 image.

jwhitlark03:11:51

If I have to, I'll bootstrap through that way, but I was trying to avoid it.

Alex Miller (Clojure team)03:11:21

The version of Clojure used at your repl depends only on your deps.edn files

Alex Miller (Clojure team)03:11:18

The version of Clojure used to run the program that build your classpath is bundled into clj and is always Clojure 1.9

Alex Miller (Clojure team)03:11:40

That part would run fine with 1.10 too, but 1.10 has not yet been released yet, so...

Alex Miller (Clojure team)03:11:44

This is not a thing that’s provided - if you want it, you’ll have to build it

Alex Miller (Clojure team)03:11:09

Also FYI, #tools-deps is a good place for any future questions about stuff like this

jwhitlark04:11:26

Ok, I'll ask there in the future. but just to clarify, there isn't a https://download.clojure.org/install/clojure-tools-1.10.0-beta5.xxx.tar.gz ?

andy.fingerhut05:11:19

I don't know if that URL exists, but there is a 1.10.0-beta5 JAR for Clojure on Maven central, where all Clojure versions are published: https://search.maven.org/artifact/org.clojure/clojure/1.10.0-beta5/jar

Alex Miller (Clojure team)05:11:41

no, there is no clojure tools built on any 1.10 release, because it’s unnecessary

Alex Miller (Clojure team)05:11:27

the clojure-tools-1.9.0… can be used with any version of Clojure (it just uses Clojure 1.9 internally and is of the same approximate vintage)

Alex Miller (Clojure team)05:11:35

the clojure-tools jar is an uberjar that happens to include Clojure, and lots of other stuff. it is intentionally not published on Maven because publishing uberjars on Maven is imo wrong

Alex Miller (Clojure team)05:11:29

when 1.10 goes GA, I’ll switch over to building the clojure tools with it (and defaulting to it for projects), but there is no rush for that

jwhitlark05:11:38

Ok, so it sounds like the answer for my use case is just run the usual installer, add the config file, and clj -e '(println "hello world")'

Alex Miller (Clojure team)05:11:17

just a deps.edn with {:deps {org.clojure/clojure {:mvn/version "1.10.0-beta5"}}}

Alex Miller (Clojure team)05:11:30

or inline it with clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-beta5"}}}' -e '(println "hello world")'

Alex Miller (Clojure team)05:11:36

(the classpath for the jvm is being built with Clojure 1.9, but you don’t care. you’re running Clojure 1.10 in the execution jvm)

jwhitlark05:11:40

I've been working on a book about Clojure and Kubernetes, and building up exemplary examples has been, shall we say, interesting.

jwhitlark05:11:22

haven't picked one yet.

jwhitlark05:11:39

any suggestions? I've always had a soft spot for pragmatic.

Alex Miller (Clojure team)05:11:41

well pragprog was great to work with

Alex Miller (Clojure team)05:11:02

I did a bit of work with apress long ago that was … not great

Alex Miller (Clojure team)05:11:37

although it was long enough ago that would prob not use that as relevant info

jwhitlark05:11:26

The original "The Pragmatic Programmer" got me to think of this as more than something I just stumbled into.

jwhitlark05:11:21

part of what got me on this kick was sitting down to update my clj+k8s tutorial. https://github.com/jwhitlark/clj-on-k8s-quickstart

nha11:11:42

If you are taking suggestions for the next steps, I am curious about 7. Istio example 🙂 Oh and if you have experience with the Gateway I’d be curious to hear about it too! ( https://istio.io/docs/tasks/traffic-management/ingress/#configuring-ingress-using-an-istio-gateway )

jwhitlark06:11:59

Let me see what I can do. When I was first working on this, Istio was in heavy flux, so I was waiting for it to calm down.

simple_smile 4
jwhitlark05:11:01

Also, PSA, there's work going on with docker-clojure: https://github.com/Quantisan/docker-clojure/pull/56

todo09:11:51

What is the easiest way to add Clojure (or CLJS) as a scripting language on top of a C/Rust application? People often embed Lua as a scripting language. I would like to use Clojure or CLJS as the scripting part.

dominicm09:11:49

You could embed v8 into rust. Then use cljs-in-cljs to compile provided code and run it on the v8 engine.

schmee13:11:46

spec question: I have activated instrument in my test ns and now I’m getting a bunch of Unable to construct gen errors

schmee13:11:56

however, I don’t want to generate anything, I just want to validate the args of my specced functions

schmee13:11:02

is this possible?

pithyless13:11:39

I’m testing existing libraries (e.g. onyx) against clojure 1.10.0-beta5 and seeing Call to clojure.core/ns did not conform to spec exceptions. 1. Has something in Clojure 1.10.x fundamentally changed where existing import statements won’t work? e.g. (:import [java.nio.ByteOrder]) vs (:import java.nio.ByteOrder) 2. Or, is this just a question of enforcing new best-practices by default and we can change this build-failure to a warning only via some build flag?

Alex Miller (Clojure team)14:11:29

this is wrong and has never actually had any effect: (:import [java.nio.ByteOrder])

Alex Miller (Clojure team)14:11:12

either (:import java.nio.ByteOrder) or (:import [java.nio ByteOrder]) are correct

Alex Miller (Clojure team)14:11:52

you should report anything like this to the lib maintainer so they can fix

pithyless14:11:43

fair enough, it’s actually been reported already - https://github.com/onyx-platform/onyx/issues/879

pithyless14:11:23

I actually fixed the namespaces locally, but then it failed because a transitive dependency also had similar problems.

Jakub Holý (HolyJak)16:11:13

Hi! Can you recommend any videos (Screencasts?) that exemplify REPL-driven development, to wow my colleagues? (the flapping birds talk is awesome but aged, and cljs-focused) Thank you!!!

Bobby Towers17:11:33

Den of Clojure: Build Your Own Logic Engine with Timothy Baldridge https://www.youtube.com/watch?v=y1bVJOAfhKY

❤️ 8
mike_ananev19:11:40

Hello all! Java 11 has a nice feature to eval .java files. Example command: *java HelloWorld.java will compile and execute single java file. I need to load from git a single java file and execute it from Clojure code in runtime. Any advice, how to do it?

mike_ananev19:11:22

Of course, I can run it as shell (separate process), but I need to load java clases and run them in my runtime, like clojure code.

emccue21:11:26

(cracks fingers) welp

emccue21:11:50

AFAIK clojure has no special superpowers when it comes to compiling class files, so you might have to shell out to that new command. After you have compiled class files you should be able to use import or clojure.lang.DynamicClassLoader to load them into your process

emccue21:11:35

There is an example of using the DynamicClassLoader in the docs for import Your biggest problem will probably be (mumblemumble something classpaths mumble mumble), but it should be solveable. Curious as to what you are planning to use on the fly class compiling for though

mike_ananev22:11:32

thanks for advices! they are helpful. we are building a metadata system and we need to load data transformation code from local git or nexus. so data will be transformed on the fly, based on meta data description.

newres20:11:57

Hi all! So I am trying to figure things out with the Java interop. I have an instance of a Java class on which I want to call its "add" method each time for a collection. Normally in pure clojure I would just use map and be on my way, but I need to maintain the state of the instance, to get the right result will all the elements added in. What would be the best approach here? An atom for keeping the state perhaps? If anybody got some pointers on this or an example it would be much appreciated!

didibus20:11:51

You don't need an atom. Your java object is already mutable.

didibus20:11:13

You probably just want something like:

(doseq [e coll]
  (.add myJavaObj e))

didibus20:11:04

If you prefer a map like syntax, you can also use run!

(run! #(.add myJavaObj %) coll))

didibus20:11:01

(let [javaObj (java.util.ArrayList.)]
  (run! #(.add javaObj %) [1 2 3 4]) javaObj)

=> [1 2 3 4]

ag20:11:12

Can someone show me the right way to reference a lib on a local drive from deps.edn? That's supported out of the box, right?

mfikes20:11:08

@ag you are interested in the :local/root feature

jwhitlark20:11:54

@ag Note that it only takes absolute paths.

ag20:11:08

Thank you, is it described anywhere? Sorry my google is... slow this Saturday... a lot of smoke here in SF Bay because of wildfires

ag20:11:50

Thank you Mike!

andy.fingerhut21:11:51

Wait, are you using the Internet via transmission of smoke signals, and in the SF Bay area? Yeah, you are hosed 🙂

emccue21:11:27

@ag You can always try TCP/IP over avian carriers

andy.fingerhut21:11:47

And it looks like the people working on Wi-Fi standard 802.11ac already thought of the connection between that name and "avian carriers". Of course: https://mentor.ieee.org/802.11/dcn/11/11-11-1236-00-00ac-lb178-d1-0-gen-bucket-comments.xls