Fork me on GitHub
#babashka
<
2020-08-30
>
borkdude09:08:01

Extended poll about including clojure.spec in babashka here: https://twitter.com/borkdude/status/1300428421252747266

hugod14:08:51

What is driving the inclusion of spec in either version?

borkdude14:08:09

Excellent question. Some people like to validate their command line args with spec: https://github.com/l3nz/cli-matic/issues/113 Some people like to generate data from specs. Instrumenting functions during script development (may be far fetched). There's probably more command line applicability to spec, but maybe it's not really an urgent thing to have. @U0FT7SRLP also had a need for it. Earlier requests resulted in a library which can be interpreted and is not built-in: https://github.com/borkdude/spartan.spec

borkdude14:08:24

If you have any thoughts on this, I'd like to hear them. Btw, the version with the uberscript fixes was released (0.2.0).

hugod14:08:18

Thanks for the release

hugod14:08:28

I wonder how Clojure will incorporate spec alpha2. I suppose it could just include both versions so it doesn’t make a breaking change.

borkdude14:08:01

Good question. I'll ask in #clojure-spec

jeroenvandijk14:08:29

Regarding my use case, I was working on a cli tool for launching cloudformation stacks. I wanted to validate these templates with Spec (and expound). At the time it was unclear (to me) how Spec could work with Graalvm. Now there are more examples of this option, but being able to use spec for things like this, without needing to set up a graalvm project makes things easier and cheaper

hugod14:08:35

Can spec not be used with bb by adding it to the class path?

borkdude14:08:07

Right now it can't. That's why I have created spartan.spec

borkdude14:08:54

At least at the time there were several limitations. And having spec built-in will make it run lots faster

borkdude14:08:24

Malli might also be interesting to look at, since it's more data driven

hugod14:08:06

Mali does indeed look very interesting

jeroenvandijk14:08:41

Ah yeah regarding speed, I had a cli parser with spartan.spec and it was indeed to slow https://gist.github.com/jeroenvandijk/c6cb6cdecfd5aa8e990c3765f3411c0f

borkdude14:08:25

I think it would be good to try it again, since there were several improvements concerning performance

jeroenvandijk14:08:41

True, I’ll do that tomorrow probably

borkdude14:08:16

$ time bb tasks.cljc options -a :foo
::foo
bb tasks.cljc options -a :foo   0.10s  user 0.03s system 93% cpu 0.135 total
Not sure how I should invoke the script

hugod14:08:00

Would making it easier to build graalvm native images reduce the pressure to include more things in bb?

borkdude14:08:56

There's one project that allows you to convert a babashka script into a Graal binary: https://github.com/MnRA/nativity

borkdude14:08:35

I think having a compilation step in between is always going to be a barrier, no matter how "easy", it will still take time and memory

hugod14:08:05

There is also distribution. Is Brew a sufficient distribution mechanism for Linux and windows?

borkdude14:08:02

For things that are not used by everyone there is https://github.com/babashka/babashka.pods. It lends itself well for libraries that receive data and return data. Spec is probably not so suited for that architecture.

borkdude14:08:35

Brew doesn't work on Windows, but Windows has scoop, which is similar

borkdude14:08:48

Babashka pods do have the same distribution problems as other graal binaries

borkdude14:08:18

I think brew and scoop are nice solutions for distributing binaries

jeroenvandijk15:08:10

> I think it would be good to try it again, since there were several improvements concerning performance @U04V15CAJ The script is broken it seems (not sure if was working before). I’ve updated it so that the command generation will work. The spartan.spec version still adds quite some overhead 130ms vs 100ms.

time bb -f tasks.cljc
No task found for ''

Existing tasks
* options : Demonstrate the task options DSL.
bb -f tasks.cljc  0.09s user 0.04s system 89% cpu 0.140 total
vs
time QUICK=1 bb -f tasks.cljc
No task found for ''

Existing tasks
* options : Demonstrate the task options DSL.
QUICK=1 bb -f tasks.cljc  0.06s user 0.03s system 92% cpu 0.093 total
code is here https://gist.github.com/jeroenvandijk/c6cb6cdecfd5aa8e990c3765f3411c0f

borkdude18:08:36

I'd like to get an idea on core.async usage in babashka. If you are using it, please leave a note here: https://github.com/borkdude/babashka/issues/559