beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
zackteo 2021-03-31T07:33:27.326600Z

I believe I have asked this before but couldn't seem to find it from digging up the zulip logs. May I ask what ways are there to run python scripts from Clojure (backend)? I understand I can use clojure.java.shell/sh or some java interop (?) (I recall someone might have mentioned there a new api to do so?), as well as graalvm and lib-pythonclj . I want to send quite a lot of (database) data to the python scripts, would passing the python script a large json work out alright? Would preferably like to keep it as a python script so that my friends working pick up Clojure and do interop

cschep 2021-03-31T16:30:21.329400Z

you could do something like, save the database data to a file (JSON maybe?) and then kick off a python script (from clojure or manually while testing) to read that JSON in and do whatever it needs to do

2021-03-31T16:44:52.331Z

swap! just calls compare-and-set! until it's accepted right?

ghadi 2021-03-31T16:46:40.331200Z

correct @drewverlee

đź‘Ť 1
2021-03-31T20:10:04.332Z

well, and repeating calls to your provided function each time, too.

Franco Gasperino 2021-03-31T20:12:48.332100Z

agree with cshep - use the file system as an async queue between applications.

sova-soars-the-sora 2021-03-31T21:15:28.333200Z

I know you said no lein/boot... is there another way to run a clojure program / clojure server process?

2021-03-31T22:09:04.333800Z

clojure is a java library, all you used to need is the java vm + a jar with clojure in it (plus your source), now you need a dep manager because clojure.jar no longer comes with all its deps

2021-03-31T22:09:18.334Z

that's why deps.edn / the clj cli tool came out

2021-03-31T22:10:11.334200Z

similarly clojurescript is a java library (using clojure) that outputs js

2021-03-31T22:13:41.334600Z

you can still run clojure without a dep manager, if you get a valid classpath

(ins)justin@abjection:~$ CLJCP=$(clj -Spath)
(ins)justin@abjection:~$ echo $CLJCP
src:/home/justin/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/home/justin/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/justin/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
(ins)justin@abjection:~$ java -cp $CLJCP clojure.main
Clojure 1.10.1
user=> (+ 1 1)
2

2021-03-31T22:14:36.334800Z

of course I used the package manager to get those deps into the .m2 cache

zackteo 2021-03-31T23:16:49.335600Z

Mmmm, I guess that does seem to be the best way :thinking_face: given the constraints. Just 2 questions - How should I call python from clojure - is there a better way than clojure.java.shell/sh ? Would the step of saving as a file be necessary - would sending the entire json in the call be better?

seancorfield 2021-03-31T23:20:54.335800Z

@sova When @stephen788 said “clojure clj” he meant the Clojure CLI — not Leiningen or Boot. And, yes, it is another way to “run a clojure program / clojure server process”. We use the Clojure CLI at work — with 112K lines of Clojure — we don’t use Leiningen, and we don’t use Boot. Although we did in the past (`lein` from 2011-2015, boot from 2015-2018, CLI/`deps.edn` since 2018).