This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-26
Channels
- # announcements (1)
- # babashka (106)
- # beginners (11)
- # biff (7)
- # calva (16)
- # clj-kondo (40)
- # clj-on-windows (5)
- # clj-yaml (10)
- # clojars (4)
- # clojure (37)
- # clojure-austin (22)
- # clojure-australia (1)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (13)
- # conjure (11)
- # cursive (14)
- # datalevin (8)
- # datascript (5)
- # emacs (39)
- # events (1)
- # fulcro (55)
- # gratitude (4)
- # holy-lambda (2)
- # humbleui (9)
- # instaparse (1)
- # lsp (3)
- # malli (12)
- # meander (2)
- # membrane (7)
- # nbb (1)
- # off-topic (16)
- # pathom (9)
- # releases (3)
- # sci (14)
- # shadow-cljs (25)
I’m wondering if there’s an example somewhere of how to do deployment with babashka. Like git tagging and maybe rsync’ing to a remote host.
@soren Several of my projects do this. My convention is to have a bb publish
task that creates a tag, pushes and then CI kicks off a release. E.g. nbb:
https://github.com/babashka/nbb/blob/e5d84b0fac59774f5d7a4a9e807240cce04bf252/bb.edn#L55
Thank you very much!
rsync
is just a matter of calling out to rsync:
https://github.com/borkdude/blog/blob/05ece7b280c905aca906d111f383b70fecd163a0/bb.edn#L30
Hello
FROM babashka/babashka:latest
COPY . /app
WORKDIR /app
CMD ["bb", "-m", "", "stream-link", "link", "stream-name", "1]
This is my docker file
i run docker build ...
i run docker run <img>
i get exception
Exception in thread "main" java.lang.Exception: Couldn't find 'java'. Please set JAVA_HOME.
at borkdude.deps$_main.invokeStatic(deps.clj:439)
at borkdude.deps$_main.doInvoke(deps.clj:428)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at babashka.impl.deps$add_deps$fn__26719$fn__26720.invoke(deps.clj:92)
at babashka.impl.deps$add_deps$fn__26719.invoke(deps.clj:92)
at babashka.impl.deps$add_deps.invokeStatic(deps.clj:92)
at babashka.main$exec.invokeStatic(main.clj:815)
at babashka.main$main.invokeStatic(main.clj:1084)
at babashka.main$main.doInvoke(main.clj:1054)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at babashka.main$_main$f__31212__auto____31222.invoke(main.clj:1123)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:705)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.RT.intCast(RT.java:1221)
at babashka.main$_main.invokeStatic(main.clj:1123)
at babashka.main$_main.doInvoke(main.clj:1109)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at babashka.main.main(Unknown Source)
I am quite new to docker and i am not sure if it's something i am doing
bb.edn
{:paths ["src"]
:deps {}
:pods {}}
hey, do you have a dependency download happening in your script or bb.edn?
i shared my bb.edn (it's empty) and i dont think i am downloading anything in the script
(ns
(:require [clojure.java.shell :as shell :refer [sh]]
[cheshire.core :as json]
[ :as io]
[clojure.string :as s]
[taoensso.timbre :as timbre])
(:import (java.time.format DateTimeFormatter)
(java.time ZonedDateTime ZoneId Duration)))
right thats weird, this error generally happens when bb is trying to download a dependency and needs java for it
looking at the stacktrace looks like a dep is being downloaded
look for maybe (deps/add-deps '{:deps ...
in your code?
i just ran empty script (just ns declaration, without requirements and code) - got the same exception
ah interesting
not sure what was happening there, maybe @U04V15CAJ has better ideas
something i learnt today too
hey, is babashka mainly (only) about faster start of the application? I have trouble to understand use cases when I could be interested in to use babashka.
So I understand use cases as writhing small bash script to do something but in Clojure. Is it correct? Do I miss other use cases?
In general, for me i see bb for the following: • where i would use bash • where i would use python without the machine learning things • CI automation • glue scripts • CLI apps • need Clojure but the run time has to be less than few seconds at max • AWS lambdas
Also scripts with real multithreading (and soon virtual threads!) if thats important 😄
> need Clojure but the run time has to be less than few seconds at max Does it speed up all kind of Clojure systems without any issues?
it only "speeds up" the start time as things are either compiled to native code or interpreted with low overhead. long time perf or things like tight loops with any day be faster on a JVM.
so the rule is: if you use pure bb it will be faster, but if you depend on third party libraries, then JVM will be faster. Do I understand this correctly?
bb can do third party libs, provided they follow certain rules. as for the faster bit, its mostly startup time and not necessarily runtime performance
if the contents of the jar file is compatible with bb then yes.
I know GraalVM or how it is called can do it, but it has issues. I am curious if bb can speed up cold start (starting docker in cloud) which take for example 8 sec. to 2 seconds or something like that.
bb cannot execute arbritary code
so bb is a native compiled environment which interprets clojure unlike the usual clojure which emits JVM bytecodes, which runs differently. meaning it can interop with java code at run time etc. bb doesnt have the jvm so cant interop unless the java class is know ahead of time.
a lot of clojure libs are around java code or have clojure code which emit byte codes. such libs cannot be run on bb
list of things that are compatible: https://github.com/babashka/babashka/blob/master/doc/projects.md
oh so bb can’t use Java, only pure Clojure? > unless the java class is know ahead of time Do you mean author of bb include it into bb?
bb is an interpreter and doenst have the full JVM infra anymore, hence the limitations
sure, but bb uses its own project system https://book.babashka.org/#project-setup
if your code isnt too complex you can always have it in a single file and bb script.clj
its in a similar set of ideas like bash or python
complex code is okay too. you can use its project setup
bb can produce a single script or a jar if you want too
Maybe someone will make a “1 line solution” to prepare bb to run with project and do all things like get libraries from deps.edn by automate
quite doable! 🙂
keep in mind, the JVM isnt quick to start but is one of the fastest when running for a while. so optimise not only on start time but how long a thing runs. if its more than 4-5s, the JVM can already beat bb
JVM will probably outperform native code too, which has an even lower startup time than bb
i wouldnt write a long running server in rust for instance
> but is one of the fastest when running for a while Do you mean bb is slower in runtime?
so the JVM has the Just In Time compiler (JIT) which produces optimised assembly code based on how your code runs. its only possible when its running so ahead of time (AOT) languages like rust/go wont have these info. and bb is an interpreter, like python. it doesnt emit assembly
it can do jars, provided then contain compatible code 🙂
they are just zips right
but yeah if it has .class files, it cant. bb cant load bytecodes right.
So when compile my own bb can I make it start faster and work as fast as standard jar file compiled from Clojure including Java libraries?
yep. the whole reason it starts faster is probably also why its runtime is slower: it doesnt have the fancy machinery of the JVM
It should be written in first line of the doc to make people understand when use bb heh
> It should be written in first line of the doc to make people understand when use bb heh we can take it as a feedback, also PRs welcome!
we have a https://book.babashka.org/ too
can ask the author @U04V15CAJ 😛
as far as i remember, its for the "gray" areas of bash, so the grandma reference, the word-play with bash
also you can check out this https://www.youtube.com/watch?v=ZvOs5Ele6VE from me, mostly focusing on scripting and moving from the JVM to native to bb. also has a bb project made from scratch, live code!
its a talk at a Linux users group, so has some intro to clojure too, can skip it probably 😛
I am always curious how people are so creative to make names for they libraries. I am simple guy and name things in very raw way: for example https://github.com/kwladyka/form-validator-cljs While everyone have cool names for everything 🙂
its simple
what do you think is really happening in the hammock?
also id recommend checking out #nbb too since you seem to be involved in cljs too!
hello, one question about spec.alpha, currently when using anything that depends on clojure.spec.alpha, a babashka user must include the https://github.com/babashka/spec.alpha, I wonder if that should be included by default, given its also part of Clojure core
@wilkerlucio yes, I want to include that as a built-in, just haven't gotten around to it yet