Fork me on GitHub
Dmitrii Pisarenko07:11:33

I have a Figwheel project in which I want to have multiple pages such that each page has its corresponding ClojureScript file. How can I make sure that for a given HTML page a particular ClojureScript namespace is used? Let's say I have this HTML page:

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link rel="icon" href="">
    <div id="reg">
      <h2>Figwheel template</h2>
      <p>Checkout your developer console.</p>
    <script src="js/compiled/migration_to_russia.js" type="text/javascript"></script>
And I have this CloureScript file:
(ns migration-to-russia.reg
              [reagent.core :as reagent :refer [atom]]
              [reagent.dom :as rd]))


(println "This text is printed from src/migration-to-russia/core.cljs. Go ahead and edit it and see reloading in action.")

;; define your app data so that it doesn't get over-written on reload

(defonce app-state (atom {:text "Test"}))

;; Registration, reg.html (start)
(defn reg []
   [:h1 "Регистрация"]
   [:h3 "Проверка"]])

(rd/render [reg]
           (. js/document (getElementById "reg")))
;; Registration, reg.html (start)

(defn on-js-reload []
  ;; optionally touch your app-state to force rerendering depending on
  ;; your application
  ;; (swap! app-state update-in [:__figwheel_counter] inc)
How can I make sure that the HTML page uses the code from the above ClojureScript file (i. e. uses that code to bind regin HTML to whatever is defined in the above ClojureScript file)?


Short answer - just add print somewhere in the namespace and check developer console after loading. Long - your should check with your figwheel configuration and check into which bundle file that namespace will be rendered. And if that file is different from migration_to_russia.js then unlikely it will be used


 :foo 10
 :bar nil)
=> {:foo 10}
what is the closest to this assoc-some I'm thinking of? It should only add items when the value is not nil


I use cond-> a lot for this kind of thing


