7 ms·
Babashka – A Clojure for the grey areas of Bash
- rob74 7y agoInteresting 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...
- CGamesPlay 7y agoI also thought this was about a grandma who would lovingly guide me through the hard parts of bash... which honestly still makes more sense to me than the headscarf ideology.
- macleginn 7y agoWhile we are on the subject of Russian words with "bash" in them, I offer "barabashka" to whomever's interested. (It is one of the names for https://en.wikipedia.org/wiki/Domovoy https://en.wikipedia.org/wiki/Domovoy)
- aldanor 7y agoOr even more simply, "Bashka", which means "head" in slang.
- namelosw 7y agoI interpreted as "grandma" as well since it's a super popular Russian term on the internet (eg: YouTube) nowadays.
- asveikau 7y agoIt'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 7y agoIt'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".
- baitkush 7y agoBabuskha https://m.youtube.com/watch?v=6xckBwPdo1c https://m.youtube.com/watch?v=6xckBwPdo1c Please don't downwote, people, dang,etc <3
- dhimes 7y ago(All: the link is to a music video). At least warn us that we're clicking into something irrelevant and silly if we follow the link.
- throwaway2048 7y agoas 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 7y ago`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.
- heinrichhartman 7y agoAs to parsing `ls`: Bash scripting is incredibly powerful but also terribly broken with horrible edge cases. E.g. if syntax, bash quoting, -print0, parsing strings with regexps... It's near impossible to build sound applications with bash. Parsing output of almost any program breaks at _some_ point: https://dwheeler.com/essays/fixing-unix-linux-filenames.html https://dwheeler.com/essays/fixing-unix-linux-filenames.html You need to know what data you are dealing with when writing shell scripts. bb does not aim to fix that. Just gradually improve.
- aidenn0 7y agoBut parsing ls (with no arguments) is just stupid when there is a safe alternative that already exists and is shorter.
- throwaway2048 7y agoThose methods of installing stuff suck too, and its not like you have to pick one of the three... The main problem isn't malicious code, you can review the script after all, the main problem is the app making unwarranted assumptions about your install/distribution, then breaking things in the process.
- Royalaid 7y agoI 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 7y agoAlso 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
- arnautdaniel 7y agoWhy? 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/
- 0x445442 7y agoMan, I'm pretty up to date on things but I admit this is the first time I've heard of Gauche. Seems like a pretty mature project too what with the 907 page PDF manual.
- VWWHFSfQ 7y agolet them use clojure if they want to who cares
- arnautdaniel 7y agoBecause one day you go to look for minimal cli programs and find githubs littered with "minimal dependencies, only nodeJS!". It's madness. There's already several much better tools people should be using for these domains, but they seem to insist on importing their massive and bloated toolchain in instead.
- simongray 7y agoWhy even bring that up for a Clojure project that compiles down to a single native binary? This is not Node.
- kazinator 7y agoThe materials that go into that binary which don't come from the project itself are external dependencies. There is a dependency on a Java VM implementation, GraalVM, and on a Small Clojure interpreter. That looks Node-ish to me, regardless of the application deployment model. GraalVM has some kind of updater, "gu", that's looks reminiscent of npm: https://www.graalvm.org/docs/reference-manual/install-components/ https://www.graalvm.org/docs/reference-manual/install-compon...
- mdszy 7y agoWhy 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 7y agoI guess the examples are so simple so that every bash user can translate them easily.
- mdszy 7y agoWho 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 7y agoDo you speak Clojure? If not, this isn't for you anyhow.
- Grimm665 7y agoGenuinely 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 7y agoAuthor 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.
- marssaxman 7y agoAside 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 7y agoAuthor 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 7y agoAha, that makes more sense - thank you for the explanation.
- parliament32 7y ago$ 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.
- lwb 7y agoNot necessarily ... there are many high profile projects that recommend installation this way. NodeJS and HomeBrew come to mind. Unfortunately it's sort of becoming a standard practice these days.
- jdminhbg 7y agoI'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 7y agoI 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 7y agoHow 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_stealer/ https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_st...
- truculent 7y agoPretty sure even like homebrew does the same thing, chief
- polityagent 7y agowhats the issue here? (genuine question) besides having to trust the author? and what installation methods do you recommend for cli tools?
- lwb 7y agoI'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 7y agoYou 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/663c3e1a82dc2ccf9e53eb8f45d08fc4 https://gist.github.com/cldwalker/663c3e1a82dc2ccf9e53eb8f45...
- leira 7y agoReminded 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.