sci

https://github.com/babashka/SCI - also see #babashka and #nbb
hairfire 2021-06-25T14:21:50.134700Z

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.

borkdude 2021-06-25T14:22:22.135300Z

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

hairfire 2021-06-25T14:23:23.136300Z

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

borkdude 2021-06-25T14:25:30.136500Z

@hairfire https://gist.github.com/

1πŸ‘
hairfire 2021-06-25T14:29:45.137100Z

Looks like a reflection problem

hairfire 2021-06-25T14:31:34.138400Z

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

borkdude 2021-06-25T14:33:10.139300Z

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

borkdude 2021-06-25T14:33:25.139700Z

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

borkdude 2021-06-25T14:33:37.140100Z

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

hairfire 2021-06-25T14:34:19.140800Z

Thanks for the tips. I'll keep going.

borkdude 2021-06-25T15:44:07.141300Z

@hairfire cool, keep me posted about your progress

hairfire 2021-06-25T16:06:01.143500Z

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.

hairfire 2021-06-25T16:07:05.144300Z

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

borkdude 2021-06-25T16:10:49.145200Z

:-D

hairfire 2021-06-25T16:10:53.145300Z

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

hairfire 2021-06-25T16:11:26.145900Z

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

borkdude 2021-06-25T16:12:10.146500Z

@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

1πŸ‘
borkdude 2021-06-25T16:12:58.147200Z

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

2βœ”οΈ
razum2um 2021-06-25T22:48:08.150200Z

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

hairfire 2021-06-26T16:49:05.151600Z

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.

2πŸ‘
borkdude 2021-06-25T22:50:50.151100Z

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