babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-05-06T06:54:43.008Z

In bb new features will never shadow old usage

borkdude 2021-05-06T06:55:49.009900Z

So it won’t break users. Users will simply not have access to the new feature if their usage shadows it, which is not breaking since they didn’t use the new feature yet.

1πŸ‘
borkdude 2021-05-06T12:16:02.013400Z

babashka 0.3.8 now comes with the Selmer templating library built-in Other than that, minor enhancements. Ramping up to a 0.4.0 release where tasks will be available as a stable feature. No other changes to tasks are planned, feedback still welcome.

9πŸ‘
emilaasa 2021-05-06T14:19:18.014200Z

It's a dirty job but someone has to do it πŸ™‚

dominicm 2021-05-06T19:24:26.014900Z

Does bb have a parsing library in there? Instaparse or something? I have a few plaintext scripts that might be nice to have be fast.

borkdude 2021-05-06T19:25:53.015500Z

It might be nice to add Instaparse at some point (it's pure Clojure and has no deps, so seems alright, but must be carefully considered) but right now it's not there

2πŸ‘
borkdude 2021-05-07T09:47:17.030600Z

@dominicm I have now added the java.text.ParseException class to babashka so from master (check #babashka-circleci-builds) you can now run https://github.com/rm-hull/jasentaa as is. I will try to fix support for kern too, but meanwhile, you can look at the above gists which uses my forks of both libs. I'm surprised it works this well.

borkdude 2021-05-07T09:58:45.031100Z

Added all the unit tests from jasentaa to bb CI and all are passing :)

dominicm 2021-05-07T12:38:47.049400Z

FSM parsing is definitely the best. I did some work a while back on improving bidi performance that compiled bidi to a FSM and saw massive speedups. You can do some pretty neat stuff with it.

wilkerlucio 2021-05-06T19:49:35.015900Z

I gotta say that I find a bit concerning keep adding libraries to babashka like this, I understand the idea is to be batteries included, how do you see those affecting size and start time in the future? for instance, imagine if somebody wants to use babashka for some less capable processor/memory devices, how would go? compile bb itself removing those? if that's easy may be ok, also I wonder if adding those can affect the boot time of babashka, would love to hear your thoughts on those

borkdude 2021-05-06T19:58:04.016100Z

I have the same concerns. I do a careful analysis when adding something. For the selmer dependency: I had been considering this for a while, several people asked for this. Yesterday my colleague needed this for his devops tasks and I finally did a POC for adding it. The lib only adds 0.6-1.5mb to the binary which I find reasonable for what it does. I usually take into consideration how useful it is for scripting tasks (or in combination with the built-in webserver) and I think a templating lib like this is useful enough. So adding everything up, I made the decision that it's good to add it. As for Instaparse this is far less clear, but if it's a light weight dependency and doesn't add much size, I might be open to it, depending on how often this comes up.

1πŸ‘
borkdude 2021-05-06T19:58:28.016300Z

I did several PRs over the last two days to Selmer to make all dependencies optional btw. see #announcements

borkdude 2021-05-06T20:00:27.016600Z

There is an issue about adding malli to bb which also isn't clear yet, so I'll leave that open for feedback. If people suggest I should add Instaparse to bb, they can open an issue to it can collect feedback. cc @dominicm

borkdude 2021-05-06T20:02:27.016900Z

Adding libs doesn't impact startup time btw, at least, I haven't seen a noticeable effect

borkdude 2021-05-06T20:03:38.017200Z

There is a BABASHKA_LEAN environment variable which can be used to strip non-essentials to have the most bare bb possible, but so far I haven't had many requests to make such a distribution

borkdude 2021-05-06T20:04:31.017400Z

I sometimes spend days to keep the size of bb in check when adding something. E.g. with clojure.pprint I did this. https://github.com/borkdude/pprint

borkdude 2021-05-06T20:05:56.017800Z

But thanks for expressions you concern, it's good to be concerned about that.

1πŸ™
borkdude 2021-05-06T20:06:33.018Z

Sometimes when I upgrade GraalVM (e.g. now from 21.0 to 21.1) it adds 5mb for no reason, while I spend days trying to save 1 or 2 mbs when adding a clojure lib. This is very frustrating sometimes.

dominicm 2021-05-06T20:08:21.018300Z

I am not enough of an advocate for instaparse to actually advocate for it. I wrote a parser for http://todotxt.org/ using it so I could do some scripting on my todo file. And I have to wait a whole 2s for it to run! I'd happily have used another library if it were included in bb already though (kiev I think you tried @borkdude?). I would say that one of bb's value propositions is that it allows adding structure to the unstructured data we often get in text streams, so I think there's value to something that can handle that. But I'm not sure if that's the same as my problem or not.

borkdude 2021-05-06T20:09:03.018600Z

For structured things people usually use JSON or EDN already

borkdude 2021-05-06T20:10:12.018800Z

Recently bb added support for the https://github.com/helins/binf.cljc library (by adding appropriate Java classes), that might also come in handy, but is more geared towards parsing e.g. MIDI files, etc)

borkdude 2021-05-06T20:10:52.019200Z

There is a complete web-assembly parsing library available which also works with bb from source based on that lib

dominicm 2021-05-06T20:11:17.019400Z

ls (LS) doesn't output json, that's the kind of thing I mean. Input from other tools.

borkdude 2021-05-06T20:11:58.019700Z

As for parsing, you can go a long way with a Reader, .read and a loop: https://github.com/babashka/process/blob/eba04e6c35814296e5bb383804f801aee912cba1/src/babashka/process.clj#L10

borkdude 2021-05-06T20:12:26.020100Z

That function parses shell invocations like ls 'foo "bar"' \"hello\"

borkdude 2021-05-06T20:12:36.020300Z

and also works with bb from source even

borkdude 2021-05-06T20:13:26.020600Z

it's low level, but this is how many parsing things work. just a state machine and loop through chars

borkdude 2021-05-06T20:13:49.020800Z

what is kiev?

dominicm 2021-05-06T20:14:12.021100Z

You're a monster :D Yeah. I think there's value to the higher-level thing though. Parsing todo.txt is not trivial because you have to go through many characters before you realize it's not a date, and it's part of the todo, stuff like that.

borkdude 2021-05-06T20:15:28.021300Z

There might be parser combinators compatible with bb (or can be made so): https://github.com/rm-hull/jasentaa https://github.com/blancas/kern I haven't tried, but I'm curious

dominicm 2021-05-06T20:17:24.021800Z

kern, that's the one you've tried :D

dominicm 2021-05-06T20:18:21.022Z

https://github.com/borkdude/aoc2017/blob/master/src/day16.clj here we are

borkdude 2021-05-06T20:33:33.022300Z

yeah, I remember, it was a pretty good experience. also, the conclusion was: manual parsing always wins in terms of performance

borkdude 2021-05-06T20:37:37.022500Z

bb currently trips over this defrecord with a Comparable interface: https://github.com/blancas/kern/blob/3ef65e559658c06a321a9ca7c85a541edc7b9ff2/src/main/clojure/blancas/kern/core.clj#L108

borkdude 2021-05-06T20:45:51.022900Z

wow, removing that, it works

borkdude 2021-05-06T20:47:01.023100Z

let me push the fork

borkdude 2021-05-06T21:12:44.023800Z

@dominicm The other one works too: https://gist.github.com/borkdude/4e66410b09894b544d4d26483014815b

borkdude 2021-05-06T21:15:37.024600Z

Just found out that with slight modifications, two parser combinator libraries work with babashka: Kern: https://gist.github.com/borkdude/bbc78b34e77ef91510ace75862d23aeb Jacentaa: https://gist.github.com/borkdude/4e66410b09894b544d4d26483014815b /cc @dominicm

ghosttoaster 2021-05-06T21:42:56.025700Z

Is babashka not available for Apple Silicone chips?

borkdude 2021-05-06T21:50:34.027Z

@cdimara If you can find a (free) CI that can build native binaries for Apple Silicon, I would be happy to support that. Until then, Rosetta can run the amd64 binaries as well.

1πŸ‘