Fork me on GitHub

I've just noticed that the namespace alias recommendations in are inconsistent with babashka's choices: for example pp is pprint in bb, which would result in pprint/pprint (which is a bit unnecessarily long) and sh is shell in bb, which results in shell/sh. same issue; unnecessarily long for such a core operation. the other convention leads to sh/sh though, which is short, but weird because of the repetition. i wonder how has this divergence happened? were there any discussions anywhere about these choices with @bozhidar? would it be possible still to achieve a higher degree of consistency, now that babashka is already pretty mature? would it make sense to amend the clojure style guide somehow?


i don't have any good ideas in this regard, but i've just seen recently that some another project is following babashka's conventions.


it's a question of convenience mostly of course, since it's possible to have 2 aliases to the same namespace:

user=>  (require '[ :as sh])

user=> sh/sh
#object[$sh 0x11d24ea2 "$sh@11d24ea2"]

user=> shell/sh
#object[$sh 0x11d24ea2 "$sh@11d24ea2"]


> were there any discussions anywhere about these choices with @bozhidar? I don't think we have to discuss all of our choices with bozhidar, that would take the poor man his entire week. The choices of aliases here are intented to be used on the command line and I like them to be more explicit for this reason, also not to conflict with shorter ones if you are introducing them yourself.


Initially babashka was used as a command line tool only (for a few weeks probably). Later on scripts were introduced. If this was there from the start, I perhaps woudln't have introduced built-in aliases at all.


thanks for the background! i was just asking, because this kind of differences cause tension within teams, where certain members are trying to look for some authoritative source for answers (usually outside of the team). now they can find even 2 conventions 🙂 currently we only have 1 file, which runs under both clojure and babashka, so it's not a big issue yet. im starting to realize that i might have OCD and that's why such things bug me 🙂


when creating scripts it might be better to create your own namespace so you can decide on your own aliases and not rely on the user namespace so much


which is also written here:

👍 2

it's a fair criticism but not something we can change at this point

👍 2

Btw, pprint isn't aliased at all, I see now


> i was just asking, because this kind of differences cause tension within teams, where certain members are trying to look for some authoritative source for answers (usually outside of the team). now they can find even 2 conventions Slightly OT, but just as a datapoint @U086D6TBN - we internally use Nikita's "long namespace convention" in our team (and his other Readable Clojure recommendations) even though they deviate from the linked Clojure Style Guide. The longer (and consistent and codebase unique) namespace is something I have particularly learned to appreciate when reading code. Just wanted to point out that there may already be more than one source of convention. :)

👍 6

thanks @U05476190, i was not aware of this article. I watched this presentation from tonsky, where he talks about related things: and tried his alabaster theme too 🙂

Jakub Šťastný14:06:56

Anyone running babashka from Emacs Orgmode? I was trying to find some ob-babashka, but I haven't found one. What do I want: to be able to use #+BEGIN_SRC babashka, rather than #+BEGIN_SRC clojure. It would simply use CJ syntax, but would work with the bb executable, rather than with clojure. The use-case is direct code execution (`C-c C-c`) from literate programming documents, rather than tangling. Has anyone done it already? If not, I'll probably tweak one of the existing packages, like ob-clojure.el.


I think @U01LR7M2B7A uses something like this, you can maybe watch one of his streams


or search his github profile to see if he has some public dotfiles

Jakub Šťastný15:06:25

Cheers @U04V15CAJ, I will check search on his GH then!

Jakub Šťastný15:06:36

Found the Emacs config, but it doesn't deal with babashka as far as I see.


I'm not sure if he does bb specific stuff but he does use literate programming in org mode and clojure / babashka. He shows this on his stream. You could try to approach him on Twitter for more info.


I think he's just connected to a babashka nREPL server and from that perspective it doesn't matter which version of clojure you use

👍 2

you need ob_babashka. Just use ob_clojure as a starting-point


it’s not that much work

Jakub Šťastný17:06:42

@U04V15CAJ yeah I'd guess that's what he's probably doing. Still, given the nature of babashka, I'm more interested in running one-off things, glue code, not really something that I'd bother with REPL for (unlike in a larger project of course).

Jakub Šťastný17:06:11

@U0B1SDL67 yeah I think so. I already checked the code for other languages, looks pretty straighforward.


Haha, everyone called my shots 😉 I don't often do code eval inline and basically send s-exprs to the REPL. but, I did try this just now:


It's a very basic modification of ob-clojurescript. Though, at the moment I have only tested a few basic evals.


Last ping here. I have updated the gist to properly provide 'babashka-mode'. It is just a derived mode using clojure-mode as the base. This is necessary to get font-locking in babashka blocks. Font locking is syntax highlighting and indentation, in case you didn't know (I didn't know myself until I looked it up). edit: adding link


Is there a clever way to create help from the ":doc" data in the ":tasks" map in a bb.edn file?


I create a separate :usage key and then use that to check required arguments are given for a task -

Vishal Sachdev20:06:52

Hi, hope this is the right place to ask.. but I can't seem to access pprint in expression mode, but I can access it when using the repl. Like here ->

Vishal Sachdev20:06:28

I just installed babashka, so I'm not sure if I'm missing some setup? I'm using arch linux and installed the official package


@vishalsachdev199 in the REPL, some vars are automatically referred, like in the normal clojure REPL


In "expression" mode you can use clojure.pprint/pprint fully

Vishal Sachdev21:06:09

Thanks for the help


When writing scripts it's recommended to use require explicitly (you'll get better linting from clj-kondo for example)

Vishal Sachdev21:06:51

Yeah, the namespace and function having the same name tripped me over. clojure.pprint is available as pprint so I should've used pprint/pprint in the expression mode, but I kinda missed the namespace part. Funny because I was using json/parse-string fine in the same expression.


clojure.pprint isn't aliased as pprint by default


there are some pre-defined aliases like json but it's not done for every available namespace in bb


Here's what I came up with for a babashka "help" task:

help               {:task (let [docs (->> (slurp "bb.edn")
                                         (filter map?)
                                         (map :doc)
                                         (filter identity))]
                              (doseq [doc docs]
                                (println (str "\n" doc)))


Here's an example non-help task:

run-lein           {:doc  "run-lien: Executes 'lien run'"
                      :task (apply shell "lein" "run" *command-line-args*)}


@hairfire Any reason to not just use bb tasks for this? It does almost the same as your help task


I'll give it a try. Can you point me to the docs for "bb tasks"? I looked around, but did not run across this.


Just run it on the command line and you'll see what happens


bb tasks will be just fine. Anyway to alias it to "help", just because my users are more likely to try help


If you type bb --help you see the docs for it:


  tasks       Print list of available tasks.
(it prints it with the docstrings)


is "bb tasks" documented in I didn't see it while looking around for it.


aliasing it as help will override bb's own help :) -- although you can always get to the built-in options using double dashes as well


Thanks for gracefully tolerating my ignorance :face_with_rolling_eyes:


oh no problem at all, I hope you had fun :)

😬 2

@hairfire if you want to disable some tasks showing up in the bb tasks output, you can make a task "private" by starting the name with a dash


e.g -helper-task ...