Fork me on GitHub

extreme beginner Q: getting this from "lein figwheel":

[dev@dev ~/clojure/jobwatch]$ lein figwheel
Figwheel: Cutting some fruit, just a sec ...
2020-08-25 17:26:53,238 [main] WARN  clj-antlr.common - multi-hinted-let is deprecated and will be removed in a future clj-antlr release. Migrate to char-stream functionality. 
Exception in thread "main" Syntax error compiling at (luminus/http_server.clj:20:26).
	at clojure.lang.Compiler.analyze(
	at clojure.lang.Compiler.analyze(
	at clojure.lang.Compiler$InvokeExpr.parse(
	at clojure.lang.Compiler.analyzeSeq(
	at clojure.lang.Compiler.analyze(
	at clojure.main.main(
Caused by: java.lang.RuntimeException: No such var: http-kit/server-stop!
	at clojure.lang.Util.runtimeException(
	at clojure.lang.Compiler.resolveIn(
	at clojure.lang.Compiler.resolve(
	at clojure.lang.Compiler.analyzeSymbol(
	at clojure.lang.Compiler.analyze(
	... 103 more                                                                                                                              │
... any idea what the deal is? brand-new Luminus project ("+reagent +http-kit +postgres +cljs +graphql +auth")


I imagine there's something useful in that stack trace, but I don't see how to enable greater verbosity.


I think the important bit is “no such var http-kit/server-stop”


...It seems to be a version compatibility issue that is somehow triggered when you try to start things via Figwheel. If I do lein repl and (require 'luminus.http-server) it loads just fine.


There's so much in that template that it's hard for me to tell what's causing the problem (this is why I don't recommend Luminus for beginners: when things go wrong, there are far too many moving parts for them to stand any chance at debugging the problem).


Well... when I say "beginner", I mean mostly "with Clojure's peculiarities". But yes, there are certainly a lot of moving parts.


http-kit/server-stop! is new in http-kit 2.4.0, which is what luminus-http-kit 0.1.8 is bringing in. I think lein figwheel is causing an earlier version of http-kit to be loaded but I cannot figure out how (since I don't use Figwheel).


Hmm. OK. Any suggestions for what to do with it? Skip http-kit?


Jetty is fine so, yeah, skip http-kit. We use Jetty in production, to power 40+ online dating sites in a dozen languages worldwide -- it's solid for high-traffic stuff.


Early on we saw random "thread death" errors with an earlier version of Jetty so we switched to http-kit, which was reliable but not supported by New Relic for monitoring, so we switched back to (a later version of) Jetty to get better monitoring and it's been rock solid since then @theron.bair


Hi! What would be the most effective way of finding if :done is set to true in ANY of the maps the following vector? [ [{:done true}{:done false}] [{:done false}] ]


I think (some :done your-seq) would do it


it will return true or nil if no :done true is in there


there's also not-any?


@michael.e.loughlin so some will traverse all dimensions of the vector?


it works well on one dimension but not on more it seems


Maybe I just should flatten the vector first..


Flatten is lazy so the performance hit might not be so bad


then some works


if you have no more than 2 dimensions in your sequence this works: (some (fn [xs] (some :done xs)) your-seq)


oh sorry, do you want arbitrary nesting like a tree?


otherwise @emilien has it


thank you both @michael.e.loughlin @emilien there are always some elegant solutions in clojure.. just need to internalize them. 🙂


Any idea how to rewrite this CSS config

input[type="time"]::-webkit-calendar-picker-indicator {
    background: none;
in Garden/CSS?


I solved: [“input::-webkit-calendar-picker-indicator” {:background “none”}] ..

👍 6
Endre Bakken Stovner18:08:51

I found the line ;;ignore println statements in prod (set! *print-fn* (fn [& _])) I understand print-fn is, but I would like to see docs for it and all such global variables (or whatever they are called). Are they listed anywhere? I am guessing it is specific to Clojure since it is not defined anywhere in the Luminus-project I am reading.


(doc print-fn)


(But with earmuffs and not bold :)

😆 3
Endre Bakken Stovner19:08:02

Thanks! I had the wrong repl open XD

Alex Miller (Clojure team)18:08:15

I don't think that's a clojure thing

Endre Bakken Stovner19:08:36

You are right, it is only in cljs-core it seems 🙂

Endre Bakken Stovner18:08:02

I'll ask in the luminus channel then 🙂 It was hard to google.

Alex Miller (Clojure team)19:08:03

if you want a list of all in-scope dynvars: (->> *ns* ns-name ns-refers vals (map symbol) (filter #(clojure.string/starts-with? (name %) "*")) sort pprint)

Endre Bakken Stovner19:08:39

Thanks! I'll play around with it 🙂

Alex Miller (Clojure team)19:08:26

presumably print-fn will be in there somewhere :)

Alex Miller (Clojure team)19:08:52

not sure that will work in cljs


Hello all!, I’m a beginner and I’m trying to implement a SPA. I used a template. I want to include an authentication/authorization schema. I have seen and What do you recommend? Do you have good recommendations to read about web application development in clojure/clojurescript?


For full-stack Luminus is a good start


SPA you have a variety of options most common ones based on React. React wrappers: Reagent, rum, helix, uix Frameworks: Fulcro (relay-like), re-frame (redux-like)


Excellent, I’m gonna check Thanks a lot!


Luminus is based on ring so both Friend and Buddy should work with it


For SPA, there’s also Keechma, though I don’t know much about it

👍 3

I would just caution that there are a lot of moving parts in Luminus and most folks new-to-Clojure tend to struggle with it. There is a book to go with it, Web Development in Clojure (in Beta for the Third Edition, so you buy the ebook and get updates as work on the book progresses).

👍 12

Nice! Didn’t know that


Without the book, making sense of the generated Luminus project, is really pretty tough for beginners. And Fulcro is equally bewildering for beginners.


Web development with Clojure -- especially an SPA using ClojureScript on the front end and Clojure on the backend -- tends to be a lot harder for beginners than web development in a lot of other languages...


Yes it is hard!, I think I’m gonna start with Luminus, then move to SPA when I master the basics.


You might want to start with just Ring + Compojure to get the basics mastered. Then perhaps look at which uses Ring, Compojure, Component, Selmer, and next.jdbc. And then look at Luminus.

👍 3

Any reason you picked component/selmer over integrant/hiccup ?


@kaxaw75836 I think Component is easier for beginners to understand (and I prefer it in production code over Integrant). The same goes for Selmer -- since it's like Django templates.


Sorry, I'm a bit late. @seancorfield would you mind explaining what's your opinion on tolitius/mount? At first sight, stuartsierra.component looks like much more boilerplate with no clear benefits.. but I must be missing something in component.


mount relies on global state which is a bad idea, IMO.

👍 3

Thanks! I'll spend more time exploring the component then. That's good I noticed your message in #beginners


component makes it very easy to swap out components for testing and allows you to apply the start/`stop` lifecycle via metadata to Clojure objects. For example next.jdbc.connection/component uses that approach on a function to provide a minimal component-compatible approach to building connection pools.

👍 3

Integrant has both good and bad aspects, IMO. I like the data-centric approach in theory but I dislike the fragmented code that tends to appear when you implement the various hooks the Integrant provides.

👍 3

For example has Integrant-specific defmethod's all over the code base so trying to form a mental model of the "system" is much harder (for me, at least) and it looks much harder to swap out "components" / lifecycles when stubbing for testing.

👍 3

Also, we have UI folks on our team who do HTML/CSS/JS and they can edit our Selmer templates but would not be able to edit Hiccup data 🙂


ah designers, true


have you found any tangible benefits for data routing libraries over compojure?

Michaël Salihi22:08:54

@kaxaw75836 For learning purpose, I redo the great usermanager eg. and decide to move some libraries to learn them too. - Compojure -> Reitit - Component -> Integrant Maybe it can help :

👍 6
Michaël Salihi22:08:49

Thx so much for your useful repo and helping @seancorfield


@kaxaw75836 We're using Bidi in one app at work, instead of Compojure. I suspect if we were starting over, we might use Reitit everywhere.

👍 9
💯 3

I like how Reitit looks, based on @jacek.schae’s new course for which I reviewed all the next.jdbc code.

❤️ 3

@admin055 That's nice. I'll update my readme to link to that as well.

👍 3
Michaël Salihi22:08:02

Perfect, thx! I'll put tomorrow an README too with backlink to your repo and usage to run the app.


the place where we use bidi the reverse routing was really nice in the beginning as our urls shifted around, but the urls have been fairly stable for sometime now


seems like a really helpful feature when starting then


the big difference in my mind between compojure and most other routing libraries is in compojure finding the route and executing the handler are a single operation


you can't ask a compojure route what handler a url would hit without invoking that handler


splitting that up allows for some nice integrations with things like component, bidi can return a keyword (instead of a ring handler like most of the examples show), which you can use to lookup the handler component by name


I haven't used reitit, and have only been vaguely keeping an eye on it, but it seems to want to bake(maybe that is just the docs) in the idea that routing is a function of urls -> handlers, not urls -> whatever data I want, which is not a decision I am a big fan of


Looks like it can use names instead of handlers in the routes


cool, something to keep in the back pocket