graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
2020-03-12T08:29:19.322600Z

Does it mean we could target C++ using Clojure haha?

2020-03-12T09:59:58.323400Z

Graalvm protip: you can always shell out to the jar you are trying to run πŸ™ˆ

2020-03-12T10:00:29.323500Z

(defn from-yaml-via-jar [jar-path s]
  (let [{:keys [exit out err]} (sh "java" "-jar" jar-path "generate" "--input-format" "yaml" :in (<http://java.io|java.io>.StringReader. s))]
    (if (zero? exit)
      (cheshire/parse-string out)
      (throw (ex-info "" {:type :exit
                          :exit/code exit
                          :exit/message (str out err)})))))

(defn from-yaml [fallback-jar input]
  (let [s (slurp input)]
    (try
        (cfn/parse s)

        (catch org.yaml.snakeyaml.error.YAMLException e
          (if fallback-jar
            (from-yaml-via-jar fallback-jar s)
            (do
              (println "Did you consider using the --fallback-jar option to be able to read custom AWS tags?")
              (throw e)))))))

borkdude 2020-03-12T10:03:12.324100Z

shelling out to java: that's also what the GraalVM compiled deps.clj does πŸ™‚. it's kind of the entire of point of the tool, to create a classpath and then launch a JVM πŸ™‚

2020-03-12T10:04:52.325200Z

yeah nice πŸ™‚ I’m not doing the same though if that’s what you mean. I’m shelling out to the uberjar I’m trying to run via Graalvm in the first place. The yaml parsing fails in Graal, but succeeds in the jar ..

borkdude 2020-03-12T10:06:06.325800Z

haha yeah, that's a nice fallback πŸ˜›

2020-03-12T10:06:40.326200Z

It’s really my last resort. I gave up this yaml parsing thing

borkdude 2020-03-12T10:06:59.326500Z

it really is a rabbit hole, isn't it.

2020-03-12T10:08:25.328Z

yeah and I only really wanted to use it for importing cloudformation templates. So it started as nice to have this yaml file importing part. Now time for some real features with Sci 😎

Nico 2020-03-12T14:37:55.328700Z

can you use core.spec within something graalvm-compiled with clojure 1.9.0?

borkdude 2020-03-12T14:48:42.329Z

you can also use it again now with 1.10.2-alpha1

Nico 2020-03-12T15:02:16.329200Z

oh, awesome!