This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-03
Channels
- # announcements (1)
- # asami (13)
- # babashka (14)
- # beginners (58)
- # calva (49)
- # cljs-dev (6)
- # clojure (99)
- # clojure-europe (28)
- # clojure-gamedev (4)
- # clojure-nl (19)
- # clojure-spec (4)
- # clojure-uk (39)
- # clojured (5)
- # clojurescript (39)
- # code-reviews (3)
- # conjure (4)
- # cryogen (12)
- # cursive (21)
- # data-science (4)
- # datalog (1)
- # datomic (16)
- # duct (4)
- # events (1)
- # fulcro (6)
- # graalvm (1)
- # graphql (1)
- # jobs (13)
- # jobs-discuss (23)
- # kaocha (2)
- # lsp (15)
- # malli (24)
- # missionary (6)
- # off-topic (21)
- # polylith (75)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (47)
- # sql (35)
- # vim (10)
- # xtdb (4)
Can someone please explain to me what Shaun Lebron might have been thinking about with this?
(grey ... (white) ...
(green ... (lt-green (gold) ...)
(blue)))
I guess my question is more about why he thinks the depth view is more meaningful than the nesting view
I think it's only when the open expression is on the left, that you indent?
and you don't with the ones in the middle? or maybe that's obvious, not sure
Iām using test-runner (https://github.com/cognitect-labs/test-runner) for testing and made a github action for it, but it somehow constantly fails with
Syntax error (FileNotFoundException) compiling at (farmmorning/case_format_test.clj:1:1).
Could not locate farmmorning/util/case_format__init.class, farmmorning/util/case_format.clj or farmmorning/util/case_format.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I double checked the file names, but couldnāt find any clues. can someone give me some advice?here is the deps configuration.
:aliases {:dev {:extra-paths ["dev/src"]}
:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url ""
:sha "705ad25bbf0228b1c38d0244a36001c2987d7337"}}
:exec-fn cognitect.test-runner.api/test}}
yep. here it is.
name: test
on:
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: DeLaGuardo/[email protected]
with:
cli: '1.10.1.693'
- name: Cache maven
uses: actions/cache@v2
env:
cache-name: cache-maven
with:
path: ~/.m2
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Copy file
run: cp -r resources dev/resources
- name: Print paths
run: clojure -Spath -X:test
- name: Run test
run: clojure -X:test
@U04V15CAJ those commands should be run from github action, right?
I assume, the same command, clojure -X:test
from your local system works flawlessly?
Hmm, I don't have much experience with github actions, so I'm afraid I can't offer more help š
seems like malli channel is kinda dead. asking for help
Please wait for at least a few hours before judging a channel as "dead" and reposting a question in a different one.
By that definition, #clojure seems to be more dead
Hi all, I ran across Alex Millerās article āImproving Development Startup Timeā (https://clojure.org/guides/dev_startup_time). That seems like something I would want š Iām having trouble getting it to work however. When I execute (compile ā¦)
I only see the class files of that namespace, not the ones required by it. Whereas the article says ātransitiveā which I take to mean that all namespaces it depends on should also be compiled. So I compile a few of them by hand, do a jack-in, and start my dev server, and it isnāt one bit faster. Now that may of course be due to other reasons, I didnāt profile the startup process, but Iād like to make sure that Iām not missing something. I added ādevā and āclassesā to extra-paths
in deps.edn, I even added :jvm-opts ["-Dclojure.compile.path=classes"]
. Any idea if Iām doing something wrong?
> When I executeĀ (compile ā¦)Ā IĀ onlyĀ see the class files of that namespace, not the ones required by it That's not what I'm seeing when I compile the top level ns of an ns tree
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ mkdir classes
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ ls classes
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ clj
Clojure 1.11.0-alpha1
user=> (compile 'babashka.main)
babashka.main
user=>
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (master) $ ls classes
babashka bencode borkdude cheshire clj_yaml clojure cognitect edamame flatland hf hiccup org rewrite_clj sci selmer
Hi, I find a performance gap between the rand-int
clojure function and the java native one for instance .nextIn
of java.util.Random
. The gap is small for small amount of iterations but increasing with the number of iterations. @alexmiller,I saw some of your posts asking for feedback on performance, so I ask if I did something wrong, or if youo think this is something which should be improved in the clojure standard library, or maybe my case is so specific that I have to use interop?
(ns poc.defrecord.slack)
(def ^java.util.Random seed (java.util.Random.))
(defn compare-rands [nb-iter]
[{:method :java-call
:iterations nb-iter
:time (with-out-str (time
(dotimes [_ nb-iter]
(.nextInt seed 100))))}
{:method :native-rand
:iterations nb-iter
:time (with-out-str (time (dotimes [_ nb-iter]
(rand-int 100))))}])
(compare-rands 2000000)
;; => [{:method :java-call,
;; :iterations 2000000,
;; :time "\"Elapsed time: 35.315238 msecs\"\n"}
;; {:method :native-rand,
;; :iterations 2000000,
;; :time "\"Elapsed time: 127.318862 msecs\"\n"}]
;; => [{:method :java-call,
;; :iterations 200,
;; :time "\"Elapsed time: 0.017836 msecs\"\n"}
;; {:method :native-rand,
;; :iterations 200,
;; :time "\"Elapsed time: 0.025678 msecs\"\n"}]
In my original code there are two call to rand-int
which seems to increase the influence:
(ns poc.defrecord.slack)
(def ^java.util.Random seed (java.util.Random.))
(defn compare-rands [nb-iter]
[{:method :java-call
:iterations nb-iter
:time (with-out-str (time
(dotimes [_ nb-iter]
(.nextInt seed 100)
(.nextInt seed 100)
(.nextInt seed 100))))}
{:method :native-rand
:iterations nb-iter
:time (with-out-str (time (dotimes [_ nb-iter]
(rand-int 100)
(rand-int 100)
(rand-int 100))))}])
(compare-rands 200)
;; => [{:method :java-call,
;; :iterations 200,
;; :time "\"Elapsed time: 0.011242 msecs\"\n"}
;; {:method :native-rand,
;; :iterations 200,
;; :time "\"Elapsed time: 0.039123 msecs\"\n"}]
;; => [{:method :java-call,
;; :iterations 2000000,
;; :time "\"Elapsed time: 93.312348 msecs\"\n"}
;; {:method :native-rand,
;; :iterations 2000000,
;; :time "\"Elapsed time: 372.539035 msecs\"\n"}]
rand-int calls Random/nextDouble under the hood, and does some mutiplication and casting to get an int
I suggest using https://github.com/hugoduncan/criterium
Concerning the implementation your remark is an explanation but it may be possible to do better ?
if you a processing on multiple threads then using ThreadLocalRandom might also speed things up
rand-int and rand use Math/random(), which uses a shared java.util.Random instance for all threads, which may cause contention
I'm trying out :replace-deps
with juxt/pack.alpha.git
like https://github.com/juxt/pack.alpha/pull/92/files, I consistently get a few seconds slower run-times, (I run once to warmup and then average over three runs). Is that expected?
this:
:pack {:extra-deps {pack/pack.alpha {:git/url ""
:sha "042c61410b1851957ae5f77cfe26a255837172cc"}}
:main-opts ["-m"]}
is consistently faster than
:pack {:replace-deps {pack/pack.alpha {:git/url ""
:sha "042c61410b1851957ae5f77cfe26a255837172cc"}}
:main-opts ["-m"]}
I thought it would be faster since it would load less code, but maybe I'm misunderstanding it?
The first time you run it will compute and cache classpaths so make sure youāre accounting for that
I would generally have the same expectation as you - replace should replace the project deps so include less
You can use -Stree or -Spath to confirm that
once all that stuff is downloaded and cached, there should be no real difference here - in both cases you're just running the program
yeah, it's just a question of how many deps you have to download
but once you download them to your .m2/.gitlibs ... that's all cached
What is a good place to look for templates for clj-new?
is there anyway to prevent a symbol from being unmapped via ns-unmap
?
why do you want to do that?
I donāt. Someone asked me if it could and I was almost certain that it couldnāt but wanted to check anyway.
The person who asked me is worried about malicious code. Of course, this person hasnāt discovered eval
yet š
powerful tools are also often dangerous :)
Yes, of course. What is interesting is that truly dynamic systems have to allow for the change of their own environments/source, and everything from DNA to running code is susceptible to maliciousness
the converse is also true. Only dynamic safety is real safety. For example, unchecked array bounds have been a massively costly impact of trusting static assumptions over dynamic reality ...
@srijayanth if you want to have a kind of sandbox that forbids certain vars, you could take a look at sci
user=> (sci/eval-string "(ns-unmap *ns* 'inc)" {:deny ['ns-unmap]})
Execution error (ExceptionInfo) at sci.impl.utils/throw-error-with-location (utils.cljc:51).
ns-unmap is not allowed!
How do a type hint a vararg call for an array of Foo objects? I know to call with (into-array Foo [])
however I try it I seem to get a reflection warning š
Iāve tried variants of things like (a and b are already type hinted) (.method a b ^"baz.bar.Foo" (into-array Foo [])
^"[Lbaz.bar.Foo;"
See (type (into-array Foo []))
for the string representation of the type.
ah sorry thatās already what I haveā¦ I misstyped it here
Perhaps thereās some other aspect of ambiguity in the call then?
Does the reflection warning provide a bit more specific information?
ok real code is:
(def default-context ^"[Lorg.eclipse.rdf4j.model.Resource;" (into-array Resource []))
(defn index-data! [input-files]
(let [repo (repo/sail-repo (repo/memory-store))]
(doseq [^File input input-files]
(with-open [^RepositoryConnection conn (repo/->connection repo)]
(let [^RDFFormat fmt (.orElse (Rio/getParserFormatForFileName (str input)) nil)]
(.add conn input "" fmt default-context))))
repo))
Reflection warning,
swirrl/qb_tools/concept_scheme/positions.clj:89:11 - call to method add on org.eclipse.rdf4j.repository.RepositoryConnection can't be resolved (argument types: java.io.File, java.lang.String, org.eclipse.rdf4j.rio.RDFFormat, unknown).
class Iām calling is: https://rdf4j.org/javadoc/3.0.4/org/eclipse/rdf4j/repository/RepositoryConnection.html#add-java.io.File-java.lang.String-org.eclipse.rdf4j.rio.RDFFormat-org.eclipse.rdf4j.model.Resource...-
hmm actually the docs are one minor version out, from what I have on my classpath :thinking_face:
Maybe the type hint on the def
has to be before the symbol instead of on the value?
ahh thatās it thanks
dev=> (def example ^"[Ljava.lang.String;" (into-array String []))
#'dev/example
dev=> (meta example)
nil
dev=>
silly mistake
6pm code blindness setting in š©
hmm prints correctly
maybe the issue is something else
Is there anyone here who provides hands-on introductory Clojure workshops for corporate teams, or can recommend such from personal experience?
Hadnāt Cognitect used to offer that? @alexmiller?
I can't personally recommend him, but I like the output of Eric Normand and it sounds like he does that sort of thing: https://lispcast.com/training/
^^ resources
you can ping <mailto:[email protected]|[email protected]> - we are entertaining such requests but I don't know the full status
Thanks, all! I should have mentioned I'd found the community link, but wasn't sure how vetted or up to date it is.
It is as up to date as most internet information :)