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 - Support for JDBC + PostgresQL!

Published by borkdude over 4 years ago

  • #317: add clojure.repl/pst

  • #371: fix argument parsing: using --nrepl-server without port fails when another argument followed

  • #372: add support for next.jdbc and PostgresQL

    (require '[next.jdbc :as jdbc]
             '[clojure.pprint :refer [print-table]])
    (defn query []
      (let [db {:dbtype   "postgres"
                :dbname   "medline"
                :host     "localhost"
                :port     5555
                :user     "develop"
                :password "develop"}]
        (jdbc/execute!
         (jdbc/get-datasource db)
         ["select main_id, published from who_ictrp limit 5"])))
    (print-table (query))
    
    $ ./bb /tmp/jdbc.clj
    | :who_ictrp/main_id | :who_ictrp/published |
    |--------------------+----------------------|
    |       NCT04085224 |           2019-09-10 |
    |       NCT04086225 |           2019-01-17 |
    |        NCT04084184 |           2019-03-15 |
    |        NCT04084197 |           2018-12-19 |
    |        NCT04085042 |           2020-06-01 |
    

    Note: at the moment, only PostgresQL is supported. MySQL and sqlite are under investigation. If you have any working GraalVM examples of these databases in combination with Clojure and JDBC, let me know.

    Special thanks to @yogthos for providing an example at https://github.com/yogthos/graal-web-app-example/tree/postgres.

  • borkdude/babashka.curl#16: parse errors into :err value

  • clojure.core/load-string now can parse multiple values and resets to the original namespace

  • add BigDecimal and ClassNotFoundException

  • #375: add clojure.pprint/print-table

babashka -

Published by borkdude over 4 years ago

  • #370: fix compatibility with clojure.math.combinatorics
bb --classpath "$(clojure -Spath -Sdeps '{:deps {org.clojure/math.combinatorics {:mvn/version "0.1.6"}}}')" \
    -e "(use 'clojure.math.combinatorics) (permutations [:a :b])"
((:a :b) (:b :a))
babashka -

Published by borkdude over 4 years ago

New

Enhancements

  • #364: better error message for invalid interop form
  • #367: add docstrings for cheshire.core namespace
  • #362: preserve location metadata in fn literal in error messages
  • #368: loop bindings can refer to preceding ones like in let
babashka -

Published by borkdude over 4 years ago

Fixes

  • borkdude/babashka.curl#17: fix resource leak. File handles to temporary files (used for header parsing) were left open.
  • borkdude/sci#306: fix for clojure.repl/dir when given a non-existent namespace

New

  • #317: add clojure.repl/apropos and clojure.repl/source (only works with code loaded from source, not with native code)
  • resolve can now be used as a normal function
  • Add clj-yaml.core mark and unmark
babashka -

Published by borkdude over 4 years ago

  • #263: add clj-commons/clj-yaml
  • Refer all vars from the clojure.repl namespace in REPL and Socket REPL at startup
  • #351: exit REPL on ctrl-D. This didn't work after you evaluated an expression.
  • Add java.lang.Comparable. This makes bb compatible with the arrangement library.
  • Add java.net.DatagramSocket, java.net.DatagramPacket and java.net.InetAddress. This makes bb suited for implementing a statsd client.
  • borkdude/babashka.curl#4: support files in :form-params
babashka -

Published by borkdude over 4 years ago

  • #317: add clojure.repl/find-doc

  • #318: support :refer :all and :use to enhance compatibility with existing Clojure code.

  • borkdude/sci#303: add support for :rename in :require

  • #353: when using a main argument (-m foo.bar), the system property babashka.main will be set.
    This is useful in the situation when a script has a -main function but must also be able to execute when invoked as a file with the -f option:

    (defn -main [& args]
      ...)
    
    (when-not (System/getProperty "babashka.main")
      (apply -main *command-line-args*))
    
babashka -

Published by borkdude over 4 years ago

  • #344: add nREPL documentation

  • #345: add test for .deleteOnExit

  • #346: implement nREPL close and ls-sessions operations

  • #347: fix issue with reader conditional

  • #348: support multiple top level forms in an nREPL eval op. This fixes support for vim fireplace:

    Screenshot 2020-04-11 23 10 50

  • #349: send output to client while evaluating expression in nREPL server

babashka -

Published by borkdude over 4 years ago

Fixes:

  • #340: Fix interop with PushbackInputStream class
  • #342: use BufferedOutputStream when writing bencode in nREPL server
  • borkdude/babashka.curl#11 and borkdude/babashka.curl#13: babashka.curl now parses headers via a temporary file. This fixes issues when there are multiple status codes due to 100 Continue.
babashka -

Published by borkdude over 4 years ago

  • Add java.lang.Runtime to support shutdown-hooks. See docs.
babashka -

Published by borkdude over 4 years ago

  • Fixes for the new nREPL serve (#329, #331)
  • Add the while macro (borkdude/sci#296)
babashka - nREPL server!

Published by borkdude over 4 years ago

Thanks @jeroenvandijk, @rymndhng and @lispyclouds for contributing to this release. Also thanks to @bbatsov for his help on implementing an nREPL server.

Additions

  • #301: add nREPL server. You can start an nREPL server with bb --nrepl-server 1667 and then connect to it from your favorite editor.

  • #307: add java.io.FileReader

  • #310: add java.nio.FileSystem and java.nio.FileSystems

  • #312: add .getMessage method on ex-info

  • add clojure.core/*print-length*

  • add java.lang.Byte

  • add bencode.core's read-bencode and write-bencode functions

  • add note taking app example

Breaking changes

Always check CHANGES.md for breaking changes before upgrading.

  • babashka.curl functions now return a response map with :status, :headers and :body, whereas before it only returned the body.

Enhancements / fixes:

  • #308: print exception name in REPL
  • #316: upgrade GraalVM to 19.3.1
  • #325: find-ns didn't return nil for non-existing namespace
  • require is now a normal function instead of a special form
  • port CircleCI config to Github actions
babashka -

Published by borkdude over 4 years ago

  • Fix bug with *input* when used in code from classpath.
  • Introduce BABASHKA_DISABLE_PIPE_SIGNAL_HANDLER env variable for AWS Lambda
babashka -

Published by borkdude over 4 years ago

  • #264: add the cognitect.transit namespace. Note: only reader, read, writer and write are currently supported.
    $ echo "{:a 1}" | jet --to transit | ./bb '(transit/read (transit/reader System/in :json))'
    {:a 1}
    
  • Add java.lang.NumberFormatException, java.lang.RuntimeException,
    java.util.MissingResourceException and java.util.Properties classes.
    This was done to support the cprop library:
    $ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {cprop {:mvn/version "0.1.16"}}}')
    $ export ANSWER=43
    $ bb "
    (require '[cprop.core :refer [load-config]])
    (spit \"config.edn\" {:answer 42})
    (load-config :file \"config.edn\")"
    {:answer 43}
    
  • Add ns-unmap. Thanks @sogaiu.
  • #293 restore *ns* after load-file
  • Bump babashka.curl to 3104d234a63fca71f0d3557c5d3dc23f4fbc294f
  • Include curl in babashka Docker image
  • Fix issue with catching exceptions (discovered while trying to support the cprop library)
  • Default to port 1666 for --socket-repl option
babashka - babashka.curl: a tiny wrapper around curl

Published by borkdude over 4 years ago

Thanks @lispyclouds for contributing to this release.

Fixed issues

  • #283: support writer arg in clojure.pprint/pprint
  • upgrade to clojure 1.10.2-alpha1 and remove related workarounds
  • #284: add clojure.core/eval and clojure.core/read-string
  • add babashka.curl:
$ ./bb '(-> (curl/get "https://clojure.org") (subs 0 10))'
"<!DOCTYPE "

See babashka.curl for usage.

babashka - Hack on the train from ClojureD back to The Netherlands with @jeroenvandijk

Published by borkdude over 4 years ago

Thanks @sogaiu and @jeroenvandijk for contributing to this release.

  • support docstrings for spit, slurp and file-seq
  • add re-groups and re-matcher
  • #255: support clojure.core.async/go macro by falling back on threads
  • #280: fix bug in try body
babashka -

Published by borkdude over 4 years ago

Thanks @lispyclouds for contributing to this release.

  • Revert static build for linux which was introduced in 0.0.72
  • Provide separate optional linux-static build
  • Smaller Docker image
babashka -

Published by borkdude over 4 years ago

Thanks to @nate and @mbjarland for contributing to this release.

New

  • Add when-some and if-some
  • Add java.time.temporal.ChronoUnit class
  • Compile linux executable with --static option so it works on Alpine linux
babashka -

Published by borkdude over 4 years ago

  • Check arity of if (thanks @jeroenvandijk)
  • Implement clojure.repl/doc
  • Fix tools.cli alias in user namespace
  • Support metadata on namespaces (which display in clojure.repl/doc)
  • Add ns-imports, ns-refers and ns-map
  • Add clojure.pprint/pprint backed by fipp
  • Potentially BREAKING: Change behavior of reader conditionals: the :clj branch is taken when present and when not preceded by a :bb branch.
babashka -

Published by borkdude over 4 years ago

  • Added in clojure.core: satisfies?, promise, deliver, prefers

  • Support checking if something is a clojure.core.async channel:

    $ bb '(satisfies? clojure.core.async.impl.protocols/ReadPort (async/chan))'
    true
    
  • Add java.lang.Long, java.math.BigInteger and java.security.MessageDigest.

  • Babashka now has a Dockerfile and is published to Docker hub.

Thanks @stijnopheide, @cldwalker, @jeroenvandijk and @hden for their contributions.

babashka -

Published by borkdude over 4 years ago

Fix for BABASHKA_PRELOADS: the *ns* var was not bound when evaluating code.