This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-22
Channels
- # announcements (1)
- # beginners (109)
- # boot (2)
- # calva (26)
- # cider (6)
- # circleci (6)
- # cljsrn (3)
- # clojure (77)
- # clojure-dev (5)
- # clojure-europe (28)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (21)
- # clojure-japan (13)
- # clojure-nl (36)
- # clojure-spec (22)
- # clojure-sweden (4)
- # clojure-uk (105)
- # clojurescript (91)
- # community-development (8)
- # cursive (60)
- # datascript (3)
- # datomic (4)
- # emacs (33)
- # fulcro (19)
- # graalvm (38)
- # hoplon (4)
- # instaparse (1)
- # jobs (1)
- # leiningen (22)
- # off-topic (14)
- # pathom (2)
- # perun (4)
- # planck (5)
- # re-frame (10)
- # reagent (1)
- # reitit (11)
- # rum (11)
- # shadow-cljs (97)
- # tools-deps (82)
- # vim (53)
the first one is a literal, and is not evaluated; that's what the single quote is for --- it's like saying (quote `~x)
Can you walk me step by step through how (quote (quasiquote (unquote x)) and (quasiquote (quote (unquote x)) eval to different things ?
has anyone done any benchmarking on moving from regular maps to defrecords? I know they’re theoretically faster, but I’d like to have some numbers and performance characteristics
They’re not necessarily faster. They are faster in certain ways, so it really depends on your use case.
For instance, records don’t do structural sharing. Depending on your mutation pattern, this could mean using a lot more memory and affecting gc. It’s hard to test that in a micro benchmark.
Construction and access is usually faster. Mutation creates a new object, which may be slower, I really don’t know. Probably depends on number of fields.
Well, access of known fields is probably faster. Access of extra fields is probably slower (since it’s really map access plus a field lookup).
If you really want to know how it affects your particular app, you probably just have to try it.
yeah, but that takes a lot of work, since you have to refactor all the places where you access the known keys, so I wondered if there’s already some research done on this. until I know more, I’ll probably won’t change anything
well like I said, it's entirely dependent on what you're doing, so there can't be any research that applies to /your app/
I know, but there can be research that describes certain scenarios and heuristics. if the win is only a few nano-seconds I won’t bother
well, that doesn't exist
I've microbenchmarked various things in the past, but that doesn't tell you gc effects etc
for example rewrite-clj has a lot of defrecords, but when you replace the children
of a node, it creates an entirely new object. that hadn’t occurred to me. so the benefit isn’t clear at all here
While running lein release from Jenkins the vcs push part does not work, git considers the repo to be in a detached HEAD state
@todo my understanding is
1. tilde
is a syntax-unquote, backtick
is a syntax-quote, apostrophe
is short for quote
special form
2. first check for `~ those cancel each other out (syntax- quote/unquote)
3. ` stops evaluation and namespaces
4. ' stops evaluation
When I connect to a closed socket, it throws a connection exception, but with a syntax error. Why does this happen?
Syntax error (ConnectException) compiling at (/private/var/folders/_m/m545vvvx28j2x50v81pjs3bh00l3wz/T/form-init4854649086981149918.clj:1:125).
Connection refused (Connection refused)
anything that happens while loading forms (top level of source, top level of repl) will often be reported as a syntax error
eg. (def foo (/ 1 0))
is a syntax error because the divide by zero happens while compiling foo
user=> (def foo (/ 1 0))
Syntax error (ArithmeticException) compiling at (REPL:1:10).
Divide by zero
form-int*.clj usually means lein was doing something at the top level of a namespace, you probably shouldn't be doing anything with sockets inside def or the top level of a namespace
Hello all, I´m trying to use clj-time to print local time, but it always get UTC time, I tried use (f/unparse (f/formatter "yyyyMMddHHmmss") (l/local-now))
and (f/unparse (f/formatter "yyyyMMddHHmmss") (t/now))
but no success. How does it work?
Use the new cljc.java-time from Clojure/North: https://youtu.be/UFuL-ZDoB2U
Can also do (zdt/now (ZoneId/of "US/Hawaii"))
Or clojure.java-time
that has existed for quite some time
(! 504)-> clj -Sdeps '{:deps {clojure.java-time {:mvn/version "RELEASE"}}}'
Clojure 1.10.0
user=> (require '[java-time :as jt])
nil
user=> (jt/zoned-date-time)
#object[java.time.ZonedDateTime 0x6d67f5eb "2019-05-22T12:14:41.190-07:00[America/Los_Angeles]"]
user=> (str *1)
"2019-05-22T12:14:41.190-07:00[America/Los_Angeles]"
user=>
Either way, I'd highly recommend using a Java Time based solution, like either of those or just raw Java Time with interop, instead of clj-time
(and I'm one of the clj-time
maintainers -- that library, and Joda Time, has been superseded by Java Time).
I tried this (.toString (org.joda.time.DateTime/now) "yyyyMMddHHmmss")
and works, it´s better using java-time?
And just to be clear @fabrao you don't need a Clojure library at all for this:
user=> (java.time.ZonedDateTime/now)
#object[java.time.ZonedDateTime 0x2a448449 "2019-05-22T13:23:03.927-07:00[America/Los_Angeles]"]
user=> (str *1)
"2019-05-22T13:23:03.927-07:00[America/Los_Angeles]"
user=>
@seancorfield Thanks for information
That's baked into Java from Java 8 onward. Which is a big part of why Joda Time is considered deprecated -- Java Time was the "next gen" of Joda Time, designed by the same folks.
And here's the formatting in full, if you need it:
user=> (.format (java.time.ZonedDateTime/now) (java.time.format.DateTimeFormatter/ofPattern "yyyyMMddHHmmss"))
"20190522132639"
user=>
(and you can use :import
to clean that up, rather than typing out the package names each time)
Yeah, and the use of a single-segment namespace java-time
is awful too.
but like @seancorfield says, everything you need is already at hand
I suspect it's "pushback" against the everything.core
convention that Leiningen accidentally gave us all those years ago? 🙂
what's a "single-segment namespace"?
meh I don't know what it comes from, the namespacing advice/suggestion has been there for 10 years
@nbtheduke when you have a namespace named foo
date-clj
is another one you can hate on 🙂
you don't have to go "full Java" by doing com.noah.whatever.foo
but namespacing is there for a reason
And date-clj
's coord is date-clj/date-clj
🙂
what could possibly go wrong
(personal opinion: lots of projects that do this aren't worth using for other reasons.)
Yeah, don't get me started on that one...
anti-contrib ?
But it's not really surprising people put clojure
or clj
or cljc
or cljs
into namespaces and/or artifact names given that they have a single concept in mind and it's for Clojure 🙂
I called next.jdbc
that because it's the "next generation" of org.clojure/java.jdbc
/ clojure.java.jdbc
but I didn't want to imply "authority" via clojure
unless it ends up in Contrib and that's looking less and less likely at this point (I have CircleCI and cljdoc in place so most of the benefits of Contrib are accounted for).
I agree that thin wrappers have limited value, but you may wish to check out the video for cljc.java-time
. It is a cross-platform clj/cljs implementation that avoids the js/Date
problems. The clj part is auto-generated wrappers of java.time
, so that is simple & convenient. The cljs part is a re-implementation of most java.time
classes, and does not use js/Date
at all. See Clojure/North video for details: https://youtu.be/UFuL-ZDoB2U
hey, does the clj repl support tab completion for namespace members? i know the lein repl does, but it doesnt seem to work when i use clj -r
no, the clj tab completion is very rudimentary
you can check out rebel-readline for a minimal terminal style thing https://github.com/bhauman/rebel-readline