babashka

Native, fast starting Clojure interpreter for scripting

EPL-1.0 License

Downloads
78.5K
Stars
3.8K
Committers
116

Bot releases are hidden (Show)

babashka -

Published by borkdude over 4 years ago

  • Fix: --uberscript: do not execute code while analyzing code
  • New: introduce -- option to stop parsing args and pass the remaining to *command-line-args* (#250)
  • Fix location of failing test (#249)
babashka -

Published by borkdude over 4 years ago

New in babashka v0.0.67:

  • Add clojure.test:

    $ bb "(require '[clojure.test :as t]) (t/is (= 4 5))"
    
    FAIL in () (test.clj:370)
    expected: (= 4 5)
      actual: (not (= 4 5))
    false
    

    This makes the spartan.test library deprecated. The missing.test.assertions library now also works with babashka.

  • Add hierarchies (derive, isa?, etc.)

  • Add multimethods

  • Although babashka comes with clojure.data.csv built in, the newest version can now also run the clojure-csv library.

  • Add StringBuilder:

$ bb '(time (loop [s "" i 0] (if (< i 100000) (recur (str s (char 67)) (inc i)) (count s))))'
"Elapsed time: 10446.353326 msecs"
100000

$ bb '(time (let [sb (StringBuilder. "")] (dotimes [i 100000] (.appendCodePoint sb 67)) (count (str sb))))'
"Elapsed time: 840.823386 msecs"
100000
  • #245: add aliases for -i -O and -I -o
babashka -

Published by borkdude over 4 years ago

New

  • Add alter-meta! and reset-meta!
  • Support :reload in require
  • Add clojure.core/time macro

Enhancements

  • :row and :col metadata were renamed to :line and :column which is what Clojure tooling like Chlorine expects.
  • add Throwable to default imports
  • #232: better error message when requiring unknown namespace
  • #243: ns form doesn't work with socket REPL
  • #243: *ns* should be controllable per socket REPL connection
  • #213: allow -e argument to be repeated
babashka -

Published by borkdude almost 5 years ago

Enhancements

Fix bug when requiring external library namespace: local bindings of the calling namespace should be reset.

babashka -

Published by borkdude almost 5 years ago

Enhancements

Performance enhancements. Compare these two runs between bb 0.0.64 and 0.0.61. With 0.0.64 it runs about 8x faster.

$ time ./bb-0.0.64 "(loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val))"
1000000
./bb-0.0.64   1.32s user 0.07s system 99% cpu 1.400 total
$ time ./bb-0.0.61 "(loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val))"
1000000
./bb-0.0.61   11.42s user 0.08s system 99% cpu 11.507 total

Special thanks to clj-async-profiler.

babashka -

Published by borkdude almost 5 years ago

New

Enhancements

  • Performance improvements with regards to hot loops. Although hot loops are not a strength of babashka compared to JVM Clojure, they are up to around 4x faster now.
  • #239: Fix issue with clj-http-lite
babashka -

Published by borkdude almost 5 years ago

New

  • Add babashka.classpath/add-classpath. This function allows to add to the classpath dynamically:
(require '[babashka.classpath :refer [add-classpath]]
         '[clojure.java.shell :refer [sh]])
(def medley-dep '{:deps {medley {:git/url "https://github.com/borkdude/medley"
                                 :sha "91adfb5da33f8d23f75f0894da1defe567a625c0"}}})
(def cp (:out (sh "clojure" "-Spath" "-Sdeps" (str medley-dep))))
(add-classpath cp)
(require '[medley.core :as m])
(m/index-by :id [{:id 1} {:id 2}]) ;;=> {1 {:id 1}, 2 {:id 2}}
  • Add alias, find-ns, the-ns, ns-aliases, ns-publics, clojure.repl/dir
  • Support pre- and post-conditions in fn

Enhancements

  • #219: better error message for unrecognized command line arguments
  • #221: print name of exception in case of error and when not using --verbose
babashka -

Published by borkdude almost 5 years ago

New

  • add .., any?, inst?, macroexpand, macroexpand-1, clojure.repl/demunge / clojure.main/demunge

Most of this was added to support an interpreted version of clojure.spec:

spartan.spec.

Enhancements

  • #227: remove usage of Unix-specific classes.
  • interop improvements:
$ bb "(type (. System (getProperties)))"
java.util.Properties

now works, whereas before it didn't.

  • case now supports a list, as it should:
$ bb '(case 1 (1 2 3) :match)'
:match
babashka -

Published by borkdude almost 5 years ago

New

  • Add alter-var-root.
  • Add locking:
$ bb '
(def x (volatile! 0)) (defn inc! [] (vswap! x inc)) (doseq [f (map (fn [_] (future (inc!))) (range 1000))] @f) @x'
994
$ bb '
(def o (Object.)) (def x (volatile! 0)) (defn inc! [] (locking o (vswap! x inc))) (doseq [f (map (fn [_] (future (inc!))) (range 1000))] @f) @x'
1000

See the difference?

  • Use edamame for parsing function literals:
$ bb "\`~'#(inc %)"
(fn [%1] (inc %1))

In previous versions the above example would return a map with implementation details that weren't so pretty to look at.

babashka -

Published by borkdude almost 5 years ago

Enhancement

babashka -

Published by borkdude almost 5 years ago

New

  • Add clojure.stacktrace
  • Support metadata in defn
  • Add functions + classes to support medley
babashka -

Published by borkdude almost 5 years ago

Misc improvements

  • Fix problem with using a var created in a different namespace with declare
  • Add java.util.UUID
  • Add defonce
  • Add clojure.lang.IOBj
  • Add :name and :ns metadata to vars
babashka -

Published by borkdude almost 5 years ago

New

Add the java.net.Socket and java.net.ServerSocket classes.

babashka -

Published by borkdude almost 5 years ago

New

  • #200: add shell/with-sh-dir and shell/with-sh-env
  • #200: IllegalArgumentException can now be used unqualified
  • #200: add java.nio.file.LinkOption

Fixes

  • #199: java interop of the form (. "foo" isEmpty) didn't work
babashka -

Published by borkdude almost 5 years ago

New

Add clojure.java.io/resource.

babashka -

Published by borkdude almost 5 years ago

Fix: arguments to require should be evaluated.

babashka -

Published by borkdude almost 5 years ago

Fix bug when using a classname in a syntax-quote.

babashka -

Published by borkdude almost 5 years ago

New

This release adds the --uberscript option:

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

babashka -

Published by borkdude almost 5 years ago

Enhancements

  • Add some missing functions to cheshire.core like parsed-seq:
$ bb '(json/parsed-seq (io/reader (java.io.StringReader. "1 1 1")))'
(1 1 1)
  • set *command-line-args* to nil instead of () when no args are provided, like Clojure
babashka -

Published by borkdude almost 5 years ago

New

  • #154 Expose clojure.main/repl to babashka:

Example:

$ bb '(clojure.main/repl :init #(println "Welcome to lambda REPL!") :prompt #(print "λ> "))'
Welcome to lambda REPL!
λ>

With this addition, babashka is now able to run the limit-break library, a debug REPL:

$ export BABASHKA_CLASSPATH="$(clojure -Sdeps '{:deps {limit-break {:git/url "https://github.com/technomancy/limit-break" :sha "050fcfa0ea29fe3340927533a6fa6fffe23bfc2f" :deps/manifest :deps}}}' -Spath)"

$ bb "(require '[limit.break :as lb]) (let [x 1] (lb/break))"
Babashka v0.0.49 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

break> x
1