hashobject / perun

Programmable static site generator built with Clojure and Boot (HELP NEEDED!)
https://perun.io
Eclipse Public License 1.0
351 stars 38 forks source link

Move to babaska? #247

Open arichiardi opened 4 years ago

arichiardi commented 4 years ago

I have been flirting with the idea of moving away from boot for my blog but not from perun.

The main advantage that I see there is startup time and possibly, but not sure about that, rendering time.

I am thinking some code could be created to handle the tasks and use the same Java libraries for it.

Mainly asking feedback on this, not sure it is worth it also but boot's maintainance could also be a factor here.

Thanks!

allentiak commented 4 years ago

Ciao, @arichiardi! Thanks for bringing this up!

Please read my answer in https://github.com/hashobject/perun/issues/241#issuecomment-633280532_

Best, Leandro

arichiardi commented 3 years ago

After closer inspection I am not sure it is possible to run arbitrary Java libs in babashka but I might be wrong.

arichiardi commented 3 years ago

Let me ask directly to @borkdude.

We have dependencies in here like:

https://github.com/hashobject/perun/blob/7d48f735e2bd66a4d93187900889ca617c5db92d/src/io/perun.clj#L403-L404

or [org.asciidoctor/asciidoctorj "2.0.0"] and even [org.apache.lucene/lucene-analyzers-common "8.4.1"]

If we built a classpath with those in it, would babashka be able to use them all?

It's a long shot and sorry about a bit of newbie-ness here :smile:

borkdude commented 3 years ago

@arichiardi Babashka is only able to use Java classes that have been explicitly added into the native image. If you want to create something like babashka, but for static site generation, you will probably have to make your own GraalVM native-image project. Bootleg has done something similar: https://github.com/retrogradeorbit/bootleg

At work we are currently migration away from boot and running some tasks in a separate JVM, while also still using boot in another one. We use this babashka script for it:

#!/usr/bin/env bb

(ns dev (:require [clojure.string :as str]))

(require '[babashka.process :refer [$ destroy-tree *defaults*]])

(alter-var-root #'*defaults* assoc
                :out :inherit
                :err :inherit
                :shutdown destroy-tree)

(defn cljs []
  ($ "./clojure" "-A:frontend:cljs/dev"))

(defn less []
  ($ "./clojure" "-A:frontend:less/dev"))

(defn clojure []
  ^{:inherit true} ($ "./boot" "dev"))

(cljs)
(less)
(-> @(clojure) :exit (System/exit))
arichiardi commented 3 years ago

If you want to create something like babashka, but for static site generation, you will probably have to make your own GraalVM native-image project.

Thank you for confirming that's what I was thinking too.

arichiardi commented 3 years ago

Bootleg has done something similar

Thanks for the heads up, however perun here does a lot more nice things than just rendering (atom, lessc, ...). That's why IMHO is worth keeping it going :smile: