This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (12)
- # asami (3)
- # babashka (59)
- # beginners (20)
- # biff (1)
- # calva (87)
- # cherry (8)
- # clj-kondo (41)
- # clj-together (4)
- # cljdoc (5)
- # cljfx (4)
- # cljs-dev (2)
- # cljsrn (6)
- # clojure (63)
- # clojure-europe (22)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (4)
- # clojurescript (5)
- # conjure (2)
- # datalevin (4)
- # datascript (8)
- # datomic (16)
- # events (1)
- # figwheel-main (1)
- # fulcro (9)
- # hyperfiddle (4)
- # introduce-yourself (1)
- # jobs (3)
- # kaocha (10)
- # lambdaisland (2)
- # lumo (7)
- # nbb (1)
- # off-topic (29)
- # pathom (15)
- # re-frame (80)
- # releases (1)
- # remote-jobs (4)
- # shadow-cljs (13)
- # spacemacs (9)
- # sql (25)
- # squint (32)
- # tools-deps (6)
- # uncomplicate (6)
- # xtdb (15)
Need to some advice here – started my Clojure journey as a first language a few weeks ago. I've gone through the basics and some advanced topics, but feeling a bit stuck. Basically, my main goal is to build things for the web – where should I go next? I guess my question is how to put into practice what I've learned so far. Would diving into reframe/reagent be too early? is there any middle places I should look into? I'd like to hear your thoughts!
Client side rendered codebases (with clojurescript) require a lot more learning because the abstractions are (perhaps necessarily) leaky + you have to split logic between client and server. It's possible to build performant and interactive website that are purely server side rendered (ie. just clojure). You can also sprinkle in some HTMX or Hyperscript to make the website even more interactive (these are just HTML tags so no extra clojure library required). You could try building a server side rendered website using https://github.com/weavejester/hiccup + https://github.com/ring-clojure/ring. Start with a "Hello World" page then build it up from there.
The book https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/ is a great resource to get into writing full-stack applications, well worth the price.
Yes, but admittedly mainly the earlier editions. I do own the third edition too and from what I can tell based on some cursory reading, there seems quite a bit of changes (like using Reitit instead of Compojure API etc.). I like the way the whole stack from Ring handlers to the UI are discussed in depth with examples.
Just popping in to thank you for the thread. I'm in a similar spot and looking for that elusive next step.
A book that is a bit too outdated at this point but that was crucial to me and I still hold dear is Clojure Applied. It's an opinionated take on what it means to build Clojure applications after you get an understanding of the language but before you are confident to make decisions on how to go about building stuff and how to put what Clojure offers you together to solve problems. Wouldn't recommend as a primary target at this point (probably the above is a better lead) but it's a nice one to have within reach. :)
re-frame is one good place to start, and almost a de facto standard amongst Clojurists. The downsides are that it is somewhat ornate, the upside is that it is very well documented. It also works off a secondary store a la Redux, so one gets sucked into more or less boilerplate and code juggling just to make the framework happy. That said, most of the front end community has swallowed the secondary store pill and survived. re-frame sits atop Reagent, which is nice but glitchy and provides building blocks more than a complete solution like re-frame. Both ^^^ also involve the ReactJS/Native pill. Not recommended, but again semi-standard. If ReactNative is a target, this is a great place to start: https://github.com/PEZ/rn-rf-shadow If you want to start simple, and are OK with react, try Helix, also great. I myself have a pure Web solution here https://github.com/kennytilton/matrix which I started to document when ClojureDart turned my head. Not much doc, but it thinly wraps HTML and CSS so MDN doc works. ClojureDart (CLJD) will let you avoid React. It is brand new but quite good in its initial form. The DX might be the only weakness, but that is being worked on. Flutter/Dart are nicely stable unlike React, but nothing like the simple uniformity of HTML, and brace yourself for serious OOP. Team CLJD is making the OOP less burdensome, like any good Lisp wrapper. I am doing the same with Flutter/MX. I have a nice POC implementation, but it is undocumented until I get off social media this morning and start doing that. Belated tl;dr: as a beginner, re-frame or Helix.
Since Clojure is your first language, I'd recommend taking things slower. I'd start with applications that don't need a UI (or a very minimal text-based or even REPL-based UI). When you are ready for a web UI, consider something basic like https://github.com/seancorfield/usermanager-example That will familiarize you with the foundational libraries used in a Clojure web app. Re-frame is great, and it addresses many real-world issues you will need to consider if you are building a production web app. But that's not where I'd start.
If you can define a specific thing you want to build, more specific advice can be shared from the community E.g. do you want to build a landing page (reagent, hiccup and some CSS), or a mobile app with react native, or a full-stack app (front end + server). So figure out specifically what you want to build and go from there The web development with Clojure 3rd edition probably covers some or all of what you want, although there are many other examples and libraries Also take a look at https://kit-clj.github.io/ to generate example projects that demonstrates how libraries can work together Reagent is a defacto standard in front end apps and very simple to work with, especially coupled with hiccup or Selma to manage content Re-frame builds on Reagent and is a lot more involved but a lot more features, especially for managing complex UI flows and events. Re-frame is too much simpler web UI's and you can use just parts of re-frame
To start with a simple ClojureScript app, I like to use figwheel as the build tool, its simpler than shadow-cljs (although not integrated with node as shadow is) There is an article about getting started with Clojurescript and figwheel here https://practical.li/blog-staging/posts/clojurescript-workflow-with-clojure-cli-tools-and-figwheel-main/
How to traverse a folder in depth first manner and print the number of files in each folder?
(defn traverse [file] (when (.isDirectory file) (let [files (seq (.listFiles file))] (println (.getAbsolutePath file) ":" (count files)) (run! traverse files)))) (traverse (File. "."))
hi! I'm trying to solve what I think is a very simple problem, but there's something I'm missing Want to have a function that takes a number (upper bound of a range), and some predicates (evaluate a number and return true or false), and returns a list (or vector or whatever) of numbers that satisfy either predicate I have this:
but when I call it, like this
(defn find-range-until-number-with-conditions [m & [predicates :as all]] (apply (filter some-fn all) (range 1 m)))
(find-range-until-number-with-conditions 10 [multiple-of-3 multiple-of-5])I get this error
class clojure.lang.LazySeq cannot be cast to class clojure.lang.IFnI have two questions: • What I'm just getting plain wrong? • How could I debug this in order to be more autonomous at solving this kind of beginner questions? (I get that I'm passing somewhere a seq when I should be passing some function, but that doesn't help me much at this point) BTW I want this function to solve (in a more elegant way) Project Euler #1 problem, which is easily solveable like this
But since I'm trying to learn, I wanted to do it the way I described above
(reduce + (filter (some-fn #(= (mod % 3) 0) #(= (mod % 5) 0)) (range 1 1000)))
look at the params for
apply and look at the return of
filter - apply expects a fn as its first arg and filter returns a lazy seq (which is not a fn)
When you swap
apply , it will work (`->>` is thread-last macro):
(defn find-range-until-number-with-conditions [m & predicates] (->> (range 1 m) (filter (apply some-fn predicates))))
(find-range-until-number-with-conditions 10 odd? #(> % 5)) => (1 3 5 6 7 8 9)