This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-04
Channels
- # architecture (5)
- # aws (11)
- # aws-lambda (1)
- # beginners (108)
- # boot (11)
- # cider (37)
- # clara (19)
- # cljsrn (72)
- # clojure (170)
- # clojure-austin (2)
- # clojure-dev (1)
- # clojure-dusseldorf (2)
- # clojure-italy (1)
- # clojure-spec (41)
- # clojure-uk (24)
- # clojurescript (113)
- # component (2)
- # core-async (29)
- # cursive (9)
- # data-science (5)
- # datomic (72)
- # docs (23)
- # duct (61)
- # editors (1)
- # emacs (1)
- # events (5)
- # fulcro (77)
- # graphql (2)
- # hoplon (4)
- # jobs (3)
- # jobs-discuss (16)
- # leiningen (5)
- # off-topic (94)
- # onyx (37)
- # precept (5)
- # re-frame (17)
- # reagent (11)
- # shadow-cljs (18)
- # spacemacs (107)
- # specter (3)
- # unrepl (64)
- # yada (1)
Hello everyone, I'm just starting to learn clojure and I'd like to ask if anyone is doing some kind of work on mathematics, like optimisation or even calculus. It's hard to find mathematically inclined C.Scientists...
anyone have experience with any oauth1 client libraries? i.e what did you like or dislike
RFC is better for you to understand the protocol. https://tools.ietf.org/html/rfc6749
Any admin for the https://dev.clojure.org JIRA instance here? Looks like it's getting spammed. https://dev.clojure.org/jira/secure/ViewProfile.jspa?name=jennyhannb
I’m on it
Hi Folks, any idea how can I automatically have (reset)
run on file changes? e.g. how to configure file watch so it resets the duct or stuart sierra system for me?
@lambder I guess you can use https://github.com/wkf/hawk as mentioned here: https://github.com/duct-framework/duct-figwheel-component/issues/1
I'm implementing a service against 3rd-party XML parsers which are strict and require elements to be output this way:
While moving from data.xml 0.0.8 to 0.2.0-alpha5 it seems it's no longer possible, or am I doing something wrong?
is there something like this in clojure?
(cond (foo x) {:type :foo :value (foo x)} (bar x) {:type :bar (bar x)})
where (foo x)
can be bound to a name?
Kind of like (let [f (foo x), b (bar x)] (cond f {:type :foo :value f} ...))
@borkdude https://github.com/clojure-emacs/cljs-tooling/blob/master/src/cljs_tooling/util/misc.clj#L7
and usage https://github.com/clojure-emacs/cljs-tooling/blob/master/src/cljs_tooling/info.clj#L64
@borkdude core.match also has a thing for that: https://github.com/clojure/core.match/wiki/Basic-usage#binding
Hi, I'd like to know which the correct way to implement something like. This snippet works in the begining for some time, but then, after random time, at/every
does not call its callback . I've tried to debug put prints, try/catch blocks. I have this handler.clj deployed in heroku. Thanks in advance
reposting my question from #off-topic: does anyone know any good resources about Java 8 streams and Java Spliterators, and if/when/how they can be used in Clojure?
Yeah, @tomaas, are you on the free tier in Heroku? If so, the dyno running your app might just be asleep. If you load the page (causing the dyno to boot up), does the callback start happening again?
no it does not, cause @data
is not nil (just returns outdated @data
value). I have free version, but the apps's client-side (cljs) makes a long polling to that route every 5 min, so it never goes to sleep (as least heroku states that sleeping mode starts after 30 min of no requests).
Accounts are given a base of 550 hours each month in which your Free dynos can run. In addition to these base hours, accounts which verify with a credit card will receive an additional 450 hours to the monthly Free dyno quota.
(calling clojure.core/read-string on user input is usually a bad idea, use clojure.edn/read-string)
when you say you tried to put debug prints and try catch blocks, what does that mean? what did you do and what was the result?
(try #(...) (catch ...))
or #(try ... (catch ...))
? what exception types were you catching?
if you replace the user of at/every with (future (while true ... (Thread/sleep (* 60 1000 5))))
what happens?
thanks @hiredman, didn't try this way, maybe then it's that libs stuff. I deployed the future snippet version, so let's see if it does not stop after a period of time 🙂
It's been a while since I've had the chance to build something new. I'm building out a new api, does anyone have any preferences for liberator / pedestal server / anything else?
@petr I prefer to keep things simple with just Ring / Compojure (I haven't used compojure-api but that is probably still "simple"-ish).
Maybe I'm being stilly. I just like the way pedestal server works with middleware. I like how the interceptor layer is done
pedestal and liberator work together well, btw.
liberator creates a ring handler, in the end wich you can mount with pedestal and still attach interceptors…
@petr, no liberator doesn’t do routing.
@seancorfield may have the correct approach though
Using a multi method as a point for e.g. Choosing an action to take in response to an event doesn't seem to work with dependency injection. The caller always ends up needing to know about the stateful methods, in order to let them query the appropriate services, with the correct api keys, etc.
@petr I'm using duct framework and it's awesome https://github.com/duct-framework/duct/blob/master/README.md https://skillsmatter.com/skillscasts/10836-productive-duct
You take the configuration out of the code and put it in a data structure, letting your focus on your code, it's opinionated, but it's well designed for APIs. Made by the same creator of compojure https://github.com/weavejester
It has some batteries included
It can be used at the place of Component from Stuart Sierra
o/ any hard time using it, PM or mention me, I have some test code that can be shared using duct, you're welcome
I'm trying to make my comojure handler functions reloadable, I notice that when I use the routing DSL as follows, the var handler-a, handler-b, handler-c are derefed to the function and when I re-define handler-a, my changes don't take effect
(route/route handler-a handler-b handler-c)
However, if I write this using vars, the code is reloadable.
(route/route #'handler-a #'handler-b #'handler-c)
Are there performance impacts of using vars instead of functions?it's an extra pointer lookup
it's just a pointer lookup and a method call
there's literally nothing else
also to be clear, when you have (defn foo [] (bar x))
it does the same lookup on bar
this is already happening everywhere in your code, repeatedly, ubiquitously even
gotcha, thanks! i think I was caught offguard why compojure's route doesn't have the same indirection -- i probably have to poke around the source code to understand, thanks!
it's because function arguments are resolved before being passed to the function
it's effectively a cached value - to see a new one you would need to call the function again (which means restarting your server, right?)
if you had (future (while true (foo)))
vs. (future (while true (#'foo)))
you'd see the same discrepancy - the difference is that using the var means it dereferences on each call without running the whole form again
an alternative is to use a system like duct or stuartsierra/component to shut down the http server then restart it with your new code without doing a restart of the clojure process
Hi all. I'm interested in picking up Clojure this year. I'm coming from a background of really appreciating statically typed languages, but find Rich's argument about dynamic typing very compelling. Could anyone point a newbie to some writing that might illuminate Clojure's design philosophy (as it applies to people writing Clojure, not so much Clojure itself)?
everything in the About section on the official homepage is worth a read: https://clojure.org/about/rationale
here is another one of my favorite Clojure talks which contrast a classic Java OOP design with a more Clojure-y design: https://www.youtube.com/watch?v=Tb823aqgX_0&t=1s
@noisesmith yeah, i'm definitely using that strategy at the moment, i'm looking at ways to reduce the feedback cycle more 😄
@petr I like yada a lot. https://twitter.com/borkdude/status/857979807358910464
I was surprised to find out that clojure.core/some
isn't implemented with reduce
. I.e.
(defn some2 [pred coll]
(reduce #(when-let [ret (pred %2)] (reduced ret)) nil coll))
It's quite a lot faster than the current implementation, and I'm wondering if it'd be a good enhancement?
maybe, but need to analyze the bootstrap order - reduce and reduced might not be defined yet
but feel free to file a ticket with a patch if you get something workable (may be able to move some
around, depends on what else depends on it)
we also do redefinitions in some cases once we have better stuff
> we also do redefinitions in some cases once we have better stuff Yeah, I noticed that in a few
I guess the good part is if you need to write one of these things to be more performant for some usage, it isn’t typically too difficult
@alexmiller I'll create a ticket then, thanks
I realize this is an exceptionally broad question, but what domains does Clojure get a lot of use in? Of course I realize it's a perfectly good general-purpose language, but is there any domain where it's seen a lot more success than in others?
@zack.mullaly There’s a decent amount of Clojure being written in the financial services/fintech space.
I've used clojure for server side of web apps, sometimes with clojurescript on the frontend to go with it
There's been some talk of people using Elixir these days for distributed systems. Am I correct in thinking there are ways of going about doing fault-tolerant systems in Clojure?
Check out #onyx
elixir has the erlang vm which has really light weight threads, which allows all types of cool OTP patterns; it's hard to do that on clojure
clojure doesn't come with inter-process stuff baked in the way erlang does
erlang vm processes's are so damn cheap, (I think 4kb overhead / process?) that you can do all type of nifty things
and they can transparently collaborate across vms and even hosts - clojure comes with nothing like that
it's not unusual to see a design pattern where a webserver gets a request, then FIRES UP A NEW ERLANG PROCESS to handle that one request (and the process dies afterwards), and it's fine because erlang vm processes are so cheap
I almost used erlang until I realized: in distribution, one of the hardest problems is state -- and for state, I don't want to roll my own riak cluster using erlang - I want to just use aws dynamodb . redis -- and if I'm using that, my functions can be stateless on lambda -- and at that point, I can just use clojure for lambda, so erlang buys me nothing
That's a very interesting approach. I'm in a situation where I'm not really sure where I want to direct my career from now on. I know I love functional programming and think distributed systems are really interesting to deal with, but I'm not really sure which technologies fit domains I might find interesting. With that said, I'm getting the impression that the Clojure community has a lot of great stuff, particularly since you can leverage existing Java code.
and clojure can do much better than erlang in terms of resource usage and performance if what you do involves any substantial computation or memory
the more I make distributed things though, the more I realize that distribution of systems is a liability that you take on in order to get some other property (like availability or throughput) and it's definitely not an end unto itself
in fact everything becomes a lot easier if you avoid it
futures, executor services, or core.async
if you want repeated tasks a scheduled executor service is made for exactly that purpose and they come with the jvm, there's a thin wrapping library over that called at-at
What would you say is the best way for an experienced developer to dive into Clojure and get going as quickly as possible?
check out the puzzles at http://4clojure.com - it helps you think in idiomatic clojure and comparing your answers to the ones from other people can be very informative
some of it is just code golf, but there's a lot of tricks to be learned by studying the answers there
and the standard stuff, read code, write code, fix code
authors like halgari
, weavejester
, amalloy
, ztellman
have good github repos for browsing exemplary clojure code
oh of course - if you are experienced, "Joy of Clojure" is great
Thank you so much for answering all these questions. I'm really excited to give Clojure a go.
but "clojure applied" has more pragmatic "this is how you do it at the day job" kind of stuff
if you have a java shop, it's easy to add clojure to an existing java ecosystem
hello there
I have a re-frame project and I can't get my uberjar working
here's my project.clj
https://gist.github.com/micheledv/b2d7f7eb7909adb8794a8ec73578cb11
with lein dev
compojure serves all the public files
when I launch the uberjat it only serves index.html
I tried to extract the uberjar and the files are actually included
I don't know what to do
@erhardt.mundt are you using wrap-resource to serve the files?
@noisesmith that's how I define my routes ☝️
am I missing anything?
in order to serve arbitrary resources, there's usually a middleware used
what to look out for in your case is that it's wrap-resources with the right directory root
any clue why it's working if I launch it with lein dev
?
the common cause is that wrap-file is being used instead of wrap-resource, and things inside uberjars are not files
well, FYI that's what I have right after the routes
that's not what wrap-reload is, that's unrelated
I'm just wondering how is it possible that's working with lein dev
could be figwheel depending on how things are configured
well, I'm a beginner but I find this part very confusing
@erhardt.mundt did you use lein uberjar
to make the jar, or lein ring uberjar
- depending on how your project was created / configured it might need the latter to work properly
lein uberjar
try lein ring uberjar
@noisesmith I've tried with wrap-resource
and now it works
many thanks!
I think the ring uberjar
solution might be the intended one though
one thing left is that my css file is served with text/plain
MIME type
do you know how to fix that?
hmm... no - if you don't get that problem usually try taking wrap-resource out and using lein ring uberjar
maybe... not sure off hand though
it says that ring
is not a task
OK - I wasn't sure if were using the lein-ring plugin - different project templates have different assumptions
@erhardt.mundt I don't see any content-type configuration with wrap-resource https://ring-clojure.github.io/ring/ring.middleware.resource.html but it could be you also need to add wrap-content-type https://ring-clojure.github.io/ring/ring.middleware.content-type.html
it might be because the file is empty 🙈
I'm trying some dummy CSS
haha OK
(a friendly admin reminder that this channel has over 11,500 members and there is a #beginners channel where folks have opted in to answer questions in depth -- or use threads for 1:1 conversations perhaps)