Fork me on GitHub
#beginners
<
2022-07-07
>
Ivan Koz03:07:52

Can somebody explain me the meaning of "direct and transitive calls" in core.async/>!!

Alex Miller (Clojure team)03:07:07

direct = you invoke a function transitive = functions that you invoke, invoke a function

Alex Miller (Clojure team)03:07:41

so in context, that means inside a go block you should not call >!! or a function that calls >!!

Alex Miller (Clojure team)03:07:11

if you do, it can block, and there are a small finite set of go block threads - if you block enough of them, go blocks stop working

Ivan Koz04:07:08

thank you Alex, very helpful

Gagan Gayari10:07:50

How can I run the core.logic constraints on an external database( Neo4j etc) using pldb ? Kind of querying. The database is huge and I don't want to pull the whole DB.

NickName13:07:32

Have a question about ex. 3 from here https://aphyr.com/posts/306-clojure-from-the-ground-up-state From the ex. 4 it seems like it is somehow possible to calculate those futures in parallel using reduce (in contrast to using atom). But I can't understand how we can do it. Something like this obviously does not work:

(def v [(future (sum 0 (/ 1e8 2))) (future (sum (/ 1e8 2) 1e8))])
(reduce + v)
Can somebody please point me in the right direction?

dpsutton13:07:24

Futures return a value eventually. You need to deref it to get its value

NickName13:07:02

Oh, now I got it. I was doing something like (+ @(future …) @(future …)) and wondering why it seemed like a consecutive execution with no improvement in time. Now I understand that I need to start futures simultaneously, e.g. [(future …) (future …)], and when I refer to them later they will already be executing in parallel. Thanks for clarification!

👍 1
psc14:07:07

According to Programming Clojure, 2nd Edition, What if you want to coordinate an update of both current-track and current-composer with an atom? The short answer is “You can’t.” That is the difference between refs and atoms. If you need coordinated access, use a ref. But this seems to work with any problem, what am I missing from that explanation?

(def current-track (atom "Venus, the Bringer of Peace") )
; #'user/current-track
(def current-composer (atom "Creedence Clearwater Revival") )
; #'user/current-composer
(dosync
 (reset! current-track "Ramble tamble") (reset! current-composer "CCR"))
; "CCR"
@current-composer
; "CCR"
@current-track
; "Ramble tamble"

Alex Miller (Clojure team)14:07:26

The reset! and @ there are not part of the transaction

Alex Miller (Clojure team)14:07:37

that is, the dosync is doing nothing there

Alex Miller (Clojure team)14:07:31

and a concurrent modification in a different thread could change things in between the reset! and @

psc14:07:00

That last message is what explains it best for me Thanks for the fast answer!!

Alex Miller (Clojure team)14:07:16

np... you should check out the 3rd edition of that book ;)

psc14:07:04

I actually have a physical copy of the 3rd edition 😊 and a digital of the 2nd, I’ll be sure to check this part specifically. Maybe it also explains why is it ok (transaction-wise) to group several ref-set inside a dosync, but it’s not nice to run several reset!

Nika19:07:13

I'm going through brave clojure and the https://www.braveclojure.com/basic-emacs/ points me towards http://github.com/flyingmachine/emacs-for-clojure/ which reads

WARNING this does not work currently.
A lot has changed since I last put significant effort into this repo, and as a result this emacs config is broken. 
I hope to get it working again soon (as of 2022-04-02)
I was wondering if anybody has a safe/up-to-date reference for setting up emacs for clojure.

seancorfield19:07:53

I think https://prelude.emacsredux.com/en/latest/modules/clojure/ is well-maintained and there's a #prelude channel (as well as an #emacs channel).

‼️ 1
seancorfield19:07:45

I can't recommend any setup guides as it's been many years since I used Emacs but back when I did use it, Prelude was what I settled on after many other attempts to get a good dev env up and running on Emacs 🙂

seancorfield19:07:24

(I switched to Atom and then VS Code, in case you're wondering, mostly for their ability to render arbitrary HTML UIs and therefore support visualization tooling)

seancorfield19:07:03

In general, for beginners coming to Clojure, I recommend using whatever editor/IDE you're already comfortable with if it supports Clojure.

seancorfield20:07:39

According to https://clojure.org/news/2022/06/02/state-of-clojure-2022#_working_with_clojure Emacs usage has decreased from 50% four years ago to about 40% now, IntelliJ/Cursive has held steady at 30% and VS Code has climbed from 10% to around 20%.

dpsutton20:07:18

100% agree on both counts. Prelude emacs is actually written by the author/maintainer of CIDER. A great way to go. But there is no need to learn Emacs just for Clojure. If it sounds great (I love it) go for it but Cursive has a free community version for IntelliJ and VS Code has Calva which is free and open source.

Nika20:07:36

I had no idea there were so many channels! Should I have asked this in the #emacs?

dpsutton20:07:10

we’re happy to help beginners get setup. We might direct you to other channels to get more specific help but “I’m a beginner and I have a question” is perfect for #beginners

dpsutton20:07:42

(ie, don’t read “ask in #emacs ” as saying you shouldn’t have asked here. just that they can help more)

Nika20:07:16

If emacs isn't a good idea these days, by no means will I force using it, but I've been using it here and there for almost a year and brave clojure had me thinking it would be a very nice experience to pair it with clojure. I also have VS Code with Calva (which works just fine honestly) and Cursive (my first impression wasn't too great but I'm willing to blame myself). I'll ask my original question in #emacs and then get something set up to get a little taste.

dpsutton20:07:14

roll with emacs then

Nika20:07:28

Or wait.. I almost forgot about prelude. 😆 I guess I don't need to ask.

dpsutton20:07:48

just install cider m-x package-install [enter] cider and you are good to go

Nika20:07:23

@U11BV7MTK Might you know what "The lein executable isn't on your 'exec path'" means? I have cider installed and it returns that message whenever I cider-jack-in.

dpsutton20:07:12

sure. so just like your command line has a list of places to look for executables (the PATH variable) so does emacs. Usually the easiest way to fix this is https://github.com/purcell/exec-path-from-shell which attempts to copy your system’s path into emacs exec-path

❤️ 1
dpsutton20:07:44

and there’s a #cider channel and of course #emacs for all of your questions you might have about that

dpsutton20:07:51

(and of course this assumes you have actually installed lein if you intend to use it)

Nika20:07:30

I don't know enough to know what alternative to lein there is and what benefits it has, but I do have lein installed 🙂 and it is working now!