This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-16
Channels
- # announcements (19)
- # babashka (41)
- # beginners (9)
- # calva (1)
- # cider (28)
- # clerk (2)
- # clj-kondo (33)
- # cljs-dev (1)
- # clojars (32)
- # clojure (29)
- # clojure-europe (36)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-uk (4)
- # clojurescript (33)
- # datahike (6)
- # datomic (44)
- # emacs (35)
- # fulcro (25)
- # hyperfiddle (22)
- # introduce-yourself (1)
- # java (11)
- # kaocha (7)
- # membrane (3)
- # off-topic (2)
- # pathom (7)
- # polylith (15)
- # portal (3)
- # squint (1)
A major selling point for bb, is it is basically a fast starting clojure. Since it is graal compiled it is limited to certain ostype/machtype usage. I was wondering if that was one of the primary reasons for nbb? A fast starting clojure that can run anywhere nodejs can (freebsd etc).
nbb is intended to be used as bb but by leveraging the Node.JS ecosystem in mind. There are JS libraries for about anything (reading excel files, or whatever) and that may not always be the case for bb. It's just another way to increase the reach of Clojure via scripting
The other day you mentioned that SCI works in cljs, which I hadn't realized. I'm hoping that making cljs builds of ys might allow it to get to more platforms. But the ability to also leverage JS npm libs is exciting too.
nbb is one such project, #C034FQN490E is another one that uses SCI+JS, and #C03DPCLCV9N (VSCode scripting) another one
given that bb can't dynamically use java libs, are there things that bb can do that nbb can't?
bb is just closer to JVM semantics, so it's easier to share code between Clojure (JVM) and bb. ClojureScript is less popular than Clojure
The thing that bb can that nbb can't mostly has to do with the target platform (multi-threading etc) (and vice versa)
the stuff that makes nbb more complicated is that JS needs async to load libs (if you want to load ES modules). This is why sci.async (https://github.com/babashka/sci/blob/master/doc/async.md) was written
I'm also working on an alternative CLJS compiler which can be integrated in a (normal) CLJS app for dynamic evaluation: https://squint-cljs.github.io/cherry/ (playground takes a while to load due to import-maps / CDN stuff) This performs better than SCI (interpretation vs compilation)
The thing that the cherry compiler simplifies is that you can just compile to import .. from "whatever"
and don't worry about async loading of JS libraries yourself
$ time bb -e nil
real 0m0.033s
user 0m0.010s
sys 0m0.024s
$ time nbb -e nil
real 0m0.174s
user 0m0.150s
sys 0m0.029s
with npm install -g nbb@latest
I get:
$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)' 0.10s user 0.02s system 95% cpu 0.119 total
$ which nbb
/home/ingy/.nvm/versions/node/v16.13.1/bin/nbb
$ time node -e 1
real 0m0.041s
I remember versions where it went up to the 0.300
areaglad they fixed it 🙂
node also supports building images like graalvm, this might fix the startup issue even more, but that's another rabbit hole to get into
but paradoxically bun takes longer to run nbb since it first checks if there is stuff to transpile I believe
>
$ which nbb
> /home/ingy/.nvm/versions/node/v16.13.1/bin/nbb
NVM (node version manager) might also slow things down with the “shim to right version”what I'm wondering most for YS is that I need to compile to a shared lib to bind to every language. if I could build a shared lib with nodejs that would be pretty rad. (target platform wise)
I don't know about creating a shared library, but bun lets you use shared libraries pretty easily
$ time /home/ingy/.nvm/versions/node/v16.13.1/bin/node -e 1
real 0m0.049s
that's the best of 3 🤷Forgot about this one:
time deno run -A npm:nbb -e '(+ 1 2 3)'
6
deno run -A npm:nbb -e '(+ 1 2 3)' 0.06s user 0.01s system 62% cpu 0.115 total