This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-02
Channels
- # announcements (4)
- # babashka (1)
- # beginners (4)
- # cider (4)
- # clerk (3)
- # clojure (25)
- # clojure-brasil (5)
- # clojure-europe (6)
- # clojure-nl (1)
- # clojure-norway (48)
- # clojure-uk (4)
- # clojuredesign-podcast (3)
- # clojurescript (1)
- # conjure (1)
- # emacs (23)
- # hyperfiddle (3)
- # jobs (6)
- # lsp (12)
- # off-topic (5)
- # polylith (13)
- # reagent (8)
- # reitit (18)
- # sci (20)
- # shadow-cljs (8)
- # specter (3)
- # squint (3)
A port of Clojurescript Koans using SCI. Thank you, @borkdude, to make that possible.
I have a confession, I tried to change as little as possible, so I first attempted to use self-hosted Clojurescript. But after trying to make it work using an updated Clojurescript and shadow-cljs I gave it up and decided to port to SCI. It took less time to convert to SCI than the time I used to try to use self-hosting. Also, I can use advanced compilation, and the SCI version is way smaller than the Clojurescript one. SCI is an incredible tool.
great to hear. there's another option emerging for this kind of use case, it's the cherry compiler that can be embedded: https://github.com/squint-cljs/cherry/blob/main/doc/embed.md but it's less mature than SCI (simply because it's newer) - the only benefit of that is better performance (which should not matter for a tool that teaches how to use Clojure)
More options are great! I will check it out, but the current bundle size is enough, so I will probably keep on the more mature tool. Does SCI track clojure or clojurescript when there are different behaviors? I found some differences from clojure while I was writing some lessons on another project.
SCI doesn't track clojure or clojurescript unless there are new behaviors like the one with keyword arguments vs passing a map. This is so that SCI can be used with older version of Clojure as well. Right now it supports 1.9
Only corner cases, like calling max
without arguments. Cases where Clojure returns exceptions, I think. I haven't checked the Clojurescript behavior yet to confirm that it is the same.
$ bb -e '(max)'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ArityException
Message: Wrong number of args (0) passed to: clojure.core/max
The CLJS version only throws because max
in call position is implemented using a macro. What happens in SCI is more like:
plk -e '(let [m max] (m))'
subs
throws in clojure with index out of bounds when using an index larger than the string size.
Ok, so when are cases like this it should behave like Clojurescript except when there is a macro implementation?
of course if you wanted to, you could override subs
in clojure.core with your own:
{:namespaces {'clojure.core {'subs ...}}}
`Yeah, I suspected that was the case (that it behaved like in cljs). Thank you, I need to think if I would go that far, not really sure if it is necessary. I would just show an example throwing, so the user would not be surprised when it happened. There will be other exceptions that I can use 😉