Fork me on GitHub
#sci
<
2021-06-25
>
hairfire14:06:50

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.

borkdude14:06:22

@hairfire could be a reflection issue. can you post the error in a gist or so?

hairfire14:06:23

Yes. I'll figure out how to post a gist. I've never done it before. Any link to how to "gist"?

hairfire14:06:45

Looks like a reflection problem

hairfire14:06:34

I'm using clojure.spec.alpha to analyze the map created by executing "sci"

borkdude14:06:10

@hairfire the reflection happens here: > at edpdl.platform_utils$index_of.invokeStatic(platform_utils.cljc:38)

borkdude14:06:25

so you could probably use (set! *warn-on-reflection* true) in your code and solve it

borkdude14:06:37

and then it should either work, or you'll get the next error to fix

hairfire14:06:19

Thanks for the tips. I'll keep going.

borkdude15:06:07

@hairfire cool, keep me posted about your progress

hairfire16:06:01

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.

hairfire16:06:05

Using Clojure, and now "sci", our team is saving MANY MANY hours of hand coding that we used to do!

hairfire16:06:53

BTW, the native image for Linux is 51M, while the jar file is 457MB.

hairfire16:06:26

Next is creating a native image for Windows. I assume I need to do that on Windows, right?

borkdude16:06:10

@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

๐Ÿ‘ 2
borkdude16:06:58

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

โœ”๏ธ 5
razum2um22:06:08

@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?

hairfire16:06:05

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.

๐Ÿ‘ 5
borkdude22:06:50

@razum2um he used sci to get it to run in a native binary. he already had a working Clojure implementation