Using "sci" I have managed to successfully create a native image of my application, but when executed the application crashes. When the application is executed as a jar it does not crash.
@hairfire could be a reflection issue. can you post the error in a gist or so?
Yes. I'll figure out how to post a gist. I've never done it before. Any link to how to "gist"?
https://gist.github.com/pwhittin/565327507a8ea6d820e4f06356b01a2d
Looks like a reflection problem
I'm using clojure.spec.alpha to analyze the map created by executing "sci"
@hairfire the reflection happens here: > at edpdl.platform_utils$index_of.invokeStatic(platform_utils.cljc:38)
so you could probably use (set! *warn-on-reflection* true)
in your code and solve it
and then it should either work, or you'll get the next error to fix
Thanks for the tips. I'll keep going.
@hairfire cool, keep me posted about your progress
IT WORKS!!!! BTW, in one instance of using my embedded C++ code generator program the input file contained 2,341 non-blank lines of "DSL" code, and produced 27,936 non-blank lines of C++ code, which is approximately 30% of the total non-blank lines of code for the entire embedded applicaiton.
Using Clojure, and now "sci", our team is saving MANY MANY hours of hand coding that we used to do!
:-D
BTW, the native image for Linux is 51M, while the jar file is 457MB.
Next is creating a native image for Windows. I assume I need to do that on Windows, right?
@hairfire I use appveyor for this. you can check one of my projects like babashka, clj-kondo or jet: https://github.com/borkdude/jet/blob/master/appveyor.yml
not sure if this works with closed source projects btw. Github actions may work for that, if you have a paid Github account, not sure
@hairfire Iβm glad you solved you problem, and glad to see lisp adoption, but to be honest i wonder why sci? i.e. weβre concatenating and printing strings in all various languages for decades, what alternatives did you consider/compare with?
Essentially I needed to create a compiler from a DSL to C++. My approach was to design a DSL that is easily transformed to valid Clojure. The valid Clojure, when evaluated, results in a big nested map, with Clojure acting as the syntax analyzer. I use Clojure's spec as the semantic analyzer. Next I use the powerful Clojure tools to transform, create and optimize the data structures needed for C++ code generation. The sci library comes in because I want a GraalVM native executable, which I couldn't get with regular Clojure evaluation of the DSL.
@razum2um he used sci to get it to run in a native binary. he already had a working Clojure implementation