Fork me on GitHub

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


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


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


Okay, thanks!


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


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


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.


In this case you can also use clj-kondo

👍 3

@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))))'
  "Captured at compile time, to know if we are running inside a\n  statically compiled executable with musl."])


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


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


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

Alys Brooks13:06:00

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.


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


The common approach is clojure -M foo.clj

Alys Brooks14:06:26

Yeah, looking at some early commits to Compojure, it suggests using ant to install the dependencies:

Alex Miller (Clojure team)14:06:36

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


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.


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


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

Alys Brooks02:06:51

Thank you for all the responses!

The Continium18:06:05

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 ?


question is about non-heap, not heap


check for direct buffers being allocated

☝️ 2

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


you can use visualvm or to get a count of the active threads, the stack of each counts as non-heap memory

The Continium19:06:53

Thanks for the quick replies. is being used to monitor the memory.


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


Can't claim much experience, but there's this:

Greg Reichow22:06:17

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?


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


Also, I believe Cognitect/Nubank do most of their actual support via

Greg Reichow23:06:46

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

Greg Reichow04:06:34

For any others that have this question, ended up using CloudWatch time based triggers to kickoff running the lambda every 30min instead of controlling the timing from within the application.

👍 2