(cond-> {:foo 10} bar (assoc :bar bar)) would be in practice (where you don't know if bar is nil or not)

👀 1
✔️ 1

that is pretty darn neato!


How can I setup logging easily? There's but this seems to suggest there are better ways? I'm looking for something simple that a beginner can use to log to plain txt file. perhaps?

Cora (she/her)16:11:54

it's a mess, and I haven't found an easy way to set it all up without just stealing it from existing projects


I use logging, with slf4j behind it. It's pretty straight forward methinks

Cora (she/her)16:11:57

I've been meaning to try out timbre


I'm not a fan of timbre tbh


I find it a bit clunky to use and not as intuitive, dare I say it, as a simple xml file controlled by slf4j!


I'll check out both ways and see what works. Thank you both for the suggestions!

Cora (she/her)17:11:21

@dharrigan have you ever found docs on how to set those up properly?

dharrigan17:11:36 and slf4j?


even better, I have a demo project 🙂

Cora (she/her)17:11:27

that's what I meant about cribbing it from existing projects

Cora (she/her)17:11:26

and there's a big presumption that you already understand java's logging ecosystem

Cora (she/her)17:11:49

it's not a great situation, currently


For sure, yes, however I believe it's not beyond anyone to grok it.

Cora (she/her)17:11:31

sure, I guess I just mean that my original point stands, that it's a bit of a mess and mostly just need to steal it from existing projects


imho, we all borrow from other projects, not only logging. I stand on the shoulders of mightier giants than I.

Cora (she/her)17:11:30

sure, but even that's not ideal


Why? I mean, there's far to much NIH in many projects, causing things to be done time and time again, solving the same problems over and over.


If you can learn from others who when before us, how those problems where solved and how it can apply to our own projects, then that's incorporating the wisdom of others and their experiences into your own learning.


at least, thats how I like to look at it.


So, I think it is quite ideal, to learn from others and not ignore the lessons from the past.

Cora (she/her)17:11:21

ok this is veering way off course from what I was taking about. my point was clear documentation that explains the setups holistically is superior to just copy/pasting

☝️ 1
Cora (she/her)17:11:58

no one is saying don't learn from other projects

Cora (she/her)17:11:02

I'm saying that the only/best way to setup logging being copy/pasting is inferior to having well-rounded documentation, including examples, for solving the problem


Perhaps a PR to the project that includes better examples would help others?

Cora (she/her)17:11:41

I'm not here for "they should just read the code", it has been settled since forever that documentation is much, much better than slinging a mountain of code at people and hoping for the best

Cora (she/her)17:11:03

I don't understand any of them well enough to do that

Cora (she/her)17:11:18

if you do, then please do


I find the documentation quite sufficient


but then again, I suppose, I have a different background.

Cora (she/her)17:11:30

that's the Curse of Knowledge in play

Cora (she/her)17:11:09

beginners and those who don't understand are the best judge of whether documentation is sufficient

Cora (she/her)17:11:39

because the proof of sufficiency is whether it's good enough to teach and to learn

Cora (she/her)17:11:49

because that's what it's there for


Beyond just Clojure, I have never been able to get a sense of the trade-off between different logging frameworks. I have certainly felt the trade-offs after making an arbitrary choice, spending the time to learn, and then regretting/enjoying it. I find the docs for most logging projects all read very similarly because they focus on the basic mechanics (and often speed). The tricky stuff is usually in the configuration or something that gets glossed over as just “setup”.

Cora (she/her)17:11:29

that's a great point, too, there are different documentation needs at different levels of expertise.

Cora (she/her)17:11:32

you're at the point of not just "how do I do this?" but at "how do I do this well?" and "what are the implications of choices?"

👍 1
Cora (she/her)17:11:17

all super valid levels to be at and grow from, all poorly served by code you copy/paste

Cora (she/her)17:11:01

this is my dead horse I flog from time to time

Cora (she/her)17:11:09

thanks for coming to my TED talk


I have had success getting some code to work by just copy-pasting. In my opinion the critical piece that is missing the “why” for any of the choices made.


And if we want to solve interesting problems that tackle meaningful complexity over long stretches of time, just “getting it to work” isn’t enough.

Cora (she/her)17:11:17

sure, the setup need is served by copy/paste, but not the most critical part: understanding why

👍 2
Cora (she/her)17:11:48

serving beginners needs with docs yields big results later, too. give an on-ramp for beginners to become intermediate and you suddenly have more people to write different levels of docs at intermediate and novice levels

Cora (she/her)17:11:12

but if we create bottlenecks at the beginning then fewer people reach intermediate or mastery

Cora (she/her)17:11:54

it's a sweet positive reinforcement loop once you get it going at a cultural level

Cora (she/her)17:11:57

the dynamics of culture that yields great tools and docs and all that goodness depends on a strong inflow of people. otherwise the community shrinks or you end up with some wild survivorship bias that limits diversity of experience and needs

☝️ 1

tl;dr: The “what” matters to get things working, but the “why” matters to get things working well and allows for knowledge and understanding growth?

R.A. Porter17:11:57

The culture of incomplete and downright bad documentation has a creeping effect as well. I'm constantly surprised when beginners ask questions about those Clojure projects that are well documented where the answer is right there in the docs. Then I remember that they've just grown to expect bad docs and likely don't bother looking.

Cora (she/her)17:11:01

or it's hard to find in the docs


Yes, I see that too. Sometimes I wonder what’s the difference between languages, how to present Clojure in the best light (I’ll make a hungarian Clojure site) and that’s hard, how to build a successful project from the ground up. My experience in ad agencies (head of digital) dates back 15 years... but Clojure is different. What’s the difference between Golang/ Python/ R vs Clojure? Why would people try Clojure? Why is it so difficult to start for a complete beginner? How solve this? Eg. at R.. so easy to understand the documentation.. you can solve difficult problems quickly (I create my own LAMR environment (not PHP, I used R).. within 2 months..). So, I’m really thinking how to create one site, what is really helpful from early students like 8-12 yo, and they can learn like me Basic language.. So, I’m not sure.. complex examples bad.. ofc with documentation better; but how we can build more easier start for Clojure.

Cora (she/her)17:11:45

and they're already drowning in a sea of information and don't have the necessary context to zero in on the information they need


I know that is bigger part of this question.. but this is .. what is in my mind.

Cora (she/her)17:11:31

they're big questions. @pez has done so much wonderful work on addressing the needs of beginners. and @jr0cket has an awesome website that contains a huge number of resources for learning and growing in clojure

👍 4
❤️ 1

For me, I came here because by default logs to terminal. I wanted to change the default to log to a file but couldn't find it from the official docs (and the many other frequently used docs resources for clojure) after 15 minutes. Googling turned up too many results and so I hoped to get some tips from Clojurians


Did you manage to find a solution?


I didn't unfortunately, for now I'm making do with spit...


If you are going down the logback.xml route, then I can help you by showing you what should go into that file to log to a file


I thought I was missing something obvious, so I thought maybe someone here would know


I'm still reading/trying to understand the logback.xml part, but I really just wanted something easy to log to file quickly


I've pushed up a change to that project that shows logging to a file


I see it, thanks!


One defines appenders, console and file are two such appenders, then you tell the logger (root in this case) which appenders to use.


I don't have a java background. Is logback.xml part of the SLF4J library? where should I look for documentation on logback.xml?


logback and slf4j are by the same person. There is extensive documentation here:


Din dins for me...


Thanks for taking the time! Enjoy dinner!

Cora (she/her)18:11:32

that's awesome feedback! I love it 💜


if there are issues with tools.logging docs, would welcome a question at to move towards fixing it

👍 2

Very often #beginners give me valuable advice that I can't find on the internet

Cora (she/her)18:11:18

human brains are great search engines 😂

Cora (she/her)18:11:59

@seancorfield had an awesome writeup of jars, the context around it and such for those who don't come from a java background. I'd love if someone wrote up something about the logging ecosystem on the jvm

👍 1
Cora (she/her)18:11:33

because i'm still clueless on it and I've been working in Clojure professionally for two years now

Cora (she/her)18:11:34

it was a great read for me, from someone coming from outside of the jvm world


at the risk of tooting my own horn, I think is pretty good, I just haven't gotten it over line so it can be merged (in coming up on 6 years)

Cora (she/her)19:11:00

looks good 👍