babashka

Native, fast starting Clojure interpreter for scripting

EPL-1.0 License

Downloads
78.5K
Stars
3.8K
Committers
116

Bot releases are visible (Hide)

babashka -

Published by borkdude almost 5 years ago

babashka -

Published by borkdude almost 5 years ago

New

  • Support for :refer-clojure + :exclude in ns form
  • Add condp
  • Add defn-
  • Add instance?
  • Add delay
  • Use current file in error messages
  • Add support for java.nio.file.Paths

Fixes

  • require can now be used with a single symbol instead of a sequential collection
  • When error happens during namespace load, the namespace will be removed as if it has never existed (like in Clojure)
  • Fix crash when ns form only has docstring and no other forms
babashka -

Published by borkdude almost 5 years ago

New:

babashka -

Published by borkdude almost 5 years ago

  • #173: Following up on the breaking change in v0.0.44, <input> is now renamed to *input*, which is now also a dynamic var, which looks and feels more idiomatic.
babashka -

Published by borkdude almost 5 years ago

  • https://github.com/borkdude/sci/issues/188: add letfn
  • #173: BREAKING: rename *in* to <input> (in the user namespace). The name was a poor choice for two reasons. It shadowed clojure.core/*in*. Also, the value was not a dynamic var, but the earmuffs suggested otherwise.
  • #174: add clojure.edn/read
  • fix clojure.string/re-quote-replacement
babashka -

Published by borkdude almost 5 years ago

  • #149: Add support for java.time API. This is an example how you can print the current time in California:
#!/usr/bin/env bb
(def now (java.time.ZonedDateTime/now))
(def LA-timezone (java.time.ZoneId/of "America/Los_Angeles"))
(def LA-time (.withZoneSameInstant now LA-timezone))
(def pattern (java.time.format.DateTimeFormatter/ofPattern "HH:mm"))
(println (.format LA-time pattern))
  • #160: Add support for java.lang.ProcessBuilder. See docs. This replaces the conch namespace (BREAKING).

  • #162: Add support for java.util.Base64:

$ bb '(String. (.decode (java.util.Base64/getDecoder) "YmFiYXNoa2E="))'
"babashka"
  • Add support for java.lang.Math:
$ bb '(Math/pow 2 3)'
8.0
babashka -

Published by borkdude almost 5 years ago

v0.0.42 has a fix for using nested syntax quotes:

user=> `(let [x# 1] `~x#)
;;=> (clojure.core/let [x__1__auto__ 1] x__1__auto__)
babashka -

Published by borkdude almost 5 years ago

New

Support for --classpath / -cp, BABASHKA_CLASSPATH and --main / -m.
Read more about it here:

https://github.com/borkdude/babashka/#classpath

babashka -

Published by borkdude almost 5 years ago

  • #147 Add cheshire. The cheshire.core namespace is available via the json alias in the user namespace:
$ bb '(println (json/encode {:a 1}))'
{"a":1}

$ bb "(require '[cheshire.core :as cheshire]) (cheshire/generate-string {:a 1})"
"{\"a\":1}"
babashka -

Published by borkdude almost 5 years ago

  • #137: implement console REPL. Babashka will now start a repl when no arguments are provided, or with the argument --repl. Using rlwrap is recommended.
$ rlwrap bb
Babashka v0.0.39 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (+ 1 2 3)
6
babashka -

Published by borkdude almost 5 years ago

New

$ bb '(def ^:dynamic *x* 1) (binding [*x* 10] (prn *x*)) (prn *x*)'
10
1
  • Add java.nio.file.attribute classes (thanks @holyjak)
babashka -

Published by borkdude almost 5 years ago

  • Add clojure.core/walk
  • Add examples/tree.clj
  • Fix *command-line-args* when using ns form
babashka -

Published by borkdude almost 5 years ago

  • Fix dotimes
  • Add initial support for java.nio.file.Files
babashka -

Published by borkdude almost 5 years ago

New

  • Add support for in-ns and ns:
$ cat script.clj
(ns foo (:require [clojure.string :as str]))
::str/foo

$ bb script.clj
:clojure.string/foo

Note that require still does not load external files. This will probably be added in a future release.

babashka -

Published by borkdude almost 5 years ago

babashka -

Published by borkdude almost 5 years ago

Upgrade to GraalVM 19.3.0. This means that SSL now works without any additional configuration due to static linking of the necessary library:

$ bb '(-> (slurp "https://www.clojure.org") (subs 0 55))'
"<!DOCTYPE html>\n<!-- This site was created in Webflow. "
babashka -

Published by borkdude almost 5 years ago

babashka -

Published by borkdude almost 5 years ago

Bugfix release: see #117.

babashka -

Published by borkdude almost 5 years ago

Bump sci with performance enhancement: borkdude/sci#154

babashka -

Published by borkdude almost 5 years ago

New

  • #112: Add binding, with-out-str and with-in-str:
$ ./bb '(let [w (java.io.StringWriter.)] (binding [*out* w] (println "hello")) (str w))'
"hello\n"

$ ./bb "(count (with-out-str (println \"hello\")))"
6

$ ./bb '(with-in-str "hi" (read-line))'
"hi"

Notes:

  • Currently binding only works with clojure.core/*in* and clojure.core/*out*
  • *in* has a special meaning in babashka expressions, but you can refer to Clojure's *in*by fully qualifying it: clojure.core/*in*.