Fork me on GitHub
#clojure
<
2020-10-04
>
dpsutton00:10:21

You’re using the file on the file system which doesn’t exist when all you have is a jar. Use http://clojure.Java.io/resource

Eamonn Sullivan00:10:37

I'm sorry, I'm really, really stupid when it comes to building things in the jvm world. Do I need to do something else (in addition to this) in the pom.xml file? Now I just get

Execution error (IllegalArgumentException) at bbc.dpub.github-pr-tool/eval138$loading (github_pr_tool.clj:1).
Cannot open <nil> as a Reader.

Eamonn Sullivan00:10:58

That's probably confusing -- I'm trying to load the library in a github-pr-tool and it just doesn't work.

Eamonn Sullivan00:10:37

Fix it. Just me working too late. Can't see straight.

jamesleonis03:10:30

I have a hard question that might not have an answer. I'm trying to build up an ns form from nothing but the surrounding REPL environment instead of Files. I can infer 90% of a given namespace's :require form from the interns and aliases. However a non-aliased namespace is giving me a headache. Consider the following ns form:

(ns some.awesome.namespace
  (:require [clojure.set :as cset]             ; This can be inferred from 'ns-alias
            [clojure.test :refer [is deftest]] ; This can be inferred from 'ns-refers and some poking
            clojure.string                     ; this is completely invisible to any known query
))
Is there a way to discover such a dependency on a naked symbol like 'clojure.string above, but without a file and/or existing 'ns form? I can see it in 'all-ns, so I know it's loaded...

andy.fingerhut04:10:09

I don't necessarily know everything Clojure stores at run time that might be used to recover that relationship, but from a few minutes of looking in the Namespace.java source file within Clojure's implementation, it isn't obvious there is anything.

andy.fingerhut04:10:06

You can look at the list of all namespaces that are currently loaded, but without aliases, I can't think of any way to know if A requires B, or B requires A, or neither requires the other.

andy.fingerhut04:10:09

Out of curiosity, why do you want to try to build up an ns form from the run-time state of a Clojure JVM process?

jamesleonis05:10:58

I'm on a lark where I build up a program purely from a REPL session. Ideally I would be able to query the REPL and output a file to "save" a session. I'm exploring more REPL-driven development ideas.

andy.fingerhut05:10:48

Note that the source code of Clojure functions is not saved anywhere when entered into a REPL, unless you write code yourself that saves the input text somewhere.

andy.fingerhut05:10:05

A straightforward technique would be to save all text entered into the REPL into a file, and then later load that file into a new Clojure JVM. That can fail in various ways, e.g. if in the original REPL session you were opening network connections, reading files from the file system (and later you tried loading that text on a different system that did not have those files), etc.

dominicm08:10:11

@U0SCZ80LS palletops ns-reload hooks load-lib to do this. Might be worth a poke.

jamesleonis21:10:18

These are all good suggestions. I'll look more into pallet. At least now I know where some limitations are, which still helps.

ido08:10:17

hey clojurians. could you explain to me this?

=> (def data (vec (map inc (range 100000))))
=> (def xf (comp (map inc)(filter even?) (map #(* 2 %))))
=> (quick-bench (->> data (map inc)(filter even?) (map #(* 2 %))))
Execution time mean : 23.365075 ns
=> (quick-bench (into [] xf data))
Execution time mean : 6.275398 ms

ido08:10:58

how come the transducer version is slower than the simple composition ->> version?

ep08:10:46

i think because the first one is only returning LazySeq and the second one evaluates all

ep08:10:02

(type (->> data (map inc) (filter even?) (map #(* 2 %))))
=> clojure.lang.LazySeq
(type (into [] xf data))
=> clojure.lang.PersistentVector

ido08:10:13

oh missing a vec at the end 🙂

ido08:10:27

(quick-bench (->> data (map inc)(filter even?) (map #(* 2 %)) vec))

Chris K08:10:43

Just found this answer on stack overflow of how I can make a gui app using clojure but I don't know how to develop using this way... can someone reference me to a resource or things I should research and learn about?

Nobody yet suggested it, so I will: Browser as UI platform. You could write your app in Clojure, including an HTTP server and then develop the UI using anything from HTML to hiccup, ClojureScript and any of the billions of JS libaries you need. If you wanted consistent browser behaviour and "desktop app look'n'feel" you could bundle chrome with your app.

This seems to be how Light Table is distributed.

p-himik09:10:19

They're talking about this: https://www.electronjs.org/

Chris K12:10:21

thanks so I can use hiccup here?

p-himik12:10:58

You can use HTML and JS there. But CLJS can be converted to JS, just like Hiccup can be converted to HTML.

p-himik12:10:20

There are projects that bring Electron closer to CLJS.

littleli12:10:52

It is not the only way. You can develop UI apps with OpenJFX. There is even a channel for it here #cljfx

Chris K12:10:04

@UBLU3FQRZ cljfx didn't work too well for me so I wanted to try out the one from this stack overflow.

Chris K12:10:31

@U2FRKM4TW Do you know any resources to get me started working?

p-himik12:10:55

Sorry, I don't.

phronmophobic16:10:39

@U012BEGBECC, what kind of GUI app are you trying to make?

zilti20:10:54

I can only second cljfx, it works really well, the only thing that's a bit cumbersome is to add support for new GUI elements from libraries

Chris K00:10:53

@U7RJTCH6J I want to try making a productivity app with stuff like timers, and way to store notes

phronmophobic00:10:43

is the app for personal use or will it be distributed to other users?

Chris K02:10:49

@U7RJTCH6J I want to try a personal one

phronmophobic02:10:50

i'm not exactly sure why cljfx wasn't a good fit, but it seems like it could work in principle. the folks in #cljfx are pretty responsive if you have questions. if you have cljs experience, an electron app is pretty straightforward. I would recommend something like https://github.com/Day8/re-frame (#re-frame for questions) as an overall framework, browser apis for timing, and then use the https://nodejs.org/docs/latest-v13.x/api/for storage.

dominicm21:10:07

Curious, is anyone aware of a java/clojure task/job queue with a dashboard available? I'm struggling, which surprises me given the java ecosystem. Maybe I'm not using the right term. I can find examples for ruby, php, nodejs quite easily.