Fork me on GitHub

Hi! πŸ™‚ About MongoDB. Does anyone here know how the monger library (via the mongodb java driver) converts the internal JSON data structures to and from Clojure data types?


Documentation says: "Monger does not try to offer object/document mapping functionality. With Monger, you work with native Clojure and Java data structures like maps, vectors, strings, dates and so on"


Conversion seems very fast so I am trying to find out why. :)


I guess there are some BSON <-> clojure converter involved

Louis Kottmann16:11:04

hello, is there an easy way to get the formatted time elapsed since a given date (for example: "5days ago") in clojure?

Louis Kottmann17:11:46

this uses clj-time and I was told to use java-time now

Louis Kottmann17:11:55

datetimes in Java-land are a nightmare..

Igor Garcia15:12:55

@U01CVNTDF34 have a look at tick - it uses Java-time and you can use it in both clj and cljs

Louis Kottmann16:12:28

looks interesting, don't know why I went past it, thanks

Louis Kottmann16:12:22

it doesn't seem to support humanizing a time "ago" (i.e: "5 days ago")

Louis Kottmann16:12:31

but it's definitely more complete than java-time

Igor Garcia17:12:25

Oh @U01CVNTDF34 I'm sorry I completely missed the point of your initial message. Try this

Louis Kottmann17:12:42

actually I replaced my code with and it's much better already

Louis Kottmann17:12:35

that duckling lib looks awesome

Louis Kottmann17:12:40

I never saw it before!

Louis Kottmann17:12:44

I'm trying to see if it can handle the reverse (a duration to a humanized representation)

Louis Kottmann17:12:36

mmh it doesn't seem to do that, and it has been deprecated in favor of an haskell version from facebook πŸ˜•

Igor Garcia18:12:18

@U01CVNTDF34 sorry I can't help much. I don't think it would be too hard to implement one, though. And at the end you can publish that as a lib πŸ™‚

Louis Kottmann18:12:47

well, I did but I didn't make into a library

πŸ‘ 3
Louis Kottmann18:12:16

(uses tick)

πŸ‘ 3
Igor Garcia13:12:11

Just a quick tip (as a user) - I personally don't like when apps do that. I even have JS tweaks to replace the "... ago" on github. So please remember some people might not want that "feature". So I'd add that as an configurable option.

Louis Kottmann18:12:27

I use it for knowing how long ago an app was deployed, and my users are my employees so it's fine ^^


Hello, i have to develop web app with clojure (API) + vue.js. Is there any framework that nearly equal to express.js? Are Ring + http-kit recommended? I haven't completely read about them yet. The project is relatively small only crud stuffs and user administration.


Clojure tends to prefer composing libraries over using frameworks. compojure-api is probably a good place to start looking if you want to build an API. Pretty much all the web libraries in Clojure are based on Ring. The default adapter is the built-in Jetty web server and that's a good, solid choice for production usage.

❀️ 3

@raefaldhiamartya We have used both Jetty and http-kit at work. They're pretty much interchangeable although http-kit claims to be faster -- but most monitoring/observability solutions out there work much better with Jetty (we ended up switching from http-kit to Jetty because we use New Relic and it doesn't work very well with http-kit).


okay, thank you very much!

MichaΓ«l Salihi03:11:59

@raefaldhiamartya You can also take inspiration here There is 4 Clojure implementations including a recent one I did with the Ring Reitit stack.


Pretty useful, thank you!

πŸ‘ 3

Ok I have the stupidest thing that I've been staring at for too long...


Syntax error compiling at (/tmp/form-init9098034618826095313.clj:1:73).
No namespace: devbots.bots.vacation


ls -l src/devbots/bots/vacation.clj
-rw-rw-r-- 1 stefan stefan 1538 Nov 27 18:15 src/devbots/bots/vacation.clj


head src/devbots/bots/vacation.clj
(ns devbots.bots.vacation
  (:require [ :as events]
            [devbots.github :as github]
            [devbots.macros :as macros]
            [java-time :as jt]))


(ns devbots.dispatcher
  (:require [taoensso.timbre :as timbre :refer [info]]
            [taoensso.carmine :as car :refer [wcar]]
            [taoensso.carmine.message-queue :as mq]
            [clojure.core.cache.wrapped :as cache]
            [ :as events]
            [devbots.util :as util]
            [devbots.bots.vacation :as vacation]
            [devbots.bots.lock-issue :as lock-issue]
            [devbots.bots.lock-pull-request :as lock-pull-request]
            [devbots.bots.needs-triage :as needs-triage]
            [devbots.bots.needs-review :as needs-review]))


