This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-03
Channels
- # announcements (8)
- # aws (2)
- # babashka (16)
- # beginners (173)
- # calva (13)
- # cider (4)
- # cljfx (6)
- # cljs-dev (108)
- # clojure (63)
- # clojure-australia (2)
- # clojure-dev (10)
- # clojure-europe (73)
- # clojure-italy (8)
- # clojure-nl (4)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojurescript (49)
- # clojureverse-ops (4)
- # community-development (3)
- # core-async (23)
- # cursive (3)
- # data-science (5)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (13)
- # helix (5)
- # introduce-yourself (1)
- # lein-figwheel (1)
- # lsp (36)
- # malli (1)
- # meander (2)
- # membrane (4)
- # music (8)
- # nextjournal (51)
- # off-topic (47)
- # other-languages (5)
- # pathom (31)
- # pedestal (5)
- # planck (14)
- # polylith (5)
- # portal (1)
- # re-frame (30)
- # react (2)
- # reagent (24)
- # releases (1)
- # rewrite-clj (18)
- # ring (9)
- # sci (33)
- # shadow-cljs (49)
- # testing (3)
- # tools-build (21)
- # tools-deps (29)
- # vim (19)
- # web-security (1)
- # xtdb (12)
Are there examples of using scittle
with other JS libraries besides the bundled ones? (I'm thinking of D3 here but any examples of requiring an external JS lib from scittle
will probably help me get started)
@afoltzm scittle currently doesn't support loading JS libraries in the ns form. The way this would work is just by loading d3 in a script tag and then using js/D3.whatever
@afoltzm Example:
<html>
<head>
<script src="" type="application/javascript"></script>
<script src=""></script>
<script type="application/x-scittle">
(-> (js/d3.selectAll "p") (.style "color" "blue"))
</script>
</head>
<body>
<p>This is a paragraph</p>
<p>This is another paragraph</p>
</body>
</html>
Wanted to say that sci is exceptionally cool. I'm not aware of anything similar in other languages.
Also, I have a question. Does sci self host? In other words, can sci use sci to eval clojure code isolated from the outer sci layer? Just curious for now. It's like... We've got this Docker for Clojure, just without tons and tons of copied stuff, containers, images, versions, one might say bloat.
@teodorlu SCI cannot evaluate itself, but what is evaluated in a SCI context, created with (sci/init {...})
, does not, or should not affect the host. E.g. creating vars in a context does not create vars in the Clojure runtime.
some people use SCI in the JVM to evaluate programs coming from web requests. SCI gives a form of isolation and you can control what vars are or are not allowed. One thing SCI doesn't do is protect you from long-running or never-ending loops, but both JVM and Node.js have lower level primitives for this
There are two libs for this: ā¢ https://github.com/babashka/babashka/blob/master/doc/projects.md#clojure-term-colors ā¢ https://github.com/AvisoNovate/pretty
In #nbb (SCI on Node.js) I've used something to kill for-ever running loops. E.g. if you type (range)
in the REPL and then press ctrl-c, you're still in the REPL and the eval loop is killed.
in the JVM, CIDER uses .stop() on Threads to do the same. Unfortunately GraalVM doesn't support it, since they have decided not to implement the deprecated method
as a note, cider uses .interrupt
, wait, then .stop
, https://github.com/nrepl/nrepl/blob/d875260afcecd6bfc2ff53a0be437cf2972250f4/src/clojure/nrepl/middleware/session.clj#L176
This allows tasks that do support interruption to property clean up.
Ahh, nice, thanks for the link. So... First try to kill "nicely", then permit 5 seconds for cleanup, then stop forcibly?
Yes, it seems like a reasonable balance which is good enough for trusted code in a dev environment. If you need true isolation, you probably want to run it in a separate process with appropriate sandboxing.
https://clojurians.slack.com/archives/C015LCR9MHD/p1643925719149929 Does that mean that the answer to my original question is that ā¢ It's not really necessary to stack two sci interpreters for isolation because they can run "next to each other" ā¢ And the same isolation guarantees could be provided with an interface to sci/init and sci/eval from Babashka ? Just that it hasn't been needed so far?