The best way to load clojure add-ons?

Let’s imagine that a clojure program wants to load clojure files during runtime. I want to emulate weechat scripting system in clojure.

The clojure files are stored as ~/.program/scripts/*.clj

I could, for example, add ~/.program/scripts to classpath, scan ~/.program/scripts, and require clj files in ~/.program/scripts. Is there a better way?

There’s also load-file.

Ideally, I’d also want sandboxed execution, but even java security manager has security issues. It is an intractable problem for now.

How would you use load-file to mimick weechat scripts?

I don’t know weechat scripts, but if you need sandboxing you could also use a Clojure interpreter like sci.

1 Like

That’s a great option for guaranteed sandboxing. Sandboxing native clojure is an intractable problem. A minimal clojure dialect is sandboxed by default.

It seems that combination of GraalVM and sci enables a lot of things including dad which I always wanted to have.

Also, depending who the target audience is, you can check out: https://github.com/benzap/eden

It is also an interpreted, sandboxed language meant to be run embedded inside Clojure. It mostly mimic Lua syntax, and is imperative by nature.