That is where it fails ...


The file is in the right place with the right name with the right ns .. so wth


OMG ... I had a test/devbots/bots/vacation.clj which I just renamed to vacation_test.clj (it did have the right devbots.bots.vacation-test namespace though

duckie 3

(rubber-duck debugging: figuring out the solution, just by explaining it to someone else)


being a lone coder is not always easy


i do think out loud, but writing it down usually helps better πŸ™‚


I hear ya! Although I have a team mate, we've always worked remotely, so we're both almost "lone coders" πŸ™‚


Clojure is a side project for me ... work is all Kotlin πŸ™‚


Kotlin is nice. Better than Java or Scala πŸ™‚


I don't even write Kotlin actually - I'm managing the team, not writing code πŸ˜‰


coders gonna code


Maybe I should find a Clojure job and get paid to do this


Some of my roles have involved more management or more architecture than actual coding -- that's when my OSS projects get a lot more attention! When work is heavy coding, my OSS projects take a back seat. I just have to code to stay sane πŸ™‚


Clojure tends to prefer composing libraries over using frameworks. compojure-api is probably a good place to start looking if you want to build an API. Pretty much all the web libraries in Clojure are based on Ring. The default adapter is the built-in Jetty web server and that's a good, solid choice for production usage.

❀️ 3

Thanks @seancorfield! I will look into the code. πŸ™‚

Louis Kottmann20:11:47

for the "time ago" thing, I ended up (painfully) writing this


I see logging is still the same mess I remember it was


@st3fan After a lot of back and forth at work, we ended up settling on and log4j2 (and setting the JVM option


(and using the log4j2 adapters to pipe all the other logging libs through it)


;; use log4j 2.x:
    org.apache.logging.log4j/log4j-api {:mvn/version "2.13.3"}
    ;; bridge into log4j:
    org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-jcl {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-jul {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.3"}


Right now I see Jetty and my own logging end up in different formats in the console ..


Yup, another reason to bridge all logging into one place.


This sounds like something I should pour at least an hour into to understand and get right

nate sire20:11:21

is Clojure considered a really expressive language? meaning... can represent almost any algorithm or idea.


yes and what the foundational clojure forms cannot express well you can build with macros and functions


Can someone help me understand why this throws an error?

((fn [start stop]
   (loop [start start
          stop  stop]
     (if (start >= stop)
       (recur (inc start)
              stop)))) 1 4)


because (start >= stop) should be (>= start stop)


oh my goodness :man-facepalming:


or maybe <= i also get confused with the notation πŸ™‚


no worries, earliet today i typed something like (defun something [] (return 123)) πŸ™‚


i keep being oblivious to that from time to time


i find it specially hard when switching between languages

πŸ‘ 3

yeahh, i think everything clicks but conditionals tends to be something i skip over


I suppose I also need to understand how to read clojure error messages better - couldn't tell what error my line was on. So i thought the issue was with recur


here's a question of specs and namespace s:


I defined:

(ns minimal.spec
      [clojure.spec.alpha :as s]))
(s/def ::my-spec ...)
and in the main file:
(ns minimal.core
      [clojure.spec.alpha :as s]
      [minimal.spec :as spec]))

(s/conform :spec/my-spec ...)
but I get
unable to resolve spec: :spec/judgement
what's going on?


@meditans You need ::spec/judgement so the alias is auto-resolved.


(you have a single : instead of a double ::)


thanks @seancorfield (I can't wait to see your talk on the repl btw). But why do I need to autoresolve that? isn't :spec/judgement equivalent to :minimal.spec/judgement given my import? I was under the impression (maybe wrong) that :: added the current module


(I mean, it works, but I can't see why)


No. :foo/bar is always just :foo/bar. But ::foo/bar will expand an alias foo into its namespace.


In the same way that ::bar expands to :current.namespace/bar


I see, so without the :: there's no namespace substitution! Thanks! Where can I find the complete semantic of ::?


I was just looking on for that... I suspect it might be in the Reader section...

seancorfield23:11:27 (and the following section about namespace map syntax) touch on it -- but don't really show aliases being expanded...


Oh, they do give an example further down in the namspace map syntax section!


I see, thanks for the pointer πŸ™‚