All Projects → borkdude → jayfu

borkdude / jayfu

Licence: EPL-1.0 license
Jayfu is a tutorial on how to create a Clojure CLI with GraalVM native-image and SCI.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to jayfu

LogoRRR
A log viewer which visualises log events such that it is easy to identify problems or events of interest. This app was implemented using Scala and JavaFX, GluonHQ toolchain and GraalVM as platform.
Stars: ✭ 40 (-20%)
Mutual labels:  graalvm-native-image
graal-config
GraalVM native-image configurations distribution for Clojure libraries
Stars: ✭ 21 (-58%)
Mutual labels:  graalvm-native-image
tools-deps-native
Run tools-deps-alpha as a native binary.
Stars: ✭ 30 (-40%)
Mutual labels:  graalvm-native-image
serverless-graalvm-demo
Sample serverless application written in Java compiled with GraalVM native-image
Stars: ✭ 132 (+164%)
Mutual labels:  graalvm-native-image
kafka-consumer-lag-monitoring
Client tool that exports the consumer lag of Kafka consumer groups to Prometheus or your terminal
Stars: ✭ 45 (-10%)
Mutual labels:  graalvm-native-image
piu.clj
Simple pastebin
Stars: ✭ 14 (-72%)
Mutual labels:  graalvm-native-image
GraalVMREPL
REPL (read–eval–print loop) shell built on top of JavaFX and GraalVM stack, incorporating GraalJS, GraalPython, TruffleRuby and FastR
Stars: ✭ 31 (-38%)
Mutual labels:  graalvm-native-image
lucene-grep
Grep-like utility based on Lucene Monitor compiled with GraalVM native-image
Stars: ✭ 160 (+220%)
Mutual labels:  graalvm-native-image

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].