Fork me on GitHub
#beginners
<
2022-03-12
>
Siddarth Kumar07:03:47

When you’re new to clojure and you have a background in Javascript,PHP and Java, what is the best resource or path to start thinking in clojure? I would prefer video based resources thanks 😁

pez09:03:28

If you also are an interactive learner, you can try my Getting Started with Clojure guide which runs in the editor and lets you experiment directly using the REPL. I’ve put a few links to various videos in there as well, in the context I think they apply the most. https://calva.io/get-started-with-clojure/

💪 3
Cora (she/her)03:03:57

Getting Clojure is amazing for adjusting to think about Clojure and how to use it

leifericf11:03:37

Here's another fantastic talk that's worth checking out: https://youtu.be/Tb823aqgX_0

Siddarth Kumar07:03:39

someone recommended this book : https://www.braveclojure.com/ but I am more of a visual learner and I learn quicker with videos

adi10:03:03

@siddarthkay I love Tim Baldridge's video series. Clojure masterclasses: https://tbaldridge.pivotshare.com/

👍 1
adi10:03:28

You may also like Eric Normand's https://purelyfunctional.tv/

❤️ 1
adi10:03:15

Additionally, I would recommend material you can work with hands-on, like @U0ETXRFEW recommended https://clojurians.slack.com/archives/C053AK3F9/p1647077848713049?thread_ts=1647070007.031119&amp;cid=C053AK3F9. The extremely fluid conversational development workflow a-la Lisps, Smalltalks, APLs is one of the hardest things to teach about these languages. You got to see someone do it, but then fool around on your own to wire it into your brain.

adi10:03:10

I will also plug the https://github.com/adityaathalye/clojure-by-example we teach at IN/Clojure. It is aimed at people from other programming backgrounds. Each "chapter" progressively builds on the previous ones, with in-line examples, and end-notes suggesting 4clojure exercises to reinforce the "chapter" concepts. The thing converges into a standalone app to process some planetary data :) It should take about a day to work through, and will get you from zero to hobby-level understanding.

👀 1
dgb2312:03:14

An important lesson is to observe a Clojure programmer using a REPL workflow. Here for example: https://youtu.be/gIoadGfm5T8

dgb2312:03:11

In JS/PHP you also have fast feedback loops with JS hot reloading and the way PHP is executed. But this is like a different more interactive level on top.

practicalli-johnny14:03:57

@siddarthkay there are many community resources at https://clojure.org/community/resources including video resources My humble http://practical.li YouTube channel has many videos, although not specific to any particular developer background

👀 1
popeye16:03:53

I am building an application wit rabbit MQ from scratch , I am making use of https://github.com/michaelklishin/langohr for it, But I am confused how to build application using dependency injection using integrant , I never build a system like it ( dependency injection ) Can anyone give me reference please? or git link to refer - (May be I am asking architect question) But your help is appreciated 🙂

Ben Sless16:03:02

You can refer to this example with Component https://github.com/seancorfield/usermanager-example Or this one with Integrant https://github.com/PrestanceDesign/usermanager-reitit-integrant-example TL;DR: anything with state -> turn into an argument -> state which is injected later

popeye16:03:33

@UK0810AQ2, Thanks for your response - Will read it

Drew Verlee20:03:06

i would ask in #integrant also watch https://www.youtube.com/watch?v=tiWTpp_DPIQ&amp;feature=youtu.be and then https://www.youtube.com/watch?v=lvuwxzONXbQ&amp;t=3430s the next day. Then realize what these solutions are offering a common abstraction around systems/processes that have actual physical lifecycles : they start, stop heal, recover, increase, scale up bc you need more, down bc you need less. The ideas are farther from math and closer to physics and so there more need to manage them. These solutions are, for example, more general then k8s which deals with a limited context. But generality isn't itself a goal, but as your solution requires more actors, having a common vocab across them is useful. If that doesn't make sense to anyone, let me know, i might be wrong, i don't get to play with these ideas much (for better or worse!)

popeye16:03:35

Just consider a senior engineer is doing architecture work now 🙂

oddsor23:03:05

I’m trying to learn to better navigate complex datastructures using core functionality! Let’s say you wanted to reverse the two strings in this mess:

{:a [1 {:b [2 {:c "Hello,"}]} {:b [{:c "world!"}]}]}
so you’d end up with:
{:a [1 {:b [2 {:c ",olleH"}]} {:b [{:c "!dlrow"}]}]}
Does the core library have any neat tricks up its sleeve for this? I’ve ended up with a nasty update-map-update-map-update thing myself and can’t come up with something better. Examples in thread:thread:

oddsor23:03:38

Basic use of update and mapv:

(update data :a (fn [x]
                  (mapv (fn [y]
                          (if (map? y)
                            (update y :b (fn [z]
                                           (mapv (fn [x]
                                                   (if (map? x)
                                                     (update x :c str/reverse)
                                                     x)) z)))
                            y)) x)))
Using clojure.walk
(defn fif [pred fun] #(if (pred %) (fun %) %))
(clojure.walk/postwalk (fif #{"Hello," "world!"}
                            str/reverse)
                       data)
Using specter
(defn all-maps-in [k]
  (s/path k
          (s/filterer map?)
          s/ALL))

(s/transform [(all-maps-in :a)
              (all-maps-in :b)
              :c] str/reverse data)

oddsor23:03:54

I feel like it’d be possible to write small helper-functions to clean up the basic version :thinking_face:

ahungry23:03:47

I like the postwalk suggestion

ahungry23:03:55

(clojure.walk/postwalk #(if (string? %) (clojure.string/reverse %) %) x)

👍 2
ahungry23:03:34

(where x is your input sample - it'd reverse each string ending node - compared to the other solution by only referencing hello/world explicitly)

dorab00:03:35

There is also update-in

oddsor11:03:07

Yeah, if we assume that the sequences are always vectors (I like to write my code assuming that’s not the case) then this isn’t too bad either!

(-> data
    (update-in [:a 1 :b 1 :c] str/reverse)
    (update-in [:a 2 :b 0 :c] str/reverse))
After sleeping on it I also think it cleaned up okay by introducing the home-made and not-at-all-niche function mup
(defn mup [xs k fun]
  (into (empty xs)
        (map (fif map? #(update % k fun)))
        xs))

(update data :a mup :b #(mup % :c str/reverse))
I think I’ll stick to Specter or clojure.walk for these things in the future though 😅