Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Native CLI tooling with Clojure on GraalVM

Rahul De
November 13, 2019

Native CLI tooling with Clojure on GraalVM

Deck for building native cli tooling with Clojure on GraalVM

Rahul De

November 13, 2019
Tweet

More Decks by Rahul De

Other Decks in Technology

Transcript

  1. About me (❤ FOSS) ( Diversity) (❤ Sustainable Living) (

    Vegan Food) (constantly [:❤ :Clojure :Infrastructure]) Backend and Infrastructure Developer Compilers, VMs and High Performance https://github.com/lispyclouds https://twitter.com/lispyclouds
  2. CLI tools and native compilation Instant startup time ⚡ Easy

    and lightweight installation Short lived commands Portable and easy distributions without too much system requirements Low resource consumption Simple, obvious naming convention and intuitive CLI arguments
  3. When not to use native code Long running applications like

    web servers Dynamic runtime behaviour requiring optimizations Dynamic loading of dependencies and updates Most(80%+) of the application use-cases are more suited for JIT compilation.
  4. Clojure and the JVM Clojure is dynamic JVM reflection (Clojure

    warns with (set! *warn-on-reflection* true)) The JVM byte code itself is dynamic JIT and the design of the JVM
  5. Rust Immutable by default with functional features Super fast Fully

    AOT compiled GC less automatic memory management Safe Low resource consumption Slow compile times Less mature libs
  6. Haskell For me, the only other thing as cool as

    Clojure! Fast compiled binaries Very very safe Mature Slow compile times Practically zero dev tooling, slow dev iterations High memory consumption at times
  7. Python Very mature Pre installed in most *nix systems Dynamic

    Vast and mature tooling and libs Imperativeness is idiomatic Concurrency is hard Package management is hard Unpredictable resource consumption
  8. Go Super fast compile times Ubiquitous in CLI world Easy

    deployment Vast stdlib Imperative, difficult to write FP Not a productive language IMO for large projects
  9. ClojureScript Runs on Node.js (Lumo) or JavaScriptCore (Planck) Quick startup

    without JVM overhead Decent stdlib support from Node world Mature and robust libs missing from JVM world Poor parallelism High memory consumption Complex deployment and not available for archs other than AMDx64
  10. – The Oracle (probably not the one you’re thinking of)

    “When all hope was lost, there came our savior.”
  11. The one VM to rule them all? An umbrella project

    of various tools Works via the JVMCI since JDK 9 A JIT written in Java Natively available since JDK 10 Full Polyglot capabilities Truffle SDK Full native image generation with GC using SubstrateVM. (Great way to warm up your room) https://www.graalvm.org
  12. Wendy: Bob’s reference CLI and his SO Bob is a

    scalable, modular CI/CD platform (by your’s truly) https://github.com/bob-cd/bob exposed via REST. Wendy should be able to: Make HTTP calls Parse JSON Parse TOML build configuration Provide a full CLI to Bob via intuitive command line args Verify the build and plan the execution order (magical to write in Clojure) Stream build status, info, logs and artifacts from Bob (think Docker CLI) https://github.com/bob-cd/wendy Was in Python 3 untill the fateful commit aba8aad
  13. Building Wendy Standard Tool Wendy’s Choice HTTP Calls clj-http clj-http-lite

    JSON Parsing cheshire cheshire TOML Parsing clj-toml Night-Config (really cool lib!) CLI args parsing • tools.cli • clj-matic argparse4j
  14. Resources • https://www.graalvm.org/ • https://github.com/bob-cd/wendy • https://github.com/taylorwood/ clj.native-image • https://www.graalvm.org/docs/

    reference-manual/aot-compilation/ • https://www.graalvm.org/docs/ reference-manual/polyglot/ • https://github.com/lread/clj- graal-docs