This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-05
Channels
- # aleph (10)
- # announcements (2)
- # babashka (83)
- # beginners (41)
- # biff (2)
- # calva (6)
- # cider (7)
- # clerk (3)
- # clj-kondo (7)
- # clojure (89)
- # clojure-berlin (1)
- # clojure-brasil (4)
- # clojure-dev (15)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-spec (1)
- # clojure-uk (4)
- # clojurescript (2)
- # conjure (3)
- # datomic (7)
- # emacs (4)
- # events (1)
- # figwheel-main (1)
- # graalvm (5)
- # gratitude (2)
- # honeysql (14)
- # hyperfiddle (86)
- # introduce-yourself (1)
- # joyride (9)
- # lsp (179)
- # malli (29)
- # music (1)
- # nyc (14)
- # off-topic (6)
- # polylith (16)
- # rdf (8)
- # releases (2)
- # rum (1)
- # shadow-cljs (26)
- # specter (2)
- # sql (4)
- # uncomplicate (2)
- # xtdb (16)
For a talk at bb conf, are there any topics (related to bb, the wider ecosystem, clojure, software dev in general, the answer to the universe life and everything) you'd like me to address? I have some ideas myself, but I'd like to hear if you have any. 🧵
What are the design ideas behind bb? What compass do you use to make decisions?
I’d like to hear your thoughts around how to contribute productively to open source. I feel like I’ve learned a lot contributing to Neil about the social aspects, and how to structure a “piece of work” as PRs. Plus “let’s not make things complicated if we don’t have to”.
I’m also interested in whether there’s a system behind all your open source projects. Do you loose track? No? Is that just plain old experience? Or do you use “I want to make a small library” as the “first meaningful thing”? I get the impression that cherry and clj2el just started as simple things, and you figured “we can open source this”. What level of “readyness” should a thing have before one invites others to play? Is there a difference between “I want to help make this” and “I want to use this”?
The inclusion of a library in bb (think httpkit vs clj-http) may become a consideration regarding the lib's usage outside of bb. In other words, our project favors httpkit and has moved off of clj-http just for uniformity's sake. Any positive or negative thoughts on babashka serving as a sort of "tastemaker" in this way?
I think bb is possibly the lowest entry set up for getting into clojure. I know you have covered this before, but starting from scratch to running program. One aspect that slightly confuses me about bb is the use of namespaces. I can run a 'script' without any name space but there are times when a namespace helps. Project setup s different if you use namespaces. Other aspect would be when you use bb in a bash script and when you use shell from within a bb script. Recently I tried to convert a bash script to bb and emulating things like grep and sed and awk where not that straight forward - thoughts. thanks.
@U4C3ZU6KX Thanks. I think what may confuse some people is that you need a classpath for bb to find namespaces on. By default the classpath is empty. But if you set it to .
you can just use namespaced scripts in the current working directory. We can talk in another thread about this if you want.
I'd stress how easy it is to begin contributing to this language and it's ecosystem, and how welcome you're made to feel when you do it! In contrast most other languages out there
'Scaling borkdude' (to add on to teodorlu's points) would be another interesting one
If there's any meaningful update on Java on Truffle at this point and how that can broaden bb's use cases, would be interesting.. but I had a look at that project recently and it's hard to see where it's at
Finally on use cases, bb's stating use case is 'scripting' but I will often use it while developing a clojure/ mixed library. The instant repl startup and overall feeling on greater snappiness at the repl is compelling. So 'developing' is the key (secret) use case for me
'PRs welcome!' is a good summary of my first two points, and needs to be on the next bb t-shirt!
I'm having so much fun writing babashka scripts • it's so FAST! (50ms end-to-end test turnaround time) • TDD for more complex scripts is not just possible but FUN • Clojure is the data-wrangling language PER EXCELLENCE, ideally suited for scripting • babashka.process and babashka.fs are SO MUCH BETTER than what bash offers

So many good decisions that went into making babashka such a joy to work with - well done @U04V15CAJ!

➕ on babashka.process
and babashka.fs
. First I thought Bash had the upper hand, processes and files are exactly what bash is made for. Now I come to prefer these two Clojure libraries with some Clojure glue / data transformation code.
@U3X7174KS The question of why bash is so widely used for scripting recently came up on the Future of Coding slack, and I think the answer might be helpful here:
> There were better shells for writing scripts before bash
, but they were generally regarded as less pleasant to use interactively (completions, forward/backward search, &c). Because most people spend more time composing little one-liners at the command line than writing scripts — an activity that favors those interactive features — bash
became increasingly popular. Once people were used to using bash syntax for one-liners, they preferred to just keep using it in small scripts, despite its many shortcomings as a programming language. Ubiquity was ultimately driven by Linux making it the default shell, which had to do with GNU/licensing preferences.
One of the non-goals (explicitly mentioned from the start in the README) of bb is to replace existing shells like bash. It wants to replace the scripting language, not the shell.
Aaaah, that makes sense. Bash is indeed quite pleasant to use interactively. Thanks! I might have to join that slack.
The "I don't like the language but it's here anyway, so let's use it for more things" sounds a bit like JavaScript's history as well ;)
Bash is easy ("ready-at-hand") and I don't blame people for liking it. But also, with babashka we can code circles around bash people – like 2x, 10x faster, plus it takes longer to hit the complexity ceiling where you don't understand anything anymore
"should this be -z or -eq ..." those kinds of things I only remember by looking at past scripts..
I start all scripts with babashka now, even if bash is more familiar With bb, when I encounter a problem, I learn and understand; the next time I'll know what to do. In bash, on the other hand, I don't learn anything other than workarounds.
I think the places where I mostly still touch bash is in clj-kondos and babashka installer scripts
one other benefit that bb gives me in other projects is that those scripts run in all platforms including Windows
I think you could get bash to run on Windows (cygwin or so) but there's always some thing that's different
And even where bash runs on multi-platforms there can be confusing differences and incompatibilities in tooling. The fact that babashka can also remove these un-fun mysteries from scripting is another awesomeness.
I posted a question in the github discussions about https://github.com/babashka/babashka/discussions/1554. If anyone has experience with this, I'd love to hear about it.
You mention stack traces in that discussion, but note that stack traces in bb due to interpretation work quite different from JVM Clojure. Have you tested whether your bb workaround works as desired?
it works perfectly fine, just hoping to get back some performance
Well yeah in JVM Clojure you can't create custom exception types, so you have to write .java. This is not possible in bb. So I think there aren't many alternatives to your approach
farolero's main building block is the Signal
, which is used extensively as a means of early exiting and control flow
What are you going to use farolero for, splint? Note that such libs may have impact on performance in bb as well
But if you don't care much about it and the script/project works quite fast, then it's all good. Just something to be aware of.
I thought I'd see how it works as I've been struggling/annoyed with error handling in Splint (as seen in your recent issue (that I need to publish the new release for oops))
Using more dependencies is also going to affect startup time. Keeping things more "vanilla" will work best for bb. In terms of errors that probably means: 1 Don't throw, but return exception values 2 Or embrace ex-data and just work with that
Yeah, i've played with farolero before but not for anything meaningful and this is a somewhat fresh codebase so using it is pretty easy
Finally I have a scripting problem, and a setup where I can develop babashka code. Getting my hands dirty with some data processing Some script that does sequential text file reads -> maps numbers from these reads into a vector -> write that vector in some specific text file format... that kinda thing 🙂
When creating a new project for Babashka using Cursive, which project type should I choose?
@ericdallo was sporting a very snazzy babashka t-shirt at the conj. Are those generally available?
Interesting observation here: https://clojurians.slack.com/archives/CLX41ASCS/p1683298055351499?thread_ts=1683280663.603409&cid=CLX41ASCS
Some people will try to use namespaces and will just try to put the files in the current working directory (or src?) I think and then wonder why it doesn't work.
The reason is that bb's classpath is empty by default. Should it default to .:src
? The reason I've not done so is to avoid conflicts with JVM Clojure, but perhaps that's not a good reason.
Reply in 🧵 if you have thoughts.
clojure -T
defaults to "."
but other clojure
invocations default to "src"
-- the latter is based on the default :paths
in the "root" deps.edn
(inside tools.deps
).
Yes, clojure defaults to src
but I think most newcomers aren't even familiar with that and just expects scripts to work on the top level
or we could improve the error message when a namespace could not be found and the classpath is empty ;)
I think, for a scripting tool, I'd expect "."
TBH. I think there's a potential for confusion if it was ".:src"
...?
yeah, I think .
would be a good choice, if the classpath is not specified otherwise.
but some people will read clojure tutorials and would expect src
to work by default like with deps.edn
Hmm, and another data point would be Joyride which has its scripts in scripts
but pulls libraries from src
by default... :thinking_face:
I think for someone like this, making their first steps with babashka: https://github.com/somecho/utility-scripts I think they would indeed be trying to require scripts from the local dir if they haven't read any further docs yet
So I'll start adding the local dir as the "fallback" classpath in one of the next releases
Hmm, one downside of adding .
to the paths is that when creating an uberjar, it zips up the whole directory
I'd like to announce that https://github.com/IGJoshua/farolero v1.5.0 is out now, and adds support for using the library from Babashka! 🎉

Great! :) Some feedback on the README: it would help me get going faster if there was a
(require '[farolero.core :refer [handler-case signal]])
above the exampleGood point! I'll get that in there.
While you're here, I was very explicit about using :farolero.core/blah
throughout most of the readme, and only use ::far/blah
later. Should I move to just using the alias as a part of adding that require with an :as far
in it? Would that still be clear enough about them all being namespaced keywords in the farolero namespace?
yeah, I think alias is good. A rule I keep more or less for my own readme is that you should be able to copy paste the code in a REPL
@U04V15CAJ thanks to your suggestion I just went through and updated all the references to be easy to work with from a repl. Thanks a lot for the feedback!
How can I get back all of: STDERR, STDIN, exit code, when executing a process with the babashka.process functions?
@U02NJTR0718 stdout/err as string?
with shell:
(shell {:out :string :err :string :continue true} "ls -la")
:continue true
means: don't throw on exit non-zerothey all make use of the same underlying code, but have different defaults. sh
is the closest to what you asked