Fork me on GitHub
#beginners
<
2022-06-26
>
vlad_poh00:06:36

Why does this return true

(not-any? (fn [f] (f nil)) '(nil? coll?))
but the following return false
(not-any? (fn [f] (f nil)) (list nil? coll?))
(not-any? (fn [f] (f nil)) [nil? coll?])

hiredman00:06:32

The symbol nil? is not the same as the function named by the symbol nil?

hiredman00:06:21

Quoting means you get the literal symbols, and symbols can be invoked as functions and happen not to throw errors when invoked on nil

vlad_poh02:06:41

I thought ’(…) was a shorthand for (list ..) .

hiredman02:06:16

Quoting means what follows is an unevaluated literal

hiredman02:06:40

So the list (f x) is evaluated as the application of f to x, but '(f x) evalutes to a list of two symbols, f and x

hiredman02:06:02

Pedanticly, (f x) evaluates to the application of the evaluation of f to the evaluation of x

Jon Olick04:06:31

’(…) is shorthand for (quote (….))

Gabriel Kovacs10:06:07

Hi! I would appreciate some suggestion on how I can get into web dev with Clojure. To get more comfortable with the language I am doing the Clojure track in http://exercism.io . I picked up the "Web Development with Clojure" book but it does not work for me. After looking at the https://www.youtube.com/watch?v=utmrSswhhn0&amp;ab_channel=LosAngelesClojureUsersGroup video my takeaway was that Luminus has been more or less replaced by Kit. This was also mentioned here https://www.youtube.com/watch?v=DFzukK5-rpU&amp;ab_channel=LondonClojurians . From the meetup video I had the impression that even experienced Clojure developers had a hard time to understand everything that was going on. I still don't know how I as a beginner should start approaching the web dev subject in the Clojure ecosystem.

Martin Půda11:06:04

I suggest you to start with a simple Ring + Jetty server (https://github.com/ring-clojure/ring) and learn about routing/ handlers, representation of request and response and middleware. Then you can switch to Compojure or add some Hiccup + Garden / Selmer. Then you can play with some database (don't connect it to your web, just download an example project (e.g. from HugSQL) and see how they represent data and SQL queries). After you learn these parts separately, web frameworks should make more sense to you.

1
Gabriel Kovacs11:06:45

Thank you for the advice! I will give it a try 😀

Mattias11:06:28

I have appreciated @U05254DQMs content here as a fairly no-nonsense introduction: https://practical.li

👍 2
❤️ 1
michaelteter13:06:44

I also find the choices difficult to make. There are multiple Clojure sages who have made some form of tutorial or course on this topic, but they all tend to get out of date with current state of things quickly, and they all seem to differ in some significant ways (at least the differences seem significant to a beginner). Kit seems really nice since it already has plumbing in place for some things which otherwise take time to learn in isolation and then add to a project. Looking at a Kit-based project which has cljs, sql, and html modules included (all things you might want if making a modern web app), you see how complex the deps.edn looks. Cobbling something like that together as a beginner is unlikely.

michaelteter13:06:13

Plus the added small issue of some tutorials being lein based while others are deps based.

Gabriel Kovacs13:06:53

This information overload is a problem. Learning the language and the tooling at the same time, is a challenge. Finding the proper starting point is not that trivial. I am optimistic that focusing on just one library at a time should do the trick 🙂. I just did not want to learn outdated stuff.

practicalli-johnny14:06:18

Although Clojure code should be the same regardless of if it's a Leiningen or deps.edn based tutorial, it does add more cognitive load to keep switching, especially when there are so many other things to learn. I don't know a way around this (without investing a few $100,000 on writing a long list of consistent tutorials) Unless a tutorial relies on a particular plugin to work, it should be possible to get the code working with either a project.clj or deps.edn file with the right dependencies (http://clojars.org can be used to translate between one format and another).

practicalli-johnny14:06:53

Luminus and Kit can create very big projects, so suggest limiting the options used when creating new projects. Essentially they do the same thing, although use different tools, libraries and configuration approaches. A simplistic difference is that kit takes a more data centric approach (hash-map and vectors for config, defining routes, etc) They do provide a lot of information and if you wanted to learn the entirety of one of these from scratch, I would set aside a 6 months timeline (unless you can devote yourself to full time study of it, then perhaps more like 3-8 weeks)

practicalli-johnny14:06:08

If anyone has any questions about any of the http://Practical.li content (or notices something missing - there is a lot to add), please do ask in #practicalli channel or send me a (polite/constructive) direct message

👍 1
🙏 1
seancorfield21:06:12

@U02AMR8032L This is why I created https://github.com/seancorfield/usermanager-example as a small, self-contained, database-backed web app (server-side) so that beginners could see how a small number of libraries could be combined to build basic HTML web apps -- and to be small enough that beginners could understand all the moving parts. The README links to another version built with different libraries -- again, small enough to understand the moving parts, and also to see how different libraries can be used to achieve similar ends.

seancorfield21:06:46

That example originally use to support multiple HTTP servers but I cut that out as folks just found it confusing.

seancorfield21:06:45

The reality is that Clojure is designed as a general purpose language to tackle "harder" problems than "basic web apps" -- so the benefits of using Clojure come in the larger, more complex systems and the flipside is that the small, simpler systems are not as well supported. By which I mean that you can definitely write small, simple systems in Clojure but you need to make a lot of decisions about the building blocks you want to use -- and that seems like a lot of work for a small, simple system (but it's much less work, relatively speaking, for a large, complex system).

seancorfield21:06:28

I don't recommend Luminus (or Kit) for beginners, to be honest, because there are so many moving parts -- and if anything breaks, beginners are usually completely lost trying to figure it out.

Gabriel Kovacs22:06:14

Thank you very much for the repo and the advice. I would really like to have the possibility to tackle the harder and more complex problems in the future. I wanted to go the "basic web app" route because it would be something familiar and thus I hopped that it would be a good entry point. I am not so keen on frameworks but because I already had bought the book I wanted to give it a try 🙂.

kennytilton07:06:27

Are you a web developer now, @U02AMR8032L? If so, what is your stack? If not, you have the added challenge of an unfamiliar domain added to unfamiliar language, IDE, and build tooling. Speaking of "unfamiliar language", have you worked through sth like Clojure Koans? http://clojurekoans.com/ Next issue is the Luminus/Kit thing. I am with Sean on this one, for the reasons he gave. It would be super if a framework Just Worked(tm) and gave you a big running start on web dev, but in fact they demand a big learning curve (of just that framework, no general skills) at the same time they are solving other problems for us. But those "other problems" are what we need to master, not have handed to us on a platter. I recommend first getting reasonably comfortable with Clojure while getting comfortable with an IDE at the same time, then grab one of several "hello world" projects, such as those offered by https://github.com/day8/re-frame. Here is one https://github.com/day8/re-frame-template. Also, build tools such as figwheel,main https://github.com/bhauman/figwheel-main offer ready-to-go repo/tutorials (look for "Try Figwheel with Flappy Bird"). One downside, though, is now having to learn re-frame 🙂 but the doc is great and re-frame seems to be the leading CLJS wev dev tool. If you like react, Helix has https://github.com/lilactown/helix. But then we need to know React. 🙂 If your skills already include React that would be great. In any case, by starting with a pre-built hello world, you can defer wrestling the CLJ tools madness until absolutely necessary. It is a CLJ problem worth avoiding. Btw, https://github.com/PEZ/rn-rf-shadow also offers great starter experiences but then we get into React Native and re-frame and the sad world of NPM. Again, let's defer that as long as possible. Once you find a "hello world" you like, just build out from there. hth

1
❤️ 1
seancorfield17:06:18

And it may not be obvious from Kenny's response there @U02AMR8032L but there's quite a bit of difference between frontend (ClojureScript) and backend (Clojure) in terms of code organization and tooling and so on. There are fewer differences between the two languages these days, fortunately. The two main options for cljs development are Figwheel Main and Shadow-cljs and there are dedicated channels for both here #figwheel-main #shadow-cljs (the latter is the far more popular approach but, like Kenny, I lean toward the former). re-frame is great (but, yes, there's a lot to learn there especially if you're not familiar with reactive approaches to UI development).

Gabriel Kovacs18:06:30

@U0PUGPSFR, @U04V70XH6 thank you both for the insights. I would call myself a backend developer. Some of the languages that I used of are Java, JavaScript, TypeScript, Python. I am going through the Clojure track provided by http://exercism.io. I have the feeling that there is a function for everything. I don't know if there is something like a smart (clever) vs. a readable solution in Clojure.I am pretty comfortable with the VsCode + Calva combo. I did frontend (Angular) but only for some personal projects. Even if I don't intend to focus on frontend I wanted to know what the options are and see how it looks. I kept hearing "it's only data" 🙂. I also wanted to switch it up and not do only single isolated exercises but also something more "complex" like data provided via a form and a little bit of logic. At the moment I just want to get a better understanding of Clojure and it's ecosystem. And if I develop a liking for it try to find someone who is willing to pay me for doing it 😀.