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

New

Java interop via reflection

Java interop is now done via reflection. This means we don't have to write function wrappers to fake interop anymore.

The following Java classes are supported.

  • ArithmeticException
  • AssertionError
  • Boolean
  • Class
  • Double
  • Exception
  • clojure.lang.ExceptionInfo
  • Integer
  • java.io.File
  • java.util.regex.Pattern
  • String
  • System
  • Thread

We can now have (Double/parseDouble "2.0"), Integer/MAX_VALUE or (.write (io/writer "foo")) by just adding the class entries to reflection.json and the :classes option to sci.

import

The import macro now works: (import '[clojure.lang.ExceptionInfo]).

eval

$ ./bb "(eval '(+ 1 2 3))"
6

See #107.

babashka -

Published by borkdude almost 5 years ago

babashka -

Published by borkdude almost 5 years ago

New

  • #95: add clojure.data.csv. Thanks to @plexus who ported clojure.data.csv to GraalVM compatible code.
babashka -

Published by borkdude almost 5 years ago

Upgrade sci:

babashka -

Published by borkdude almost 5 years ago

Fix

  • #89 Extra vars in clojure.core that were not in sci can now be used with a fully qualified symbol (e.g.clojure.core/println)
babashka -

Published by borkdude almost 5 years ago

Fixes

  • fixes for #85, #86 and #87
babashka -

Published by borkdude almost 5 years ago

New

Babashka now supports reader conditionals.

babashka -

Published by borkdude about 5 years ago

New

Add macros: doto, declare, cond->, cond->>, if-let and when-let

Fixes and improvements.

Syntax-quote can now be nested. Implemented auto-gensym in syntax-quote.

$ bb '`(let [x# 1] x#)'
(let [x__1__auto__ 1] x__1__auto__)
babashka -

Published by borkdude about 5 years ago

  • Upgrade edamame to v0.0.6 which fixes a bug when parsing the empty map.
  • Upgrade sci which adds with-meta.
babashka -

Published by borkdude about 5 years ago

New

Upgrade sci which now comes with support for try/catch/finally + defmacro.

babashka -

Published by borkdude about 5 years ago

  • added read-line
  • added more clojure.java.io functions
  • added loop macro
  • added for and doseq macros
  • added require
  • added Integer/parseInt
  • added clojure.tools.cli:
(require '[clojure.tools.cli :refer [parse-opts]])

(def cli-options
  ;; An option with a required argument
  [["-p" "--port PORT" "Port number"
    :default 80
    :parse-fn #(Integer/parseInt %)
    :validate [#(< 0 % 0x10000) "Must be a number between 0 and 65536"]]
   ["-h" "--help"]])

(:options (parse-opts *command-line-args* cli-options))
$ bb script.clj
{:port 80}
$ bb script.clj -h
{:port 80, :help true}
babashka -

Published by borkdude about 5 years ago

  • #56 add clojure.core.async. See docs.
  • #55 expose sig/pipe-signal-received?:
$ bb '((fn [x] (println x) (when (not (sig/pipe-signal-received?)) (recur (inc x)))) 0)' | head -n2
1
2
  • sci #54: support recur

  • #60: fix shebang /usr/bin/env support under linux (thanks @plexus)

babashka -

Published by borkdude about 5 years ago

New

#48: be able to spawn and kill processes. See docs. Also see below example at #50.

#49: add Thread/sleep

#50: add net/wait-for-it, a function that does the same as the famous bash script:

$ bb '
(def ws (conch/proc "python" "-m" "SimpleHTTPServer" "1777"))
(net/wait-for-it "localhost" 1777) (conch/destroy ws)'
  • Add future, atom, reset! and swap!

  • Support comment and #_ (uneval)

  • Support for *command-line-args* and *in* when running a socket REPL

babashka -

Published by borkdude about 5 years ago

  • fix #44
babashka -

Published by borkdude about 5 years ago

  • #41: implement socket REPL
  • #40: support -h as alias for --help
  • #34: upgrade to GraalVM 19.2.0
babashka -

Published by borkdude about 5 years ago

  • #35: make -i lazy. This allows expressions like:
$ yes | bb -io '(take 2 *in*)'
y
y

which would be the equivalent to:

$ yes | head -n2
  • #36: -I and -O options. These behave equivalently to -i and -o, but for EDN values:
$ bb -O '(repeat "dude")' | bb --stream '(str *in* "rino")' | bb -I '(take 3 *in*)'
("duderino" "duderino" "duderino")
babashka -

Published by borkdude about 5 years ago

  • #31 respect PIPE signal. This allows streaming "infinite" results and taking only the first n results using head:
$ ./bb -o '(range)' |
./bb --stream '(* *in* *in*)' |
head -n10
0
1
4
9
16
25
36
49
64
81

After printing the last number, all the processes exit.

babashka -

Published by borkdude about 5 years ago

Upgrade to sci 0.0.9 which outputs location info in case of an error.

$ ls | bb -i '(count *in)'
Could not resolve symbol: *in [at line 1, column 8]

$ ls | bb -i '(count *in*)'
15
babashka -

Published by borkdude about 5 years ago

babashka -

Published by borkdude about 5 years ago

Minor patch release.

  • Macros in data literals were not properly expanded in SCI
  • Undocumented some namespaces for cljdoc
  • Cljdoc couldn't analyze (:require [clojure.edn]) in a .cljc namespace