Fork me on GitHub
#babashka
<
2023-02-17
>
orestis07:02:00

Not sure if there's a better channel for this - recently on HN there was an interest in no-build-system web apps/pages. In the SCI-land, there's scittle, but recently there was also cherry and squint that might be in the same land? I thought a blog post detailing how you could do zero-build web apps with Clojure would be interesting 😉

borkdude08:02:56

The squint/cherry compiler can run inside a browser, but it still does a source -> source transformation, so it depends on your definition of build-less. I think babashka + scittle comes closest. E.g. this one: https://github.com/kloimhardt/babashka-scittle-guestbook or Babashka + HTMX: https://github.com/prestancedesign/babashka-htmx-todoapp

Uli07:02:43

Hey Guys. What a fun with babashka ! @borkdude thanks for your effort here ! Wasn't aware, but now I have covered all 3 important areas for me: frontend (cljs), browser-free (clj) and YAY :female_superhero:my bash (zsh) as well ! It's really fun! Thanks!

🎉 12
❤️ 10
Matthew Twomey17:02:56

I’m working with the babashka process library and I’m having trouble capturing the error message output from a command. As a simplified example, I’m trying this here:

(try (:out (shell {:out :string} "ls nofile"))
         (catch ExceptionInfo e (-> e print)))
How can I capture the error message? The excpetionInfo doesn’t seem to have it?
"nofile": No such file or directory (os error 2)

Matthew Twomey17:02:43

Oooh - no sooner do I ask than I figure it out:

(try (:out (shell {:out :string :err :string} "ls nofile"))
(catch ExceptionInfo e (-> e ex-message print)))

lispyclouds17:02:35

so thats probably written to stderr. try with {:err :string}as well

Matthew Twomey17:02:08

Yep - just realized that 👍 ty

Jeffrey Bay19:02:25

has any thought been given to incorporating readline type support into the babashka repl? it is pretty painful to use without it. we've been wrapping the basic call to bb in rlwrap, which works for that use case, but we're starting to find reasons to hit the repl from within a program, and it would be much easier to use if it was just built into the repl itself...

borkdude19:02:39

@U03A0EGF82E The babashka console REPL is as basic as the clj REPL. If you want to have a better experience, you should probably just start the nrepl-server and connect from your favorite editor

Jeffrey Bay19:02:48

i guess that's fair.

borkdude19:02:03

You can also get a long way with load-file and (require '[foobar] :reload) and then edit the files in your editor, but reload the evaluation of that file in the console REPL

Jeffrey Bay19:02:29

no, this all makes sense. the idea is to stop after generating a complex data structure and drop the user into a repl. i think i can do that by starting nrepl-server and pausing so they can connect to it, and get the desired functionality.

borkdude19:02:15

You can programmatically start the nREPL server as well

Jeffrey Bay19:02:37

hmm - i just tried to use

Jeffrey Bay19:02:41

babashka.nrepl.server

Jeffrey Bay19:02:05

weird, my editor can't find it but it executes fine. Looks like it should work 🙂 thanks

borkdude19:02:05

$ bb -e '@(:future (babashka.nrepl.server/start-server!))'
Started nREPL server at 0.0.0.0:1667

borkdude19:02:37

the reason is probably that your editor is looking for an .nrepl-port file or so - bb doesn't write that by default

borkdude19:02:26

You can see some snippet here which does that: https://book.babashka.org/#_nrepl

Oliver Marks19:02:21

trying to use the babashka/babashka container but getting java not available please set JAVA_HOME, its a simple script with a bb.edn, is this because its using java to handle the bb.edn file initially ? seems i should not need java as I am using babaska

borkdude19:02:19

Java is only used when you have :deps in bb.edn to download them and construct the classpath

borkdude19:02:17

If you want to run in a container without java, it's probably better to construct an uberjar first

Oliver Marks19:02:36

ah okay, I was hoping to have a simpler script but, it explains the errors so that's very helpful cheers

borkdude20:02:10

@U02DXJUS5JA outside of the container:

bb uberjar foo.jar
Then copy foo.jar into the container and do:
BABASHKA_CLASSPATH=foo.jar bb

Oliver Marks20:02:34

oh that's neat cheers