This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-02
Channels
- # announcements (14)
- # beginners (133)
- # cider (27)
- # cljs-dev (7)
- # cljsjs (13)
- # clojure (105)
- # clojure-dev (58)
- # clojure-italy (1)
- # clojure-nl (17)
- # clojure-russia (33)
- # clojure-spec (5)
- # clojure-uk (154)
- # clojured (1)
- # clojurescript (35)
- # cloverage (4)
- # cursive (35)
- # datomic (58)
- # duct (8)
- # editors (9)
- # emacs (15)
- # events (1)
- # figwheel (47)
- # figwheel-main (132)
- # hyperfiddle (5)
- # immutant (29)
- # instaparse (21)
- # luminus (3)
- # off-topic (5)
- # onyx (5)
- # overtone (5)
- # pedestal (8)
- # re-frame (7)
- # reagent (6)
- # reitit (3)
- # schema (2)
- # shadow-cljs (178)
- # spacemacs (49)
- # specter (2)
- # sql (1)
- # tools-deps (110)
Can I do an update
that puts the value in another key in a simple way?
@caleb.macdonaldblack mean nested?
like if I had a key called :ten
and I wanted to add 5 and call it :fifteen
Nah I still want :ten
(assoc m :fifteen (+ (:ten m) 5))
Hey, Clojure! You have officially reached maturity. From an HN “who’s hiring?” listing: “some of our legacy code is in ClojureScript”. 🙂
I’ve created a protocol that strips out branches of data structures that end in something which registers as true
to empty?
.
It blows up when I feed it UUIDs. Why is this? I thought java.lang.Object
was a kind of catch-all.
https://gist.github.com/eneroth/81fe5acf0aab82c355889f28887e08ca
Well, I mean “not empty?
.”
Oh, weird. Why does java.util.UUID
end up matching on clojure.lang.PersistentVector
or clojure.lang.PersistentList
?
So, I need something sort of like empty?
, but more resistant to things it doesn’t recognize.
empty?
is meant for collections. Perhaps if a spec were written for it the coll
argument would indicate such somehow.
@U0670BDCH Good idea!
(defn safe-empty?
[thing]
(if (seqable? thing)
(empty? thing)
false))
Is somewhat less painful to look at.Yeah, I know @U04VDQDDY. I’m really looking for something that will return true for anything that’s known to be empty, and false otherwise.
@U06BE1L6T A good conditional is an absent conditional
@henrik I think what you want could be done more concisely as something like (clojure.walk/postwalk (fn [x] (cond-> x (map? x) (medley.core/filter-keys #(not (nil? (get x %))) input)
Thank you! 🙂 Not quite—walk/medley:
[{:moose-says "blaaargh",
:giant {},
:elf {:can-see "bridge"},
:elf/thinking-of
[#:item{:pastry "cake"} {} #:location{:land "home"} {}],
:elf/hat [{}]}]
strip-nil:
[{:moose-says "blaaargh",
:elf {:can-see "bridge"},
:elf/thinking-of [#:item{:pastry "cake"} #:location{:land "home"}]}]
@lilactown I know @seancorfield doesn't 🙂 I don't really see the point in doing so anymore.
I’m not sure I completely understand the pros and cons. I know it improves startup time - is that it?
it allows you to have a concrete classfile which can be useful when interopping from java in certain cases
I used to AOT everything, but that causes problems. Especially if you are releasing libraries. AOT as little as possible, usually just the main class if you need one. I just stopped AOTing my main class for my big project, and now instead boot it with java -cp uberjar.jar clojure.main -e '(do (require 'main.namespace) (main.namespace/main))'
fyi you can replace that with java -cp uberjar.jar clojure.main -m main.namespace
except main has to be -main for that to work... I misread :D
it doesn't need gen-class (you are using clojure.main), but clojure implicitly looks for a -main when you use -m
Problems I've seen: functions whose spelling differs only by case collide when compiled on a case-insensitive filesystem; dependency cycles in namespaces cause interfaces or record types to be reloaded multiply, so that two pieces of code reference different versions (sometimes the cycles are caused by REPL tooling which wants to reload things), macros which are expanded based on system or features present create compiled code that doesn't work on other machines.
yeah, I kind of just realized that since I’m using Docker anyways - not even much point to packaging it in an uberjar 😛
we don't AOT. We deploy to docker containers in ECS. We have about 15 seconds of startup time, followed by 25 seconds of downloading data slugs until the healthcheck succeeds.
We used Elastic Beanstalk ages ago, and were really put off by the inability for us to debug the damn thing. We couldn't just ssh on and prod it.
We've built our own rolling deploy stack on EC2/CodeDeploy, and it's showing weaknesses in AWS.
uberjars are nice for getting all your dependencies in one file and having a SHA256 hash of it for tracking what's running.
I’m interested in understanding what benefits AOT can provide though. like I get the startup time (which is non-negligible IMO) but wondering if there’s any other performance benefits
If you AOT && do direct linking, which isn't enabled by default, you'll get peak performance improvements.
yeah, I guess one downside to deploying just a docker image is that your container needs to download all dependencies before startup
@lilactown you could make a Docker image with all of your dependencies baked into it that your builds make their images from
that way you just need to rebuild the base image whenever your dependencies change instead of every time someone commits something 😛
boy, I did not understand the terms going into this conversation! :rolling_on_the_floor_laughing:
FROM openjdk:10 as jdk
RUN jlink \
--strip-debug \
--compress=1 \
--vm=server \
--output /tmp/linkedjdk \
--add-modules
# multistage docker build
FROM debian:stretch-slim
COPY --from=jdk /tmp/linkedjdk /jdk/
COPY app.jar /app/
ENTRYPOINT ["/jdk/bin/java"]
nice! I’ve been using the clojure:alpine images and have gotten about the same size
true. I haven’t had any need to update yet; I’ll might have to do that soon though, so then I’ll probably copy what you’re doing 😄
Graal native-image is cool, but it imposes severe limitations that the community rarely mentions
yeah it's not for everything, but right now i'm messing with serverless stuff and it's great for that.
yeah I went down the GraalVM rabbit hole a month or two ago. it’s fun but unwieldly
This interesting, it seems like jaotc
would make for a pretty good speedup in initialization, while also allowing dynamism?
An alternative idea for native-image
would be to make a subset of the clojure language runtime which doesn't make use of java's dynamic invokation
Yeah, I knew that dynamic invokation didn't work in graal-vm's native-image. It's a bummer to learn that it doesn't work in in jaotc as well 😞
In your experience, does it seem like jaotc has better support in a windows environment?
Could I compile my application with java.base to significantly improve runtime initialization?