off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
Ben Sless 2021-01-21T08:44:28.000600Z

Anyone has the reverse threading macro at hand?

2021-01-21T14:41:34.002400Z

I don't recall ever hearing of the reverse threading macro. how does it behave differently than threading macros built into Clojure?

alexmiller 2021-01-21T14:57:56.002800Z

it's like, the opposite, man

😂 4
borkdude 2021-01-21T15:38:55.003800Z

(defmacro <-
  [form]
  (loop [form form, out '[]]
    (if (seq? form)
      (let [f (first form)
            args (first (rest form))]
        (recur args (conj out f)))
      (list* '-> (reverse (conj out form))))))

(macroexpand-1 '(<- (inc (inc 1)))) ;;=> (-> 1 inc inc)
;P

borkdude 2021-01-21T15:39:42.004200Z

(I'm sure I can nerd snipe you into better versions of this)

2021-01-21T15:42:27.005Z

So, here is the code that doesn't need a Clojure threading macro, please give me the same but using a Clojure threading macro? I guess that is one way to reverse it 🙂

borkdude 2021-01-21T15:43:07.005600Z

@andy.fingerhut That was my interpretation of reverse threading macro asked by bsless

2021-01-21T15:44:53.006100Z

Now if you can just make it so that you invoke it like this: ((inc (inc 1)) <-) 🙂

borkdude 2021-01-21T15:45:34.006400Z

(inc inc 1 <-)

borkdude 2021-01-21T15:49:31.006700Z

maybe something for 1.11, will require some new evaluation rules...

orestis 2021-01-21T16:10:27.007600Z

I think this is what @ben.sless asks https://twitter.com/cgrand/status/1281527501387440128?s=20

Max 2021-01-22T22:06:57.059800Z

I keep staring at this and can’t quite wrap my head around it. How does threading the forms in reverse order not result in the forms getting executed in reverse order?

cgrand 2021-01-23T12:33:54.068600Z

With this macro you thread other macros (if let when etc) for which evaluation order is not the applicative order. Try to expand a simple example with pen & paper.

2021-02-03T09:06:35.483Z

I’ve worked out the example a bit more so it works in the repl when you paste it

(def fn-which-may-return-falsey identity)
 (def fn-which-may-return-nil identity)
 (def a 2)
 (def y 4)
 
 (<<-
   (if (odd? a) 1)
   (let [a (quot a 2)])
   (when-let [x (fn-which-may-return-falsey a)])
   (when-some [b (fn-which-may-return-nil x)])
   #_(when (seq x)) ;;; type incompatible
   (do (println x))
   (if (odd? (+ x y)) 2)
   3)   
   
 (macroexpand '(<<-
   (if (odd? a) 1)
   (let [a (quot a 2)])
   (when-let [x (fn-which-may-return-falsey a)])
   (when-some [b (fn-which-may-return-nil x)])
   ; (when (seq x))
   (do (println x))
   (if (odd? (+ x y)) 2)
   3))

orestis 2021-01-21T16:12:47.008200Z

That thread has example usage too

dgb23 2021-01-21T16:43:31.008600Z

Some general thoughts about beginner friendliness, adoption and learnability of Clojure. Disclaimer: I’m teaching web programming/development for designers part-time, so I’m strongly biased. IMHO web programming (frontend) is likely one of the best introductions to programming for several reasons: * Very fast feedback loops: You code, save and you see the results immediatly. * GUI/user centric: printing stuff on your terminal/REPL ist not very exciting for most beginners. * Familiar: you build something you already understand as a user and conceptually, very few concepts have to be learned. * Practical / reach: you can publish a website easily, you create something that you can show and has value. * Creative: the web is an open system with tons of capabilities, from drawing to calculating to communicating etc. However, most introductions to Clojure seem to start with JVM Clojure and almost none of them are truly introductory. Java and the JVM are scary! Someone who is familiar with these and has substantial experience will consider Clojure, because it solves problems they know from experience. Others are likely comming from learning Scheme/Racket via SICP etc. (Scheme has a strong tradition as a educational language and fantastic books/resources) and they are looking for a Lisp that has a strong pragmatic focus. They will happily take those hurdles. But what about real beginners. They might have written “Hello World!” with Python and know what a loop is or created a rudimentary HTML/CSS website. Or maybe they don’t even know where to start. I think there might be an opportunity to build learning resouces for real beginners based on the web and ClojureScript. Likely a subset of ClojureScript, with a set libaries focussed on learning, or even a simpler learning DSL that is built on top of ClojureScript. Examples of thinkable libraries/features: * easy and fast setup. There needs to be some time limit, like 5 minutes. * a simple, constrained GUI library * a networking library based on AJAX or websockets * maybe canvas/webgl to create some simple games All of these features have to be stripped down to the essence, have very strong “just works” conventions and very little to no configurability. Sorry for the long rant. But I really wonder what you guys think of these ideas, especially since I don’t know all the beginner resources for Clojure. Even pointers like X does already do that or have a look at Y are welcome.

Ben Sless 2021-01-21T16:50:24.009200Z

Yes! that's the one, thank you 🙂

Mno 2021-01-21T16:51:51.010400Z

I believe it was lighttable or something like that which seemingly had the “batteries super included” approach to things with built in templates and such.

Mno 2021-01-21T16:52:41.011800Z

But I believe it was also abandoned a few years ago.

👍 1
seancorfield 2021-01-21T16:53:29.013200Z

ClojureBridge was designed to teach Clojure to total beginners (although many attendees were already programmers in other languages) and one of the struggles we faced was trying to figure out learning exercises that were fun and provided the sort of feedback students like best. I think ClojureBridge has tried several curricula with at least one focused on graphics (Quil on the JVM, I think).

👍 1
seancorfield 2021-01-21T16:54:09.013600Z

See https://github.com/ClojureBridge/curriculum

seancorfield 2021-01-21T16:55:11.014200Z

Ah, there are five choices of app now, including one web app...

2021-01-21T16:55:20.014400Z

My view (which I have previously expressed in the Clojure Slack) is that I don’t see Clojure as a suitable language to teach to beginners. Similarly, I don’t see Java/Kotlin/C++ as suitable languages either. when learning to program as a beginner, you need to limit the surface area of things that you need to learn and the above languages don’t do that sufficiently for my liking.

✔️ 1
dgb23 2021-01-21T16:56:20.015800Z

Turtles all the way down

2021-01-21T16:56:31.016100Z

When I learned Clojure, I already knew Java and I had already learned Emacs and Slime (it was a while ago). I personally would have struggled if hadn’t.

seancorfield 2021-01-21T16:56:34.016300Z

@hobosarefriends Yeah, LightTable was really good in the early days but once it became incompatible with macOS after one of the O/S releases, it wasn't a good experience for teaching. I think ClojureBridge used NightCode for a while which is a really simple Clojure all-in-one editor. [Confirmed: see https://github.com/ClojureBridge/curriculum/blob/gh-pages/outline/setup.md ]

caumond 2021-01-21T16:57:28.017700Z

None of that I heard about while learning

2021-01-21T16:57:52.018400Z

(I’m still interested in hearing about tools/resources that you can learn in five minutes and hearing about experiences of beginners leaning Clojure because I could be completely wrong, of course.)

dgb23 2021-01-21T16:59:01.020300Z

I’m really thinking in terms of “Introduction to Programming” and not “Introduction to Clojure”

dgb23 2021-01-21T17:07:42.023100Z

There are many people who would benefit from learning how to program, not necessarily to become programmers full-time. I’m being a bit “in your face” here: There are things you cant put in front of 70% of beginners at the frist hour or so. * data structure concepts * lots of declarations * not seing a GUI * lots of setup Essentially they have to see some satisfying results in a couple of minutes.

dgb23 2021-01-21T17:08:57.023700Z

Ill look at clojurebridge, it seems to have done many things right!

dgb23 2021-01-21T17:10:09.024400Z

I just remember now, I started programming in QBasic (I think). We were able to put in a floppy, write a couple of lines and then see pixels on the screen.

dgb23 2021-01-21T17:11:12.025500Z

I’m thinking of that kind of experience, but then gradually (and very friendly) building up knowldge and familiarity with programming in general and Clojure specifically.

dgb23 2021-01-21T17:21:02.025600Z

Those are very good points. I agree especially with the surface area part. A beginner should be programming against very simple interfaces at the start. I think a Lisp is inherently suitable, because of its meta programming capabilities and dynamism. You can build a library of macros around a beginner experience. I disagree with having to learn Emacs though. I think VSCode and others enable a better beginner experience.

cgrand 2021-01-21T17:23:45.025800Z

fwiw in real code I call it else->>

borkdude 2021-01-21T17:24:12.026Z

really awesome macro

☝️ 1
🙏 1
alexmiller 2021-01-21T17:40:02.026400Z

https://www.maria.cloud/ might be worth looking at too

👍 2
😲 1
1
🎉 5
dgb23 2021-01-21T17:44:52.026900Z

Wow!

dgb23 2021-01-21T17:50:17.027500Z

This is very much like what I imagined but way better!

🕺 1
2021-01-21T18:14:39.027600Z

If they are real beginners, then would such a course include learning HTML, CSS, AJAX, too? Or assume you learned those already somewhere else?

dgb23 2021-01-21T18:23:33.027800Z

No! I thought more of having very constrained abstractions that use those things under the hood, and maybe you can dig down gradually to expose them over time.

👍 1
phronmophobic 2021-01-21T18:23:53.028Z

I think this part of clojure has been improving dramatically. For minimizing setup, I think https://github.com/babashka/babashka could be a really good fit. You could even have a download that included all the dependencies you were interested in. When it comes to GUIs, I'm pretty biased since that's the project I've been working, https://github.com/phronmophobic/membrane. The hello world for membrane is:

(require '[membrane.skia :as backend]
         '[membrane.ui :as ui])
;; Show a window that displays a "Hello World" label
(backend/run #(ui/label "Hello World"))
Making programming more accessible is a topic I'm interested in, so if you do end up going with a non-web approach, then I would be happy to help.

👍 1
dgb23 2021-01-21T18:29:55.028600Z

Impressive!

phronmophobic 2021-01-21T18:47:55.028800Z

depending on your time horizon, since clojure is expression based and repl friendly, it could become a great language to build beginner friendly programming environments

🙏 1
vemv 2021-01-21T19:55:09.034900Z

I've always thought the beginner persona is highly conflated (absolute beginner to programming? new to webdev? new, coming from a different lang?) For absolute beginners, webdev seems so complex, dragging so much historical baggage, fads etc that it can be just confusing to newcomers Ruby's irb console seems pretty self-contained and unassuming. Not sure if it allows one to code visual games like QBasic does though :)

dgb23 2021-01-21T19:59:45.038700Z

That’s a very good point actually. There are very different types of approaches and beginners. Since I’m teaching designers to code, it is useful and easy for them to think in terms of layouts. Others think well in terms of abstractions/math, and then there are learners who think in terms of machinery. For the latter it is useful to start with something like C, assembly or even by constructing machines manually.

borkdude 2021-01-21T20:00:01.039100Z

GWBasic's PLAY statement got me hooked to programming in primary school ;) (https://hwiegman.home.xs4all.nl/gw-man/PLAY.html)

😁 2
dgb23 2021-01-21T20:00:45.039600Z

There is no one type of programmer.

vemv 2021-01-21T20:03:22.039800Z

yeah I was thinking a bit about that - some people may be more 'visual-thinking' than others although I wouldn't underestimate how hard can learning the basics be: variable assignment, divide-and-conquer with functions, etc. those routinely blow children's / teens' minds so if they don't get to understand those, the rest of the learning could collapse by its own weight

vemv 2021-01-21T20:11:52.040300Z

Seems pretty ellaborate :) I recall playing a bit with https://en.wikibooks.org/wiki/QBasic/Sound#SOUND (much to the annoyance of my classmates)

borkdude 2021-01-21T20:12:20.040500Z

yeah, also that one, both :)

dgb23 2021-01-21T20:16:51.040700Z

Yeah, you need a lot of patience and enthusiasm to keep them hooked :)

☺️ 1
valtteri 2021-01-21T20:19:51.041100Z

Yep. no tool, method, language or book is going to do the learning for you. That’s something each person need to figure out themselves.. eventually. “How do I learn this thing the best?“. “How do I find the relevant resources to guide my learning?” “Where do I need help?“.

valtteri 2021-01-21T20:21:24.041300Z

In my experience the best teachers are the ones who actually try to help you to find the best learning methods for yourself.