Giter VIP home page Giter VIP logo

jayfu's Introduction

jayfu

Learn how to make a native Clojure CLI with GraalVM native-image and SCI!

This example is set up around an example CLI, jayfu, that reads JSON from stdin and transforms it using a function which is dynamically evaluated:

$ echo '{"a": {"b": 2}}' | ./jayfu -f '#(-> % :a :b)' -k keyword
2

See this talk which guides you through this project.

Prerequisites

  • Download GraalVM. Just download it to your Downloads folder and unzip the archive. No further installation required. This tutorial is based on version 21.1.0 JDK11.

  • Set the GRAALVM_HOME environment variable. E.g.:

    export GRAALVM_HOME=/Users/borkdude/Downloads/graalvm-ce-java11-21.1.0/Contents/Home

  • To run with Clojure or Java, you will need to have a Java 8 or 11 installation available. You can also use the downloaded GraalVM for this.

  • Install babashka (0.4.1 or higher).

Windows

Always use cmd.exe for executing GraalVM compilation, do not use PowerShell.

On Windows, install Visual Studio 2017 or 2019 and in cmd.exe load:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

This will set the right environment variables for GraalVM.

After this you should be able to run bb native-image.

Tasks

To see all available tasks in this project, run bb tasks:

$ bb tasks
The following tasks are available:

run-main     Run main
uberjar      Builds uberjar
run-uber     Run uberjar
graalvm      Checks GRAALVM_HOME env var
native-image Builds native image

Run

To run this example using Clojure, run:

$ bb run-main --help
Usage:
  -f, --func FUNCTION  identity  The function applied to JSON from stdin
  -k, --key-fn KEY-FN  identity  The function applied to keywords
  -h, --help

$ echo '{"a": {"b": 2}}' | bb run-main -f '#(-> % :a :b)' -k keyword
2

Build

To build the native image, run:

$ bb native-image

This should produce a binary called jayfu:

$ echo '{"a": {"b": 2}}' | ./jayfu -f '#(-> % :a :b)' -k keyword
2

Talk

See this talk which guides you through this project.

Tutorial

Coming soon.

License

Copyright © 2021 Michiel Borkent

Distributed under the EPL License. See LICENSE.

jayfu's People

Contributors

borkdude avatar pwhittin avatar wongjoel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jayfu's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.