https://github.com/paintparty/lasertag A library for categorizing values in Clojure, ClojureScript, and Babashka. v0.12.0 This release focused primarily on perf improvements and the addition of a few missing tags. Release notes https://github.com/paintparty/lasertag/releases/tag/v0.12.0
https://github.com/galatyn/clua: Clojure library for running untrusted Lua 5.5 scripts. It is Lua 5.5 interpreter in Clojure for safely executing untrusted scripts inside Clojure/JVM applications. Some features: • Full Lua 5.5 language support • Sandboxed by default • Thread-safe by design • Minimal dependencies Example:
(require '[clua.core :as lua]
'[clua.stdlib.core :as stdlib])
;; Arithmetic, strings, tables
(lua/execute "
local t = {}
for i = 1, 5 do t[i] = i * i end
return t
")
;; => {:ok true, :result {1 1, 2 4, 3 9, 4 16, 5 25}}this is so dang cool
Very nice, Andrei! Is the interpreter state a persistent data structure (value) that can be copied? How high are boundary conversion costs of types between Lua and Clojure?
oh wait, this is purely in clojure, no ffi. i'm even more surprised and impressed. how's performance?
Hi @whilo! You can check sections Persistent State — Globals Across Runs and Multithreading at https://github.com/galatyn/clua for some details. In short:
• sandbox is a regular Clojure structure so you can do whatever you want.
• Compiled script is also data structure and potentially can be used over threads or whatever, but at the moment it is not available at high level API. Easy to expose if needed.
• Script state (vars, stack etc) should not be shared between threads.
A small example:
;; Create the sandbox once, reuse across threads
(def sb (stdlib/sandbox-standard))
(future (lua/execute sb "return compute()"))
(future (lua/execute sb "return compute()"))@nbtheduke Hi there 🙂 Since it is pure interpreter, it is not as performant as Clojure code, but as for scripting engine I would say it is fast enough 🙂 Just as example, Lua script running by interpreter:
(time (count (lua/execute "
local t = {}
for i = 1, 1000000 do t[i] = i * i end
return t
")))
"Elapsed time: 4835.855417 msecs"
Clojure equivalent:
(time (count (reduce
(fn [m i]
(assoc m i (* i i)))
{}
(range 1000000))))
"Elapsed time: 652.967209 msecs"
In this example pure Clojure code is 7.4 times faster.Awesome Backseat Driver: A Copilot Plugin Marketplace for Clojure work with Calva Backseat Driver. Very WIP. This first batch includes a starter pack of skills and agents for Clojure, and Clojure Editing. Plus skills for #babashka, #joyride, and #epupp. More to come and hopefully other Clojurians will contribute domain skills and/or competing and complementary core Clojure skills. • https://github.com/BetterThanTomorrow/awesome-backseat-driver See also the new #backseat-driver channel. 🙏