This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-03
Channels
- # beginners (48)
- # boot (26)
- # cider (7)
- # cljsrn (1)
- # clojure (137)
- # clojure-nl (1)
- # clojure-spec (5)
- # clojure-uk (18)
- # clojurescript (26)
- # cursive (8)
- # datascript (4)
- # datomic (4)
- # defnpodcast (11)
- # docker (1)
- # duct (7)
- # figwheel (4)
- # fulcro (7)
- # off-topic (7)
- # re-frame (46)
- # reagent (40)
- # reitit (3)
- # shadow-cljs (4)
so the other day I've been suggested here using emacs + cider for the best clojure workflow. learning emacs felt like travelling back several decades in time. it seems every IDE action from window manipulation to repl usage entails series of idiosyncratic keyboard combinations to be memorized and habituated. is it really worth it? what's your advice?
I use cursive (Intellij IDEA plugin for clojure), many other people do. it just works.
join #cursive if you have questions
I also enjoy cursive very much, a lot of stuff like git integration, and creating tasks works just like I'm used to in Java.
Really other than being free for commercial use, what's so phenomenal for clojure dev in emacs+cider?
personal taste, emacs love, total customization if you have years of free time
for example Cursive can't be customized in fundamental ways...just setting tweaking
And there is the atom/protorepl option which even some people coming from emacs prefer. Cursive can become a but sluggish at times.
Should I use this: https://github.com/cognitect/transit-clj#usage
if I want only to convert Clojure data structure like {:a 1 :b 2}
to JSON-transit format?
@matan idea + cursive to emacs + cider is like guitar hero to the real guitar. i guess it is easier to start with.
@matan Before emacs I've used Atom + protorepl, then tried Cursive, but because I don't like IDEs, I've decided to try emacs, spent about a week to make its shortcuts the same as I've used previously and now I'm completely happy with it. Some points: - emacs language is lisp, kinda ugly but lisp anyway, personally I feel more pleasure writing it than coffeescript for Atom - emacs changes you into workflow to keyboard-centric operations and convenient shortcuts, everything is configurable - emacs + cider gives the most deep integration of clojure into editor I've ever seen - emacs is console application(despite has gui version), so you can do stuff without leaving your terminal, and you have all that context menus/autocomplete stuff right there, also emacs can be anything, from db client to chat app - magit gives the most convenient git workflow I've ever seen
@U4BEW7F61 thanks a lot, would you have your custom config which (resembles atom?) easily exportable to share?
why I hate IDEA-style IDEs is their obtrusiveness and resources consumption, Atom/Sublime are great in that sense but don't give you so deep language integration feeling as emacs does, also neither Coffee nor Python are not languages which I'd like to use for editor customization, but elisp is closer to being that one. My ideal editor should be configured in clojure 😄
wouldn't say Atom's resource consumption is great
comparing to RubyMine few years ago I saw terrific difference, and startup time is not good for IDEA even these days, but I agree that Atom is not the fastest editor
if I write (let [[x y] [1 2]])
, does Clojure allocate a vector for [x y]
or does it unroll that into local variables at compile time?
the best way to answer that is with no.disassemble
it creates a vector - and a lot of other stuff too - even if you are returning nil
indeed
user=> (macroexpand '(let [[x y] [1 2]]))
(let* [vec__30228 [1 2] x (clojure.core/nth vec__30228 0 nil) y (clojure.core/nth vec__30228 1 nil)])
now the code to bind x
and y
you'd write manually would be the same as the one destructure emits
I've definitely seen cases where directly accessing the positional vals in a collection was computationally cheaper than destructuring
how about keys
destructuring? that seems to expands to get
calls. does get
give you maximum performance on records or do you need to use keywords for that?
@noisesmith only when you have rest arguments
ahh, OK
@schmee keywords use get under the hood - you can also destructure with :strs
or :syms
(err, not the function get, but the method get uses iirc)
so it's not the fastest way to destructure e.g. a cons list, but it's not the slowest way to destructure a vector sequentially
(which is true since https://github.com/clojure/clojure/commit/0aa346766c4b065728cde9f9fcb4b2276a6fe7b5)
@noisesmith ahh, cause get calls into RT.valAt
, which uses ILookup
, and by the looks of macroexpanding a defrecord
that seems to be about as fast as it can get 🙂
so when you're doing (:foo my-record)
it's internally there's a cache doing essentially (if (= key :foo) (.-foo my-record) (get my-record :foo)
it's a bit more involved than that since there's two levels to the optimization but it's a good approximation
which does basically (if (= (class key) __prev) (thunk key) (do (set! __prev (class key)) (set! thunk (getThunk x key)) (get x key))
thunk for :foo
being that (if (= key :foo) (.-foo my-record) (get my-record :foo))
snippet from above
I asked this in the #clojurescript channel two hours ago and got nothing, so maybe one more try: Newbie question: is there a kind of minimal front-end template or framework or concept around deploying clojurescript in a way that isn't an SPA with a lightweight backend? Clojurescript would be used here and there for this and that feature (draggable cards, &c, whatever) but the page wouldn't be structured as an SPA. Is that a thing? If it is, can someone point me in a direction?
@jtth you can include compiled ClojureScript in a regular webpage just fine. I built a Grafana plugin this way. I used shadow-cljs to compile the CLJS, then grunt to wrap it in a shadowjs module.
The main bump you might encounter is that non-optimized builds will try to include dependencies using document.write
, which is prohibited after page load. Easiest thing to do is build with whitespace, simple, or advanced optimizations
@jtth jump in the #shadow-cljs channel if you have questions on that tool. I found it easy to use, and being packaged via npm was convenient (and less scary to JS colleagues)
Does anyone know if there are idioms around retrieving items from a collection via an index? For instance, if one had a collection type that included its own index, it wouldn't necessarily make sense to search the collection with filter
if the index could be used instead.
@hagmonk I'd say ILookup is fine, but have it return an iterator or lazy collection of some sort. No reason to new up a whole collection just to hand over those values.
That's the way the Datomic API works (d/datoms db :eavt e-val) => iterator of datoms where e = e-val
@tbaldridge that's a good idea ... for context I'm writting some wrapper functionality around the IntervalTree class in https://github.com/Breinify/brein-time-utilities
I seem to remember that a few weeks ago someone released a relatively large real-world clojure/datomic app on github (I think it was for some sort of ecommerce site but I could be wrong). But my google skills are failing me and I can’t find the link - does anyone remember it?
@russell any chance it was one of the circleCI codebases? https://github.com/circleci
huh, I remember seeing this too. Could have sworn it was on /r/clojure, but cannot find it there now ...
bad time for this because demo's currently not running 😛
I looked through all projects on github, written in clojure, updated in the last several weeks, that had a string match for "datomic"
ventas was definitely the one I was thinking of, doesn't seem to be any other full stack one posted recently ...
further back is the clojureacademy site, which is not ecommerce: https://github.com/clojurecademy/clojurecademy
Maybe it was a longer time ago. I think it was maybe a european startup sort of company that exited somehow and just released their github repo? maybe it was all just a dream…
the projects posted are great to look at, can’t complain since I didn’t know what I was looking for anyway, now I’m just bothered by remembering something that doesn’t exist!
run and read the code before ventas turns into an incomprehensible monolith
Once I had the idea to add "browser friendly" endpoints to a pedestal based API server. "I'll just throw a little bit of cljs in and render a cool page that's more friendly than the browser's json plugin"
can relate, though it was worse some months ago
yeah your project.clj looks more clean than mine. I'm importing a lot of libs for java interop - which feels like organizing an arranged marriage between hostile mafia families
i feel like I can't add one more dependency without triggering chaos across my transitive dependencies
just something will break
the other day i added pomegranate and it somehow needed a more recent version of plexus utils...`lein deps :tree` didnt even print a conflict there
¯\(ツ)/¯
I was really surprised to learn how hands off leiningen is with dependency management, before this I was under the false impression that magic was happening
regarding log4j, I really had to understand its universe before taming it
so glad that I did, now, though...
now datomic logs through timbre happily!
I started using stuart's boilerplate code for that, I haven't yet swallowed the log4j / logback frog
this guy, for folks following at home: https://github.com/stuartsierra/log.dev
it produces the magical recipe needed to lift the curse of log4j error messages every time your app starts :)
invaluable then 🙂 I, apparently (according to a comment of mine in my project.clj) "redirected everything to slf4j and then redirected slf4j to timbre"
surely that must make some sense
;;TODO: Sleep
having complained about this, I went back to a ruby project and the wholesale lack of standardized logging infra is actually even more intractable than java logging
we had a splunk thingy that would give you nice structured logs if you promised to print one well-formed line of json per log event
trivial to set up in java - assuming you've come as far as we have in understanding it
impossible in ruby - several deep libraries were setting up their own Logger instances and it would have required careful engineering effort and monkeypatches out the wazoo
never did Ruby but used to do PHP - prefer not to comment
I traveled through those lands when PHP/FI walked the earth. I saw many unholy things.
it's kind of nice, they have a history page describing it: http://php.net/manual/phpfi2.php#history
I think you did! 🙂 very interesting