
Babashka – A Clojure for the grey areas of Bash - tosh
https://github.com/borkdude/babashka
======
rob74
Interesting trivia on the name (from Wikipedia):

> Some English speakers use the word "babushka" [бaбушка] (the word for
> 'grandma' in Russian) to indicate a headscarf tied below the chin, as still
> commonly worn in rural parts of Europe.

However the author should be aware that most people would interpret
"bab(a|u)shka" as "grandma" and not as a scarf. Which works too, I guess.
Personally, I always think of a
[https://en.wikipedia.org/wiki/Matryoshka_doll](https://en.wikipedia.org/wiki/Matryoshka_doll)
(which is also sometimes called babushka) when I see this word...

~~~
asveikau
It's very strange to me that someone would keep using this word in those
contexts even after being told that this isn't what it means. It's almost like
"babushka" to the English-speaking mind is stand-in for "funny sounding
Russian word". It does have a rhythm that sounds a little whimsical in
English. It's also usually pronounced in English with stress on the wrong
syllable. [Should be bábushka.]

~~~
sls
It's not at all unusual for loanwords to get different meanings when they are
adopted. Wikipedia gives this lovely example:

The English word Viking became Japanese バイキング (baikingu), meaning "buffet",
because the first restaurant in Japan to offer buffet-style meals, inspired by
the Nordic smörgåsbord, was opened in 1958 by the Imperial Hotel under the
name "Viking".

------
Royalaid
I think Babashka (bb) takes important lessons learned about how Clojure grew
and applies them well. Piggieback on the tools and libraries already in place
and just provide a simpler, more uniform syntax and build in portable standard
library (in Clojure and I assume in bb just really need to use maps and
arrays). Clojurescript (CLJS) does this beautifully and bb is setup to achieve
the a similar success story. CLJS is not perfect (see
[https://twitter.com/royalaid/status/1224830807807676417](https://twitter.com/royalaid/status/1224830807807676417)
for an example of the runtime leaking through) but it is wonderfully pragmatic
and incredibly productive and hope to see bb become to bash what Clojure is
for Java and CLJS is for JS.

~~~
jeroenvandijk
Also noteworthy, Babashka is powered by the Small Clojure Interpreter [1]
(same author) which has additional applications. Both are very promising!

[1] [https://github.com/borkdude/sci](https://github.com/borkdude/sci)

------
mdszy
Why are many of the examples so easily solved using other much simpler
methods? Could they not come up with some actual reasonable use cases?

>ls | bb -i '(count _input_ )'

ls | wc -l

>bb '(vec (dedupe _input_ ))' <<< '[1 1 1 1 2]'

send your input to `uniq` for chrissakes

>ls | bb -i '(filterv #(re-find #"README" %) _input_ )'

just `ls * README * ` (there shouldn't be spaces around the * s but HN
formatting doesn't like me)

like

come on, honestly.

~~~
mateuszf
I guess the examples are so simple so that every bash user can translate them
easily.

~~~
mdszy
Who cares? That doesn't do a good job showing why this software is useful. At
first glance it makes it look like everything is just more complicated.

~~~
jerf
Do you speak Clojure?

If not, this isn't for you anyhow.

~~~
Grimm665
Genuinely curious, what advantage does Clojure provide in this context that
other tools don't handle as well or at all? I agree with the GP post, none of
the examples listed show that this tool is superior to what bash and other GNU
tools already provide.

In other words, if I don't speak Clojure, why should I learn? This project
hasn't convinced me it's worth it yet, but maybe it is?

~~~
Borkdude
Author of babashka here. This tool is intended for people who find Clojure
easier to work with than Bash because of familiarity or whatever other reason.
If you're not one of them, that's fine, just use Bash.

~~~
omaranto
There is no reason for not using more compelling examples.

~~~
derrida
What other things that exist offend you?

~~~
omaranto
I think you accidentally replied to the wrong comment.

------
leira
Reminded me of Closh
([https://github.com/dundalek/closh](https://github.com/dundalek/closh)),
which is a Bash-like shell based on Clojure. Both Babashka and Closh runs
Clojure code directly from shell.

------
marssaxman
Aside from the obvious problem that the babushka is the grandmother herself,
not the clothing she traditionally wears, what on earth do headscarves have to
do with coding? How is this metaphor intended to work?

~~~
Borkdude
Author of babashka here.

The original tagline was "a sprinkle of Clojure for the command line". A user
of babashka commented that this tool was exactly right for him to cover up the
grey areas of bash (bash constructs he could not remember the syntax for). If
you picture bash as a grey woman and Clojure as the headscarf to cover her
grey hair, the metaphor might start to make sense.

~~~
marssaxman
Aha, that makes more sense - thank you for the explanation.

------
lwb
I've been out of the Clojure ecosystem for some time now -- has GraalVM solved
the slow start problem? I remember the 1-2 second start up time being a deal
breaker for many applications.

~~~
Borkdude
You can make CLIs with Clojure + GraalVM that have instant startup. Babashka,
a Clojure interpreter written in Clojure, is one of them.

This is a nice writeup of someone diving into GraalVM + Clojure at work:

[https://gist.github.com/cldwalker/663c3e1a82dc2ccf9e53eb8f45...](https://gist.github.com/cldwalker/663c3e1a82dc2ccf9e53eb8f45d08fc4)

------
throwaway2048
as a sidenote, the README contains two really bad practices, pipeing the
output of curl into bash (running arbitrary code that can do whatever it
wants), and parsing ls.

[https://mywiki.wooledge.org/ParsingLs](https://mywiki.wooledge.org/ParsingLs)

~~~
tcard
`curl X | bash` provides _more_ transparency than most other usual methods of
software distribution, as I can always inspect X, which is usually a simple,
self-contained script.

In contrast, running code from an unaudited source (GitHub, NPM, etc.), or
executing a binary from some random website, all less transparent yet just as
dangerous, but for some reason raise way fewer eyebrows.

~~~
eyelidlessness
You can only be sure of what you're running if you download it first, examine
it, then run what you downloaded.

[https://www.idontplaydarts.com/2016/04/detecting-curl-
pipe-b...](https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-
server-side/)

~~~
3xblah
"You can only be sure of what you're running if you download it first, examine
it, _then run what you downloaded_."

What if, before "run what you downloaded", first perform a dry run and
_observe it while it is running_.

    
    
       set -x
       curl https://example.com/setup.sh | bash -n
       set +x
    

-x Execution trace

-n Read commands but do not execute them

[https://en.wikipedia.org/wiki/Dry_run_(testing)](https://en.wikipedia.org/wiki/Dry_run_\(testing\))

~~~
throwaway2048
a script can just set +x before doing anything else, and then fake output.

------
parliament32

        $ bash <(curl ...
    

Seeing this in a README immediately indicates that the author has no idea what
they're doing security-wise, and that I probably shouldn't trust their
project.

~~~
jdminhbg
I've never understood why people think this is somehow less secure than
downloading a binary blob you can't inspect and running that instead.

~~~
parliament32
I don't think I've ever downloaded and executed a binary blob. Either use a
package manager or compile from source, it's really not that hard.

~~~
jdminhbg
How is compiling and executing source you didn't examine any more secure than
executing a bash script?

It's not like package managers are immune either:
[https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_st...](https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_stealer/)

------
arnautdaniel
Why? If you really want to do scripting in lisp, why would you not just use
guile?

This is just embracing complexity when scheme is a perfect fit, and already
exists in multiple ways in the domain.

Did Gauche stop existing?

[http://practical-scheme.net/gauche/](http://practical-scheme.net/gauche/)

~~~
iLemming
Oy please. Some Lispers are stuck in the past with their ivory tower ideals,
saddened that nobody wants their favorite flavor of Lisp anymore. Why can't
you embrace the fact that Lisp just like any other idea does have right to
evolve and change?

> Did Gauche stop existing?

Out of all the five people who ever heard about it, three probably stopped
using it and for the rest, it may just be like it never existed - they've
never heard about it.

Clojure on the other hand somehow managed to become third most popular JVM
language and very popular alt-js language. Out of all PLs that can be
considered somewhat esoteric, Clojure today is the most vibrant - it has more
books, podcasts and conferences. More than Elixir, OCaml, Haskell, Elm,
Purescript and even Rust.

Very few people used Guile, even before Clojure got some spotlight. So instead
of whining why can't you be happy for the fact that people still want to use
Lisp in 2020 at all?

~~~
arnautdaniel
So your argument is that I'm somehow a lisp fanatic and I should be happy that
at least one lisp made it into the current fad?

~~~
cutler
Exactly.

