This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-04
Channels
- # adventofcode (161)
- # asami (2)
- # babashka (56)
- # beginners (128)
- # calva (57)
- # cider (10)
- # circleci (1)
- # clj-kondo (4)
- # clojure (13)
- # clojure-europe (44)
- # clojure-france (32)
- # clojure-italy (3)
- # clojure-nl (18)
- # clojure-spec (7)
- # clojure-uk (26)
- # clojurescript (18)
- # code-reviews (15)
- # community-development (7)
- # conjure (5)
- # cryogen (8)
- # cursive (31)
- # datomic (18)
- # emacs (8)
- # events (4)
- # figwheel-main (7)
- # fulcro (42)
- # juxt (3)
- # kaocha (58)
- # lambdaisland (1)
- # malli (1)
- # minimallist (1)
- # pathom (11)
- # pedestal (9)
- # re-frame (28)
- # reagent (20)
- # reclojure (4)
- # releases (1)
- # reveal (23)
- # schema (2)
- # shadow-cljs (7)
- # test-check (67)
- # xtdb (23)
If anyone is using Cursive, how do you connect to bb nrepl or socket repl?
@roklenarcic https://book.babashka.org/#repl and then ctrl-f for Cursive
thanks
is there any type of "lein" tool for BB? Dependency management / configuration / environment management etc
@kevin.van.rooijen Not yet. We're brainstorming about this here: https://github.com/borkdude/babashka/issues/473
For dependency management you currently use clojure
and set the printed classpath using the -Spath
option to the BABASHKA_CLASSPATH
environment variable or you pass the string directly to the --classpath
option.
Also, unrelated; Any plans / ideas / is it even possible for bytecode compiled BB? Basically to improve require speeds, similar to pyc files in python
I think the output from the analyzer namespace could be made printable so the interpreter could load that instead of parsing and analyzing the source from scratch. But this would need benchmarking to see if loading the analyzed output is actually faster (it should be but you never know unless you measure).
If you want to know more about sci internals, I recommend watching my talk on it: https://youtu.be/pgNp4Lk3gf0
@kevin.van.rooijen In this area, running the uberscript + carve over the namespaces will likely also help. https://book.babashka.org/#_uberscript
Is there any way to get the classpaths in BB? There is a cp-state atom that gets modified when you run add-classpath
but it's not accessible AFAIK https://github.com/borkdude/babashka/blob/67c33b227009b47131fb145bed42cf4742aa4586/src/babashka/main.clj#L356
In clj you would use clojure.java.classpath
I think, but that doesn't work in bb
We could make this available under a system property, but a function in babashka.classpath could also work
There are already these: https://book.babashka.org/#_system_properties But maybe a function is better, since the value can change. Right.
yes, I think it should return the classpath as is, so foo:bar:baz
, that's one classpath
we could add a function parse
or something, but I would do that as a separate function and only if there is a good reason to add it. generally it's just (split ... (re-pattern file-separator))
#!/usr/bin/env bb
(require '[babashka.classpath :refer [add-classpath]]
'[clojure.java.shell :refer [sh]]
'[org.httpkit.server :as server])
(defn app [req]
{:status 200
:headers {"Content-Type" "text/html"}
:body "hello HTTP!"})
(defonce server (atom nil))
(defn stop-server []
(when-not (nil? @server)
;; graceful shutdown: wait 100ms for existing requests to be finished
;; :timeout is optional, when no timeout, stop immediately
(@server :timeout 100)
(reset! server nil)))
(defn -main [& args]
;; The #' is useful when you want to hot-reload code
;; You may want to take a look:
;; and
(reset! server (server/run-server #'app {:port 8080})))
(-main)
Why this is not running the web-server?it's returning me
#object[clojure.lang.AFunction$1 0x4d572c3e "clojure.lang.AFunction$1@7fa00b1a1648"]
It starts the server on a new thread and then exits the main thread, exiting the program
(defn -main [& args]
;; The #' is useful when you want to hot-reload code
;; You may want to take a look:
;; and
(reset! server (server/run-server #'app {:port 8080}))
@(promise))
(-main)
❯ http :8080
HTTP/1.1 200 OK
Content-Length: 11
Content-Type: text/html
Date: Fri, 04 Dec 2020 20:43:45 GMT
Server: http-kit
hello HTTP!
aw thanks thanks
yey thanks!