Watching this video, what is reified mean:
@i In general, “to reify” means “to make (something abstract) more concrete or real”.
In this case, it means to turn each possibly implicit “event” or “state change” into an explicit, concrete record of that event that is recorded.
Does that help?
Thanks.
I wonder how to publish datomic transaction with at least once semantics. Does datomic itself support this functionality?
Can you please clarify? What do you mean by “publish” ?
What's the recommended way to structure a project that's divided between "library" and "application" code? I see a lot of repos with /src and /app folders, but I want them to live in separate git repositories and at the same time share a common REPL and dependencies during development. Or is that a bad idea in the first place?
You can use lein parent and separate directories for libs and apps. Take a look at how reitit is organized. Just split the modules directory in two. I also recommend maintaining the list of libs and the list of apps in files which you can use while scripting
@ben.sless nice tip.
@qythium This can be easily accomplished using deps.edn/tools.deps :local/root which allows you to develop an app and libraries in one REPL
Oh! great that we're already using tools.deps 🙂 Do you mean something like this:
foo/
lib/
.git/
src/
deps.edn
app/
.git/
src/
deps.edn - {:deps {foo :local/root {"../lib"}}}
yes
and then I start a REPL in the app/ folder, and tell Cider to sesman-link-with-project
or I don't suppose you can specify :paths ["../lib"]
paths in the deps.edn as well
no, you're not allowed to specify paths outside of the current dir. Why do you need sesman-link. Just a REPL should be sufficient
So I can interactively redefine things in the lib/ folder while I'm in app/
yes
you can already do that
oh, you can indeed! Thanks for the help 🙂
How to change a process’s working directory?
If you mean in a running JVM process, then this StackOverflow question seems to describe some ways you can at least partially get that behavior, but perhaps not for all file accessing API calls, maybe only a subset of them: https://stackoverflow.com/questions/840190/changing-the-current-working-directory-in-java
Came across this too. Seems no easy way.
Hello all. When calling Java code from clojure, is reflection always used? I’ve come across this in my profiling: Function code: https://github.com/tel/clatrix/blob/master/src/clatrix/core.clj#L214 Profiler says it uses reflection 100% of the time:
Seems odd with all the type hints…
Matrix
is a deftype
with a field called me
.
Maybe if you use (.-me m)
instead of (.me m)
it won't use the reflection.
You might be quite right… the thing is that if I (set! *warn-on-reflection* true)
and reload the namespace clatrix.core
it doesn’t give any warnings
Are people using 🅰️ lein new
or 🅱️ clj -X new
or 🅾️ other to start projects?
Unless I missed something recently, Emacs/Cider still only knows how to launch a lein
project, not a clj
one. This is probably what keeps me on 🅰️.
I personally use a GitHub template repo 🅾️ that is mostly 🅰️ plus a few niceties (Default license, community docs, GH Actions, a few shell scripts) Professionally, same orchestration mechanic, but with 🅱️ (I found I always spent more time setting up the “other stuff” than the folder/project structure)
@cassiel Pretty sure Emacs/CIDER has supported Clojure CLI projects for quite a few releases at this point?
Oh - I found that it complained if it couldn’t find a project.clj
and I had to launch the REPL externally - but Clojure CLI is pretty major now so that would be surprising. I’ll experiment again.
(I haven’t used lein
for years at this point — but I also haven’t used Emacs/CIDER for years either 🙂 )
@seancorfield What editor do you use? I tried Cursive on Idea and Emacs/Cider and I like the debugging on Emacs/Cider. Atleast for a beginner its really helpful
@prabu.rajan TL;DR: VS Code + Clover for the Socket REPL + Calva for other features with its nREPL stuff turned off. Over the years I have used a lot of different editors with Clojure. I used Emacs for a while but found the “care and feeding” aspect of its configuration too much in the end and never settled on a Clojure-focused setup that I liked (I used Emacs on and off for twenty years, so a long time prior to using it for Clojure). I’ve never liked “IDEs” but I was using Eclipse for Java-based stuff before Clojure and using CounterClockWise for a while (pretty sure that’s no longer maintained). I’ve always disliked IntelliJ (and back when I was an active blogger, JetBrains used to send me free licenses for the commercial version in the hope I would write a glowing review!). I finally switched from Emacs to Atom/ProtoREPL after seeing Jason Gilman demo it at a Clojure conference. Then to Atom/Chlorine when that appeared — and I really liked being able to jettison nREPL and the CIDER middleware and use just a Socket REPL with zero dependencies. And finally I switched to VS Code/Clover once the Chlorine maintainer had ported the cljs-based configuration over to Clover. For me, being able to use just a plain old Socket REPL in any process — local or remote — is a requirement and that means no nREPL-based solutions.
Cool. That is a long journey! Does VS Code / Clover support the kind of debugging where you evaluate a function, the debugger recursively takes you to internal function calls, and shows each of the forms getting evaluated and the values being passed in? I will try it out though. Thanks for the recommendation and putting out your journey
I’ve never felt the need for that sort of debugger (I don’t think CIDER had that back when I was still using it?).
(I prefer very minimal tooling, in general, and like to keep close to raw Clojure — so that I have the exact same UX for developing locally as I do when debugging something remotely)
I just tried VSCode Calva with nREPL and the debugging works just as good as Emacs! I tried installing Clover as well, but couldnt figure out the usecase yet. For now, VS Code with Calva is good enough for me. Thanks
The use case for Clover is: Socket REPL. If you’re happy using nREPL, Calva is great on its own.
We're using https://github.com/cookiecutter/cookiecutter
@jayzawrotny Can I vote for: none of the above? I usually bootstrap new projects just by using mkdir -p src/foo
and writing a deps.edn
file.
I think that falls into other 😛
ok
Seems like it doesn’t make a difference:
(time (do (doall (repeatedly 10000000 #(.x ^A x)))
1))
"Elapsed time: 2543.122789 msecs"
=> 1
(time (do (doall (repeatedly 10000000 #(.-x ^A x)))
1))
"Elapsed time: 2470.688716 msecs"
And profiler still shows:it’s bizarre
If you're willing to debug the compiler, I think the relevant place is clojure.lang.Compiler$InstanceFieldExpr
.
Maybe someone else has some ideas on why you see that behavior, but I don't.
With just
(deftype X [a])
(def x (X. 1))
(.-a ^X x)
I get the compiler to not use invokeNoArgInstanceMember
.Yeah but as soon as I do this:
(time (do
(doall (repeatedly 10000000 #(.-a ^X x)))
1))
Then my profile says tyhat invokeNoArgInstanceMember
is backAn unrelated thing - you can use dotimes
instead of repeatedly
or dorun
instead of wrapping doall
in do
.
I can't reproduce it at all with Clojure 1.10.3.
The whole code:
(deftype X [a])
(def x (X. 1))
(defn xxx [] (.-a ^X x))
(dotimes [_ 10000000000] (xxx))
I checked both B and O because my O is just mkdir
, cd
, edit deps.edn
sometimes, but it’s still a CLI/`deps.edn` project.
Yeah that works without reflection. But if I just go (doall (repeatedly xxx 1000000))
it is back again… it’s just weird… maybe the profiler is pulling my leg…
Still can't reproduce it on 1.10.3 with repeatedly
. invokeNoArgInstanceMember
isn't in the results at all on my end.
Yeah i dont know. I’ll keep looking
@jayzawrotny lately, been using lein new app.... But building a custom scaffolding tool to setup the full stack for web dev.
Git submodules can be really tricky.... They leave the head in a detached state. Your app code is an MVC web stack? With lib in clojure ?
Nothing to do with web... it's just some library code with a bunch of example uses and extensions of the library that aren't part of the main library logic. My plan now is to move them to separate git repos (not submodules) in the same parent folder.
i've been using @seancorfield’s clj-new
. is that clj -X new
or other?