This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-26
Channels
- # aatree (1)
- # admin-announcements (1)
- # beginners (84)
- # boot (239)
- # braid-chat (5)
- # braveandtrue (20)
- # cider (42)
- # cljsjs (4)
- # cljsrn (31)
- # clojars (18)
- # clojure (101)
- # clojure-austin (1)
- # clojure-gamedev (4)
- # clojure-madison (2)
- # clojure-poland (30)
- # clojure-russia (37)
- # clojurescript (95)
- # core-async (7)
- # cryogen (1)
- # css (3)
- # cursive (14)
- # datomic (8)
- # devcards (7)
- # dirac (2)
- # editors (2)
- # emacs (2)
- # funcool (1)
- # hoplon (15)
- # immutant (30)
- # ldnclj (37)
- # lein-figwheel (6)
- # leiningen (8)
- # luminus (5)
- # mount (1)
- # off-topic (59)
- # om (325)
- # om-next (7)
- # onyx (95)
- # parinfer (162)
- # proton (1)
- # re-frame (4)
- # reagent (23)
- # slack-help (4)
- # yada (43)
I've read in some places there's a negative sentiment toward macros
, what's your experience with using them?
Well, we have about 30k lines of Clojure... over 2k functions... about 350 Vars... and only 10 macros.
That's our production code base.
Macros are good for syntactic sugar when the underlying function call looks a little weird.
For example, we have a with-retry
macro that let's us retry code that might throw occasional exceptions (mostly around 3rd party services) and automatically performs exponential backoff.
so (with-retry :ms 500 :limit 6 (some-func with args))
will run the body up to 6 times, with an initial 500ms delay and an exponential backoff... under the hood, it would be (retry* 0 (fn [] (some-func with args)) :ms 500 :limit 6)
@josh.freckleton: I'd say to always try to solve something with functions, and only add macros when you need to clean up the syntax.
@seancorfield: good to know, this weekend I'm committing myself to learning them more thoroughly, but if they're mostly good for syntactic clean up... maybe not so important?
It's good to really know macros but they're much more rare in production Clojure code than you might think...
One of the real problems is that macros don't compose like functions.
it's important to understand macros and be able to write them when needed. A good macro can make a huge difference, e.g. the fnk
family: https://github.com/plumatic/plumbing/blob/master/src/plumbing/core.cljx#L384
@jarodzz: assoc!
is only for transients, which are special and for optimization. Don't use them unless you identified your function to be too slow. Usually you should use assoc
and "standard" data structures.
@rauh: got it. i was reading group-by in core lib, saw this. wandering why he choose assoc!
@jarodzz: Many clojure.core
functions use it to optimize performance. Also some libraries use it but by default application code doesn't usually use transients unless identified a bottleneck.
How can I make this more idiomatic:
(map (fn [one two] [one two])
(take-while (fn [] true) (repeat :id))
'(:one :two))
tried lein kibit but to no avail đhi guys I just forgot that there is a function in clojure that helps with this operation. For example : I have this vector [{:type :a :another "a"} {:type :a :another "a1"} {:type b :another "b"}]
then after running that function, it returns something like this {:a [{:type :a :another "a"} {:type :a :another "a1"}] :b [{:type b :another "b"}]}
. Any hint would be appreciated
hello #C03S1KBA2!
question about transducers and core.async⌠If I have a comp of map, filter, etc, and I pass that to a channel (chan 1 xform), it it weird if one of the map fns syncs some data to a database?
or should I pipe some channels together and keep my âpureâ channels and âdirtyâ channels separate?
I would avoid side effects like that in a transducer
For one, a database can do all kinds of strange stuff that is beyond your control
I would think it would be better to control the flow explicitly into your database anyway rather than letting the transducer do it even though the transducer is less code
if you do elect to keep it as a transducer, at least pass the exception handler so you can deal with anything that blows up. Not sure in your case if you can leak resources like connections given your code, but just be aware.
Iâm going to take a look at putting my âpureâ transducers on my source channel, then mult that channel for a) syncing db-state and b) any further âpureâ transducers
I'm trying to make a leiningen plugin that accesses resources in the project running it, but
from within that plugin refers to the resources dir of the plugin's jar rather than the including project. Is there a way that I can access the running project's context from this plugin?
I see that
can take a classloader, but I'm unsure how to get the classloader of the host application from the plugin.
Conversely: if I'm overcomplicating things, I'd love to know other ways of turning a resource-relative path to a file in the host application into a resource/file/uri that the plugin can manipulate.
ah, derp. just found https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md#evaluating-in-project-context which seems to be what I want.
Anyone else using Emacs Cider on OS X? It used to work great but today cider-jack-in gives: "cider-project-type: Symbol's function definition is void: closure-project-dir". Any ideas for fixes?
nkraft: closure with an s?
'closure' implies something to do with ClojureScript compilation (& the Google Closure Compiler)
there's also #C0617A8PQ
Which is a better approach to develop in clojure luminus or immutant?
@rnandan273: luminus has immutant as its default server
As an update to my above question, eval-in-project
didn't actually make
aware of the host project's classloader. I was, however, able to pull the project's root path from the leiningen project's :root
key and just construct paths using
.
@tolitus Thanks
@rnandan273: sure, good luck
@vptheron: Yes, it's really good (but not a beginner book)
@vptheron: utility depends on what you're looking for, but it's an exceptionally well-done book
lots of sample material on the website to evaluate
@shaun-mahood: @jonahbenton my understanding is that itâs very hands-on, compared to other books that are really focusing on the language itself, while this one is really about how to get things done
thatâs something I miss a lot from the books I already looked at (Clojure in Action, and Clojure for the Brave and True)
they are awesome to understand the syntax and the tools, but not how to apply them effectively
yes- take a look at this sample: https://media.pragprog.com/titles/vmclojeco/data.pdf
@vptheron: Oh yeah, if you've gone through those books already then Clojure Applied should be great for you.
@tolitius: When i do this using luminus lein new luminus test-proj +immutant Unrecognized options: +immutant Supported options are: +sqlite, +site, +h2, +jetty, +cljs, +sassc, +swagger, +auth, +war, +http-kit, +cucumber, +aleph, +mongodb, +postgres, +mysql, +kibit
@tolitius: I am coming from this page http://yogthos.net/posts/2015-07-11-Luminus-HTTPKit.html
@rnandan273: immutant
is a default server, so you don't need to specify it
i.e. check your project.clj
, you should see the immutant
dependency after lein new luminus test-proj
@tolitius: So you suggest adding immutant-messaging under dependencies and using it
@rnandan273: probably best to take it to the #C077KDE3A channel
Hey, I would like to add a pom file as a dependency but it is not on maven although the jars it points to are. Specifically I am going for this: https://github.com/MysterionRise/mavenized-jcuda/. I want to either use that pom file or duplicate it into leiningen so I can build a cross-platform project with native dependencies on the various cuda sub-libraries.
I am a bit baffled by how to do this so far. I guess I would like to put that pom in my resources and then use it in my dependencies but it isn't clear how this would work.
nm, it looks like that won't actually work because those cuda binaries aren't in maven...
@chrisn are you building an application, or a library?
I switched to actually building them with cmake and mvn. This path is probably more robust as we have mac devs and such and this way they can build what they need.
Is there a list anywhere of good open source projects to use as references for high-quality in-the-wild code? I know of a bunch of individual projects but was wondering if anyone is maintaining a list of them.
I once saw a library on github that someone had written for parsing Clojure-code written without the parens - based solely on the indentation.
Does anyone know where to find this?
@reefersleep: I don't know of that per se, but someone on this Slack is working on an editor that does that sorta
it's set up to convert the editor's parenless code to the user's choice of clojure or js
oh, I was wrong -- it also includes standalone parsers, not just the editor
Can't tell whether it's the same as what I found, but it's interesting none the less!
Anyone have a good strategy for going to/from other formats/languages, for example when calling a Scala or Java api? I have a protocol which dispatches on type, and while it works, I'm not so happy with the calling conventions all over the place. In some key places, I did stick in things like in the case of serializers/deserializers which handles all this transparently from a single call, but that doesn't work well sometimes when more custom behavior is needed. I'm trying to avoid something like this in every single wrapper call I have to some other APIs: ->> x (encode) (foo) (bar "something") (decode)
actually better to write -> x (encode) (.foo) (.bar) (decode) since these aren't clojure functions
anyway, it all works, but feels wrong. I could wrap some functions with pre/post calls but like I said, it's not always just encode/decode, but might help somewhat I guess