clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
tengstrand 2021-06-22T05:07:31.321100Z

What’s the best way of reading a Clojure source code file (.clj) from disk so that you also get the metadata back?

dpsutton 2021-06-22T05:14:14.322Z

i think i know what you're talking about. have it on the classpath and require it. this lets source, doc, and line numbers work correctly. if it just sends all the forms through the repl you won't have all those goodies

seancorfield 2021-06-22T06:18:27.322600Z

Yeah, you pretty much have to execute it (`require`) so that the Vars get all the correctly computed metadata…

tengstrand 2021-06-22T07:26:41.322800Z

Okay, thanks!

borkdude 2021-06-22T09:35:14.323200Z

@tengstrand if you're not interested in evaluated metadata, then you could just use the reader and no eval

borkdude 2021-06-22T09:36:37.323300Z

if you're interested in preserving more information, you could also look at rewrite-clj

tengstrand 2021-06-22T09:38:53.323500Z

Okay, thanks for the tip! I need to read an external .clj file and get metadata, like clojure doc strings, back. I guess that library will solve that. I will have a look.

borkdude 2021-06-22T09:40:59.323700Z

In this case you can also use clj-kondo

👍 1
borkdude 2021-06-22T09:48:18.324100Z

@tengstrand Example:

$ clojure -M:clj-kondo/dev --lint src/babashka/main.clj --config '{:output {:format :edn :analysis true}}' > /tmp/analysis.edn
$ cat /tmp/analysis.edn | jet --pretty --func '(fn [json] (->> json :analysis :var-definitions (filter :doc) (map (juxt :ns :name :doc))))'
([babashka.main
  musl?
  "Captured at compile time, to know if we are running inside a\n  statically compiled executable with musl."])

borkdude 2021-06-22T09:48:39.324300Z

(so here it finds only one var with a docstring in the babashka/main.clj file)

borkdude 2021-06-22T09:48:55.324500Z

if you have any questions about how to use this, let me know

tengstrand 2021-06-22T09:49:26.324800Z

Sure, will have a look at it later. Thanks.

Alys Brooks 2021-06-22T13:55:00.330300Z

I'm writing a blog post that touches on how tools like the Clojure CLI and leiningen work and have been looking at some early Clojure documentation to figure out what people did before those tools existed. It looks like you could run a script using java -cp clojure.jar clojure.lang.Script script.clj (this is officially deprecated, but still works as of Clojure 1.10.2). Was this the common approach? I assume people also started applications from the REPL? Leiningen and the first stable release of Clojure came out the same year (2009), so my guess is that people weren't using many dependencies pre-Leiningen.

lukasz 2021-06-22T13:58:05.330400Z

I remember using ant back in.... 2010 or 2011? I believe that was the "official" way of managing a clojure project, but how you obtained the dependencies was up to you - mostly by downloading jars and figuring out the classpath

borkdude 2021-06-22T14:03:26.330600Z

The common approach is clojure -M foo.clj

Alys Brooks 2021-06-22T14:03:26.330800Z

Yeah, looking at some early commits to Compojure, it suggests using ant to install the dependencies: https://github.com/weavejester/compojure/tree/0.3

alexmiller 2021-06-22T14:05:36.331Z

I used (and all the contrib libs still use) the clojure-maven-plugin with Maven

Ed 2021-06-22T16:53:10.332Z

I used maven as a build tool / test runner, swank to connect to a repl and some custom shell scripts for some more specialised jobs. It worked great for years, and I didn't actually migrate to lein till something like 2015. I was working at a startup and switching build tools just never got to the top of our priority list. But I came from a java background and was already comfortable with mvn.

Ed 2021-06-22T16:54:22.332200Z

We would generally aot the things we wanted to run, and java -jar path-to-uber.jar

2021-06-22T17:41:44.332500Z

I used a Makefile, but I don't entirely recall the details

2021-06-22T18:35:05.336Z

Hi - I have a long running Clojure process running on JVM Java 1.8 and the non heap memory is growing linearly. Has anyone any experience of this and/or methods of finding the culprit ?

ghadi 2021-06-22T18:39:31.336300Z

question is about non-heap, not heap

ghadi 2021-06-22T18:39:54.336500Z

check for direct buffers being allocated

☝️ 1
ghadi 2021-06-22T18:40:07.336800Z

also, how are you determining that non-heap is growing?

2021-06-22T18:44:42.337200Z

you can use visualvm or https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#getAllStackTraces() to get a count of the active threads, the stack of each counts as non-heap memory

2021-06-22T19:44:53.337500Z

Thanks for the quick replies. https://metrics-clojure.readthedocs.io/en/latest/jvm.html is being used to monitor the memory.

Evgeniy 2021-06-22T20:42:11.337900Z

Does anyone here have some experience integrating Okta into a Clojure web-app? Did you use any libraries or wrote your own stuff?

Greg Reichow 2021-06-22T22:07:17.338300Z

Working to deploy our first Datomic Ion based application. It is a continuously running process that ingests information, processes, and stores in Datomic. My understanding is that ion's are typically called via AWS Lambda's on some event. Yet in this case I just want to deploy the application and have it start running (and stay running). (ie. call the run function which runs and sleeps on a 30 min cycle). Tips on the best way to achieve this? Do I need to make a Lambda initial trigger or is there a way to have it launch and run automatically / continuously?

✅ 1
walterl 2021-06-22T22:34:10.338500Z

Can't claim much experience, but there's this: https://github.com/metabase/saml20-clj

seancorfield 2021-06-22T23:13:58.338900Z

@gdr3941 If you haven’t already, you might have more chance of an answer in either #datomic or #ions-aws I suspect

seancorfield 2021-06-22T23:14:38.339100Z

Also, I believe Cognitect/Nubank do most of their actual support via https://forum.datomic.com/

Greg Reichow 2021-06-22T23:49:46.339500Z

Great, thanks for the suggestion! I missed finding those channels when I searched earlier.