babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
2020-09-04T05:17:52.090600Z

we have the #graalvm folks and others to thank 🙂

borkdude 2020-09-04T06:44:09.092400Z

Thanks @goomba! Yes, #spire is a sister project by @retrogradeorbit based on the same interpreter #sci

borkdude 2020-09-04T10:55:02.093200Z

Can be handy to know: https://twitter.com/borkdude/status/1301836039129104385

Crispin 2020-09-04T12:25:12.093700Z

huh. that's surprising

borkdude 2020-09-04T12:49:31.094200Z

You can also use that for limiting the memory: -Xmx30m

borkdude 2020-09-04T12:52:30.094500Z

$ bb -Xmx0m -e "(+ 1 2 3)"
java.lang.OutOfMemoryError: Garbage-collected heap size exceeded.
$ bb -Xmx5m -e "(+ 1 2 3)"
6

😆 1
🤘 2
lread 2020-09-04T21:49:07.096800Z

Heya! I wanted to compare some versions in a babashka script and discovered that https://github.com/xsc/version-clj works with babashka. Worth adding to https://github.com/borkdude/babashka/blob/master/doc/libraries.md#libraries?

borkdude 2020-09-04T21:49:54.097200Z

yes please!

lread 2020-09-04T21:50:07.097400Z

will do!

borkdude 2020-09-04T21:51:48.097500Z

hmm:

user=> (version-compare "1.0-alpha5" "1.0-alpha14")
java.lang.StackOverflowError

lread 2020-09-04T21:52:43.097700Z

hmmm…

borkdude 2020-09-04T21:53:24.097900Z

$ bb -e "(use 'version-clj.core) (version->seq \"1.0.0-SNAPSHOT\")"
----- Error --------------------------------------------------------------------
Type:     java.lang.StackOverflowError
Location: version_clj/split.clj:63:5

borkdude 2020-09-04T21:53:47.098100Z

Did it work for you though?

lread 2020-09-04T21:55:58.098300Z

yeah, it passed my little tests, lemme check more

lread 2020-09-04T22:01:13.098500Z

I was testing from the bb repl like so:

> bb --repl
Babashka v0.2.0 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[version-clj.core :as ver])
nil
user=> (ver/version->seq "1.0.0-SNAPSHOT")
[(1 0 0) ["snapshot"]]
user=> (ver/version-compare "1.0-alpha5" "1.0-alpha4")
1
user=> (ver/version-compare "1.0-alpha4" "1.0-alpha5")
-1

lread 2020-09-04T22:02:20.098700Z

And setup my bb cp like so:

export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {version-clj {:mvn/version "0.1.2"}}}')

borkdude 2020-09-04T22:05:45.098900Z

let me try again

borkdude 2020-09-04T22:07:33.099100Z

this indeed seems to work:

$ bb -e "(require '[version-clj.core :as ver])" -e '(ver/version->seq "1.0.0-SNAPSHOT")'
[(1 0 0) ["snapshot"]]

lread 2020-09-04T22:08:08.099300Z

I can replicate your stack overflow with use

borkdude 2020-09-04T22:08:24.099500Z

But this doesn't:

$ bb -e "(use '[version-clj.core])" -e '(version->seq "1.0.0-SNAPSHOT")'
There may be a bug in the implementation of sci's use :)

borkdude 2020-09-04T22:08:33.099700Z

Thanks for discovering this :)

borkdude 2020-09-04T22:08:59.099900Z

I would appreciate an issue and I'll try to fix it in the next cycle of babashka

borkdude 2020-09-04T22:09:06.100100Z

if you don't beat me to it.

borkdude 2020-09-04T22:09:40.100300Z

I think I know what it is

lread 2020-09-04T22:09:44.100500Z

Oh interesting, version-clj is uses .cljx files.

borkdude 2020-09-04T22:10:02.100700Z

split is private, but bb currently doesn't honor private

borkdude 2020-09-04T22:10:19.100900Z

so if you use use, it will overwrite things that it shouldn't

borkdude 2020-09-04T22:10:26.101100Z

this is my guess, but I'd have to look into it

borkdude 2020-09-04T22:11:16.101300Z

What I usually do for libraries like this is copy the tests to test-resources and add it to the lib tests script

borkdude 2020-09-04T22:11:25.101500Z

so they will be tested on CI

borkdude 2020-09-04T22:11:29.101700Z

like a smoke test

lread 2020-09-04T22:11:45.101900Z

that’s smart

borkdude 2020-09-04T22:11:47.102100Z

such a PR would also be welcome for this lib

borkdude 2020-09-04T22:11:57.102300Z

I have to call it a night now. thanks!

lread 2020-09-04T22:12:13.102500Z

g’night, I’ll make an issue in babashka.

lread 2020-09-04T22:26:53.102700Z

here’s the issue: https://github.com/borkdude/babashka/issues/565

borkdude 2020-09-04T22:27:59.103Z

Thanks. Meanwhile I made a small repro which may be similar:

(ns foo
  (:refer-clojure :exclude [+]))

(defn- + [& xs]
  (apply + xs))

(ns bar (:use foo))

(+ 1 2 3)

lread 2020-09-04T22:28:19.103200Z

I’ll hold off on adding to libraries docs until this is fixed. Note that I won’t get to it immediately.

lread 2020-09-04T22:28:42.103400Z

hey, go to sleep!

borkdude 2020-09-04T22:28:56.103600Z

No problem, I'll fix it when I finish some clj-kondo business in the coming week

borkdude 2020-09-04T22:29:25.103800Z

I want to introduce something in clj-kondo so it can scan libraries for config and hook code

borkdude 2020-09-04T22:29:36.104Z

so library authors can distribute those themselves