Fork me on GitHub
#clojure
<
2023-06-23
>
DerTev14:06:44

Is there a way to display images in seesaw? :thinking_face:

genmeblog14:06:40

As I see in the code image should be a java.awt.Image or java.swing.ImageIcon object. If you need to load image from file you can steal the code from Clojure2d: https://github.com/Clojure2D/clojure2d/blob/master/src/clojure2d/core.clj#L229-L251

DerTev15:06:13

I'll try, thanks!

Noah Bogart15:06:25

I'm working on a library that defines many "rules". I've split each of the rules into separate files/namespaces for clarity and ease of development. To load these, I have a big :require block in my main namespace declaration that lists them all: (:require noahtheduke.splint.rules.lint.assoc-fn noahtheduke.splint.rules.lint.body-unquote-splicing ...) Doing some testing, it seems this is rather slow. Timings done by wrapping the ns call in time: With the require block, it takes roughly 3.2 seconds, and without, it takes roughly 1.7 seconds. Using load-file instead of a require block, it takes the same time to load the empty ns plus load-file calls, so it's not the ns/`:require` itself, it's just how long it takes clojure to load files. is there anything to be done about this?

Alex Miller (Clojure team)15:06:53

it's not the ns or require themselves that are slow, it's what's in the rule files so ... what's in the rule files

Noah Bogart15:06:41

a macro that calls into another macro that parses s-expressions into predicate functions lol

Noah Bogart15:06:53

"well there's your problem!"

Alex Miller (Clojure team)15:06:29

have you tried aot compiling

Alex Miller (Clojure team)15:06:48

that lets you do all that macro stuff once and not at runtime

Noah Bogart15:06:36

I have :gen-class so I can turn this into a jar/uberjar, but I haven't tried running compile or anything to see if that helps. i can look into that

Noah Bogart15:06:52

I don't know much about compiling, to be honest

Alex Miller (Clojure team)15:06:57

well, macros is compiling :)

Alex Miller (Clojure team)15:06:59

once you've compiled, the time is mostly var creation and initialization

Alex Miller (Clojure team)15:06:09

and a smidge of classloading

Alex Miller (Clojure team)15:06:12

https://clojure.org/guides/dev_startup_time might help you try some stuff without bothering to make a jar

👍 2
Noah Bogart15:06:54

Setting that up cut down the big ns declaration from 3.2 seconds to .8 seconds. Much improved, thank you