This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-06
Channels
- # announcements (16)
- # aws (9)
- # babashka (76)
- # beginners (92)
- # boot (1)
- # cider (18)
- # clara (7)
- # clj-kondo (26)
- # clojure (104)
- # clojure-europe (4)
- # clojure-nl (11)
- # clojure-spec (11)
- # clojure-survey (101)
- # clojure-uk (35)
- # clojuredesign-podcast (15)
- # clojurescript (8)
- # core-async (29)
- # data-science (1)
- # datomic (13)
- # emacs (4)
- # fulcro (20)
- # graalvm (14)
- # instaparse (2)
- # jobs (1)
- # juxt (6)
- # malli (5)
- # off-topic (30)
- # onyx (3)
- # planck (1)
- # project-updates (7)
- # re-frame (38)
- # reagent (30)
- # reitit (14)
- # remote-jobs (2)
- # shadow-cljs (50)
- # sql (8)
got to the expected error during compilation on windows: https://pastebin.com/5hm68xZM graal 19.3.1 should be out soon (jan 14th or so?) -- hopefully including the fix for the stdlibc++ error
just tested -- looks like that was it (removed the https and related part about security) so there is a bit less to do for a java 8 based build (because the reflection part doesn't need to be altered) compare with: https://github.com/borkdude/babashka/issues/138#issuecomment-562260963
iiuc, lein with-profile +reflection run
did generate a reflection.json, and the compilation process didn't complain about its content.
Almost all of spec1 is ported now in https://github.com/borkdude/spartan.spec Usable with babashka from master: - https://3278-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.61-SNAPSHOT-macos-amd64.zip - https://3280-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.61-SNAPSHOT-linux-amd64.zip Things not in spartan.spec: fdef, generators.
Awesome!
Tiny http server in bb: https://gist.github.com/borkdude/dca50a3d5a48ac6ab2ef6aa58a4e9f6b
Really cool btw!
I'm playing with spartan.spec
and babashka
. I noticed babashka fails when I have commented sections e.g.
GOOD
(s/def ::short-option any?)
BAD
(s/def ::short-option any? #_(s/or :nil nil?
:v (s/and symbol? #(> 1 (count (str %))))))
yeah I'm not completely sure yet what it is. I'll investigate more
ah part of it is missing any?
(next release I see https://github.com/borkdude/sci/tree/e5c34aa292c1d96f7ed41ae01af3fd61d78bd66e)
yeah, I said use bb from master: https://clojurians.slack.com/archives/CLX41ASCS/p1578303873143100
I thought I did
bb --version
babashka v0.0.61-SNAPSHOT
but will test again before posting here
Got it:
$ bb --verbose -cp src -e "(require '[spartan.spec :as s]) (s/def ::short-option #_(s/or :nil nil? :v (s/and symbol? #(> 1 (count (str %)))))) (s/valid? ::short-option :foo)"
java.lang.NullPointerException: null
at clojure.core$namespace.invokeStatic (core.clj:1603)
clojure.core$namespace.invoke (core.clj:1597)
@jeroenvandijk Short repro:
bb --verbose -cp src -e "#_:nil"
Aah, it turns out it's not related to uneval at all! bb ':nil' already does the trick
I think I know why this fails. While parsing keywords, we first parse a colon and then a symbol. But nil is not a valid symbol
Some intermediate success: https://gist.github.com/jeroenvandijk/6740c1ef7194cb65d0c6c9c5342273f2
I added the ::nil
workaround now. Works!
Yes I think so too. Without the --verbose
option I often don't even realize there is an exception
At some point I just start to wonder why I'm getting nil as output 🙈
if you get an explicit nil as output, then you can be pretty darn sure it's a nullpointer, since a literal nil doesn't get printed as output
TLDR; on above thread we found two issues, but something is working https://gist.github.com/jeroenvandijk/6740c1ef7194cb65d0c6c9c5342273f2 🙂

I'm noticing there is quite some overhead of the parsing of the options with spartan.spec
:
123 ms
(deftask options
"Demonstrate the task options DSL."
[a a-option VAL kw "The option."
]
*opts*)
293 ms
(deftask options
"Demonstrate the task options DSL."
[a a-option VAL kw "The option."
c counter int "The counter."
e entry VAL sym "An entrypoint symbol."
f flag bool "Enable flag."
o o-option VAL str "The other option."
z nil VAL str "The other option."
nil yy VAL str "The other option."
]
*opts*)
I'm guessing that just the way clojure.spec
is implemented in combination with the interpreting parts of sci
you could try to compare with normal spec on the JVM. I assume it's much faster, but you pay the startup time penalty of 1.5s there
I envision the following schedule: spartan.spec (= spec1), spartan.spec2 (= spec2), bb with built-in spec2
or maybe we could add the things that are not going to change already, but I'm not sure under which namespace and how much guarantees there are about what's not going to change
bb tasks.cljc 0.11s user 0.04s system 93% cpu 0.154 total
clojure tasks.cljc 2.44s user 0.25s system 241% cpu 1.115 total
yeah those sound like good options. I'll do some testing with the clj version as well. The parsing of options with spartan.spec versus handwritten code is much nicer and more robust anyway!
since spec is macro heavy a lot of the code is going to be interpreted anyway, even if it's a builtin I now realize
And let's say we have native libs in the future (🤞), you could define the specs in the library and the user would benefit from the precompiled code
I'm assuming spartan.spec compiles with GraalVM? That would already be a win for normal clj code compared to clojure.spec
@jeroenvandijk Using this lib: https://github.com/borkdude/graal.locking and this patch: https://github.com/taylorwood/clojurl/blob/locking-fix/src/clojurl.clj#L22-L33 you can now also monkey-patch spec and compile with graalvm in clojure 1.10.1
ah nice 🙂
good to know
Got something working like deftask
in boot-clj (needs some more testing) https://gist.github.com/jeroenvandijk/c6cb6cdecfd5aa8e990c3765f3411c0f
time bb src/adgoji/application/tasks.cljc options -a my-key
:my-key
bb src/adgoji/application/tasks.cljc options -a my-key 0.19s user 0.07s system 95% cpu 0.269 total