sci

https://github.com/babashka/SCI - also see #babashka and #nbb
kwrooijen 2020-06-25T10:30:38.000900Z

Change to sci-nl ?

borkdude 2020-06-25T10:31:20.001100Z

lol?

kwrooijen 2020-06-25T10:31:47.001800Z

Just a joke haha

borkdude 2020-06-25T10:31:53.002Z

OK, tot zover kunnen we gewoon Nederlands praten, maar laten we omschakelen naar Engels als er een niet-Nederlands iemand bij komt 😄

kwrooijen 2020-06-25T10:32:31.002200Z

😂

kwrooijen 2020-06-25T10:34:22.003300Z

By the way, I remember reading something in the Malli channel about trimming the sci build size for CLJS?

kwrooijen 2020-06-25T10:34:30.003600Z

I don't think it's in the chat anymore though

borkdude 2020-06-25T10:34:51.004Z

I think @ikitommi had ideas about this.

kwrooijen 2020-06-25T10:35:09.004300Z

SCI is about half my entire build at the moment haha

borkdude 2020-06-25T10:35:59.005100Z

One reason is that it adds lots of docstrings you might not need. Another reason is that it holds on to functions you might not need. But that's hard to predict in an interpreter, since you don't know what users want to use

kwrooijen 2020-06-25T10:37:36.006200Z

Interesting. The second one makes sense. In my case everything read by SCI is located in EDN file(s)

borkdude 2020-06-25T10:38:06.006600Z

But sci doesn't know before-hand what's in your EDN files

borkdude 2020-06-25T10:38:47.007300Z

I'm open to ideas of making a more minimal build through some API. The only condition I have is that it should not affect performance of GraalVM binaries like babashka

kwrooijen 2020-06-25T10:39:52.008Z

I think it would make sense to have some kind of optional build size optimization, which is off by default

kwrooijen 2020-06-25T10:40:12.008800Z

So that no one is affected, unless they opt-in knowing what they're doing

borkdude 2020-06-25T10:40:55.009800Z

I think the idea that ikitommi has is more fine-grained. The namespaces.cljc file contains top-level datastructures with all the core namespaces in it. Those should be lifted into a function and then users can do a select-keys or dissoc on those namespaces, and making a top-level value out of that. That should help.

borkdude 2020-06-25T10:43:27.010100Z

https://github.com/borkdude/sci/issues/357

kwrooijen 2020-06-25T10:44:17.011200Z

core namespaces being the namespaces available in SCI?

borkdude 2020-06-25T10:44:17.011300Z

I've thought about a default setting, but I can't think of a scenario where there's only one default setting that fits all

borkdude 2020-06-25T10:44:26.011500Z

yes, clojure.core, clojure.string, etc

kwrooijen 2020-06-25T10:47:33.012800Z

Checked out the namespaces.cljc file, and I get what you mean now

kwrooijen 2020-06-25T10:47:51.013300Z

Basically if you remove a NS / function from there, that would be it?

kwrooijen 2020-06-25T10:48:19.013800Z

Well not literally remove, but just filter out

borkdude 2020-06-25T10:49:17.015100Z

yes, but that should be an option to the user. e.g.:

(sci.core/add-namespace opts 'clojure.core {:exclude [...]}) or `:include
` something like that

kwrooijen 2020-06-25T10:49:32.015300Z

Yeah of course

kwrooijen 2020-06-25T10:50:58.016500Z

I wonder if it would work if I took all my EDN files, get all symbols, and just :include all of that. I assume it wouldn't since those symbol might have dependencies not listed in there?

borkdude 2020-06-25T10:51:11.016800Z

yep, could very well be.

borkdude 2020-06-25T10:51:39.017600Z

if x depends on y and you're not including y, you're doomed

borkdude 2020-06-25T10:52:19.017900Z

but with some testing it should be doable to figure it out

borkdude 2020-06-25T10:53:43.018400Z

btw, the build is still a lot smaller than when you go with self-hosted CLJS which is 8 megabytes or so

borkdude 2020-06-25T10:53:55.018600Z

at least for https://borkdude.github.io/re-find.web/

kwrooijen 2020-06-25T10:54:20.019Z

Hey I'm not complaining 😛

kwrooijen 2020-06-25T10:55:03.019400Z

I'm able to do some amazing things with Sci, which is great

borkdude 2020-06-25T10:57:19.019800Z

would be great if we could reduce the build some more. <hammock time/>

ikitommi 2020-06-25T11:27:28.022300Z

hi. just prepared malli for dce, users can cut out schemas, from def to defn and one top-level def that can be customized to have the default (all schmas) or an empty registry, which can be customly collected

ikitommi 2020-06-25T11:28:06.023300Z

select-keys won’t work here, as Closure tracks down things statically, if you call the function that has everything, everything is added.

ikitommi 2020-06-25T11:28:38.024Z

but, one can create a new map manually, having just the needed key->value mappings and only those will be in.

borkdude 2020-06-25T11:30:22.026Z

what about compile/macro time select-keys?

1
ikitommi 2020-06-25T11:30:22.026100Z

I think there are two options here. For both: make all the def defns and split them into smaller parts, e.g. clojure-set-bindings, clojure-walk-bindingsetc. Then, the options:

ikitommi 2020-06-25T11:30:53.026500Z

could work.

ikitommi 2020-06-25T11:33:01.029Z

but the options :): 1. have a global def collecting all int sci.core and create a new entrypoint, like sci.custom that doesn’t have the def, but an api that requires the bindings as parameter 2. have a compiler switch (`:closure-defines` / :jvm-opts) which allow to empty the default registry 3. macro-time select-keys, might work, tested something like this, coudn’t get it to work

ikitommi 2020-06-25T11:33:21.029400Z

I think 1 would be relatively easy

borkdude 2020-06-25T11:33:32.029700Z

I also like 1. Could you post this into the issue?

borkdude 2020-06-25T11:34:01.029900Z

https://github.com/borkdude/sci/issues/357

ikitommi 2020-06-25T11:36:53.030300Z

did.

❤️ 1
ikitommi 2020-06-25T11:42:16.030800Z

didn’t test the syntax, buf something like:

(require '[sci.custom])
(require '[sci.namepaces :as n])
(require '[clojure.walk :as walk])

(def sci-eval 
  (sci.custom/evaluator 
    {:bindings (merge (n/cloure-core-bindings) 
                      (n/clojure-set-bindings) 
                      {'walk (n/copy-var clojure.walk/walk...)})})

(sci-eval "(int? 1)")
; =&gt; true

ikitommi 2020-06-25T11:43:08.031500Z

also, options not to include docstring via options would be great, would allow tiny sci runtimes.

borkdude 2020-06-25T11:43:55.033Z

When I added the docstrings, the bundle grew with 200kb. I recently experimented with a closure defines to exclude them but it only mattered 8kb or so. Don't know what's up, needs more attention...

👀 1
ikitommi 2020-06-25T11:44:16.033400Z

There is a one clojure-based startup in Finland, running clojure in blockchain (real estate smart contracts), poked them to use sci instead.

ikitommi 2020-06-25T12:32:06.034600Z

did the size decrease in clojure.core? Not sure how those are reported.

borkdude 2020-06-25T12:33:11.034800Z

I just looked at the total size of sci.min.js overall