doc
This commit is contained in:
parent
c876b67f95
commit
17a1a2f809
1 changed files with 25 additions and 17 deletions
42
README.md
42
README.md
|
|
@ -19,21 +19,36 @@ $ bb '(vec (dedupe *in*))' <<< '[1 1 1 1 2]'
|
||||||
If you're a bash expert, you probably don't need this. But for those of us who
|
If you're a bash expert, you probably don't need this. But for those of us who
|
||||||
can use a bit of Clojure in their shell scripts, it may be useful.
|
can use a bit of Clojure in their shell scripts, it may be useful.
|
||||||
|
|
||||||
Babashka runs as a binary and uses [sci](https://github.com/borkdude/sci) for
|
Babashka runs as a binary which results in faster startup times:
|
||||||
interpreting Clojure, which results in faster startup times:
|
|
||||||
|
|
||||||
``` shellsession
|
``` shellsession
|
||||||
$ time clojure -e "(require '[clojure.java.shell :as shell])" ./download_html.clj
|
$ time clojure -e "(+ 1 2 3)"
|
||||||
2.15s user 0.17s system 242% cpu 0.959 total
|
6
|
||||||
|
clojure -e "(+ 1 2 3)" 3.29s user 0.32s system 99% cpu 3.638 total
|
||||||
|
|
||||||
$ time bb -f ./download_html.clj
|
$ time plk -e '(+ 1 2 3)'
|
||||||
0.00s user 0.00s system 69% cpu 0.010 total
|
6
|
||||||
|
plk -e '(+ 1 2 3)' 1.34s user 0.16s system 127% cpu 1.172 total
|
||||||
|
|
||||||
|
$ time bb '(+ 1 2 3)'
|
||||||
|
6
|
||||||
|
bb '(+ 1 2 3)' 0.01s user 0.01s system 37% cpu 0.046 total
|
||||||
```
|
```
|
||||||
|
|
||||||
A trade-off is that [sci](https://github.com/borkdude/sci) implements only a
|
It uses [sci](https://github.com/borkdude/sci) for interpreting Clojure. A
|
||||||
subset of Clojure. If you need more, feel free to post an issue or check out
|
trade-off is that [sci](https://github.com/borkdude/sci) implements only a
|
||||||
other Clojure scripting
|
subset of Clojure. Also, execution time may be slower than Clojure on the JVM or
|
||||||
[projects](https://github.com/borkdude/babashka#related-projects).
|
(self-hosted) ClojureScript for more CPU-intensive calculations like:
|
||||||
|
|
||||||
|
``` shellsession
|
||||||
|
(last (take 1000000 (repeatedly #(+ 1 2 3))))
|
||||||
|
```
|
||||||
|
|
||||||
|
This would take 5 seconds using babashka, around half a second using self-hosted
|
||||||
|
ClojureScript and around 200ms in Clojure on the JVM.
|
||||||
|
|
||||||
|
So the sweet spot for babashka is executing tasks from the command line where
|
||||||
|
fast startup time is preferred, in the same space where you would use bash.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
|
|
@ -80,13 +95,6 @@ bb [ --help ] | [ --version ] | ( [ -i ] [ -o ] | [ -io ] ) [ --stream ] ( expre
|
||||||
|
|
||||||
Type `bb --help` to see a full explanation of the options.
|
Type `bb --help` to see a full explanation of the options.
|
||||||
|
|
||||||
The input is read as EDN by default. If the `-i` flag is provided, then the
|
|
||||||
input is read as a string which is then split on newlines. The output is printed
|
|
||||||
as EDN by default, unless the `-o` flag is provided, then the output is turned
|
|
||||||
into shell-scripting friendly output. To combine `-i` and `-o` you can use
|
|
||||||
`-io`. When using the `--stream` option the expression is executed for every
|
|
||||||
line or EDN value from stdin.
|
|
||||||
|
|
||||||
The `clojure.core` functions are accessible without a namespace alias.
|
The `clojure.core` functions are accessible without a namespace alias.
|
||||||
|
|
||||||
The following Clojure namespaces are required by default and only available
|
The following Clojure namespaces are required by default and only available
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue