clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2021-01-12T01:10:07.115200Z

AWK is imperative though, since as you process lines, you can mutate the vars you defined in BEGIN, and then use those at the END. So not exactly like a reduce, even though you could probably do a kind of reduce

Ashwin Bhaskar 2021-01-12T09:20:49.119400Z

Where can I find a documentation of all the options and keywords that can be used in project.clj? For example I would like to know all the keywords and their uses in the :dependecies vector. For example:

[<http://my.org/mylib|my.org/mylib> "1.0.0" :scope "runtime"] ;; what does :scope do and what are the values allowed

NPException 2021-01-12T10:15:18.119600Z

I always look at this: https://github.com/technomancy/leiningen/blob/master/sample.project.clj Not sure if it covers all your needs though.

alexmiller 2021-01-12T13:19:33.120300Z

lein help sample

alexmiller 2021-01-12T13:20:17.121Z

scope is an idea from maven that says when different deps are used

alexmiller 2021-01-12T13:21:04.122200Z

In maven, the main values used are compile, run, test, and provided

alexmiller 2021-01-12T13:22:35.124400Z

It’s mostly used in lein to mark test-only deps and provided deps (needed to run but won’t be published as transitive deps - it’s the users responsibility to ensure that)

vlaaad 2021-01-12T16:15:51.124600Z

Should I distribute my library aot-compiled if I'm able to ensure that the only compiled code in the jar is from my lib and not clojure or other deps?

p-himik 2021-01-12T16:28:07.124700Z

Some discussion here: https://clojureverse.org/t/deploying-aot-compiled-libraries/2545 tl;dr: probably don't do that.

alexmiller 2021-01-12T17:46:25.125200Z

imo, no

alexmiller 2021-01-12T17:47:43.126400Z

in some narrow cases, distributing both a source and a compiled version of your library (I'm in favor of using a classifier for this) is possibly useful

👍 1
alexmiller 2021-01-12T17:48:35.127200Z

but in that case the source and compiled versions can both end up in your classpath so it's good to understand the implications of that for others

alexmiller 2021-01-12T17:56:13.128200Z

well we try hard to maintain both but we don't do anything to guarantee the latter

alexmiller 2021-01-12T17:57:35.129300Z

you have to think about both forward and backward compatibility too

alexmiller 2021-01-12T17:57:59.129700Z

a lib compiled with clojure version N may not work at runtime if you are using clojure version N-1

alexmiller 2021-01-12T17:58:28.130Z

(although I would expect it to work with clojure version N+1)

alexmiller 2021-01-12T17:59:07.130500Z

in general I think it's far safer to think about neither though and distribute source :)

🙏 2
vlaaad 2021-01-12T18:02:03.130700Z

Thanks for explanation!

alexmiller 2021-01-12T18:04:20.131400Z

and if you're after startup time improvements, I'd recommend https://clojure.org/guides/dev_startup_time as an approach to thinking about that

vlaaad 2021-01-12T18:10:12.131500Z

Yeah, I'm aware of that! I thought it might be useful to have stuff like this baked in a library like cljfx where startup time matters a lot. The thing about cljfx is that it loads namespaces dynamically to not load the whole javafx at the start, so it's not easy to compile it completely as one might try with (compile 'cljfx.api)

alexmiller 2021-01-12T18:11:04.131700Z

gotcha

2021-01-12T20:23:32.133100Z

If you can guarantee its only from your lib, it should be fine. Its not as good as source, because of the "byte-code" compatibility thing, though most likely it will be. But, I still think you shouldn't. The person making an app with cljfx, if they want their app to start faster, they can do a full AOT of their app before distribution.

2021-01-12T20:24:52.133300Z

I'd say the only thing I include compiled in a lib are gen-classes and other such thing which is meant to be consumed from Java. Since you kind of have too, otherwise a Java app cannot use your lib.

vlaaad 2021-01-12T20:26:01.133500Z

Will it this full AOT go through every ns in a dependency? The problem here is that a lot of cljfx nses are loaded dynamically, so (compile 'cljfx.api) won't be enough

nezaj 2021-01-12T22:40:44.137500Z

Hey team, lein + nrepl question (putting it here as I guess it relates to both, so am not sure if an individual channel makes sense) we are trying to set up drawbridge. When we try to connect to it, lein repl :connect <http://localhost:3010/nrepl> We get the following error:

WARNING: update already refers to: #'clojure.core/update in namespace: clj-http.client, being replaced by: #'clj-http.client/update
clojure.lang.Compiler$CompilerException: Syntax error compiling new at (drawbridge/client.clj:36:5).
#:clojure.error{:phase :compile-syntax-check, :line 36, :column 5, :source "drawbridge/client.clj", :symbol new}
 at clojure.lang.Compiler.analyzeSeq (Compiler.java:7114)  
....

Caused by: java.lang.ClassNotFoundException: clojure.tools.nrepl.transport.FnTransport
 at java.net.URLClassLoader.findClass (URLClassLoader.java:435)
    clojure.lang.DynamicClassLoader.findClass (DynamicClassLoader.java:69)
    java.lang.ClassLoader.loadClass (ClassLoader.java:589)
    clojure.lang.DynamicClassLoader.loadClass (DynamicClassLoader.java:77)
    java.lang.ClassLoader.loadClass (ClassLoader.java:522)
    java.lang.Class.forName0 (Class.java:-2) 
    java.lang.Class.forName (Class.java:427) 
Based on the FntTransport text, I intuited that perhaps there was some versioning issue. I tried down-versioning to We are using nrepl 0.6.0, and nrepl/drawbridge 0.2.1, and lein 2.9.3, but had no luck. Any help on how I could debug this further greatly appreciated

dpsutton 2021-01-12T22:42:50.138500Z

drawbridge depends on the old version of nrepl (seen from the clojure.tools.nrepl.transport namespace). From 0.3 and on nrepl moved to new coordinates nrepl rather than clojure.tools.

nezaj 2021-01-12T22:51:58.138600Z

^ Curious, it seems like in drawbridge's project.clj they use nrepl 0.6.0 see: https://github.com/nrepl/drawbridge/blob/master/project.clj#L7

dpsutton 2021-01-12T22:56:57.138900Z

i don't know. but something involved is looking for the old nrepl

dpsutton 2021-01-12T22:57:14.139100Z

you could try lein deps :tree and see if anything involved uses the old nrepl

2021-01-12T23:31:50.139300Z

It will AOT everything that is loaded when loading your namespaces

2021-01-12T23:32:55.139500Z

So like:

(if true
  (require 'a)
  (require 'b))
Will compile a, but not b.

2021-01-12T23:34:27.139800Z

So its ok to have a "dynamic load", but if the load branch is not taken when doing the AOT, then it won't be compiled.

2021-01-12T23:39:57.140Z

So ya, your scenario is a bit tricky

2021-01-12T23:40:44.140200Z

You could try to have an environment flag or a dynamic binding that if set to true will force "load" everything, if false will lazy load them "as needed" maybe.

2021-01-12T23:40:57.140400Z

So when someone does AOT, they can set it to true to force load it all and get it all compiled

2021-01-12T23:41:33.140600Z

Or, actually, I think an easy way for you to do it. Just have a namespace that all it does is require everything in cljfx

2021-01-12T23:43:19.140800Z

And then when someone AOTs, they can specify that namespace explicitly. Though.... I'm just not sure if Clojure will find your source if its inside a Jar hum..