Fork me on GitHub
#squint
<
2022-08-18
>
borkdude12:08:09

Published a new version of #clavascript with better JSX support. https://twitter.com/borkdude/status/1560247158774943746 cc @armed (gonna port this to cherry too)

๐Ÿ˜ 2
lilactown14:08:22

provocative questions: 1. what if we only had transducers, and eschewed map filter with the collection passed in? 2. what if we moved transducers to its own namespace? I would imagine these wild changes would be mutually exclusive, but maybe not!

borkdude14:08:27

I can see why that is attractive from a language designer's view to get the best performance out of programs that people write, but I don't find it attractive from a familiarity perspective: I think we should stick to what people know from Clojure/Script as much as possible.

borkdude14:08:33

Why would you like to move transducers to their own namespace?

lilactown14:08:55

just thinking of ways to enable good tree shaking. otherwise you have to include all of the transducer logic whenever you use map, even if you never use it as a transducer

borkdude14:08:44

hmm, good point!

borkdude14:08:02

how much extra is it though

lilactown14:08:30

I haven't done it yet. been thinking about how I would want to implement transducers

lilactown14:08:01

there's the transducer-js protocol that we could use, which is different than the way that Clojure does it with different function arities

borkdude14:08:04

I found the usage of the two-arity for map, filter, etc pretty error-prone. I was happy that I finally added linting to clj-kondo to find problems like this: (first (map identity))

borkdude14:08:09

I've argued that different functions: mapping, filtering etc would have been better for adding the transducer logic

borkdude14:08:21

in JVM Clojure I mean

borkdude14:08:05

But a different namespace would have the same effect (+ we don't have to teach clj-kondo about new core vars)

borkdude14:08:40

(ns foo (:require [clava.transducers :as t]))
(t/into #{} (t/map identity) [1 2 3])
Something like this?

lilactown14:08:44

if we didn't have the 2-arity version take a collection, then you could have it be composition. so you could do something like:

(->> (map inc) (filter even?) (take 5))
and it would return a transducer function

lilactown14:08:03

yeah that's exactly what I was thinking re: the namespace

lilactown14:08:10

I suppose the ->> is only one character less than comp but for some reason it reads better to me

lilactown14:08:24

probably not worth the confusion

borkdude14:08:24

Is that the same as (t/comp (map inc) (filter even? (take 5))?

lilactown14:08:46

yeah exactly

borkdude14:08:12

yeah, let's start with the least surprising stuff that is most similar to CLJS

borkdude14:08:19

and we can always add that 3-arity later

borkdude14:08:32

ok, I'm with you on the extra namespace now

lilactown14:08:42

sure, let's try it

borkdude14:08:04

btw, I don't think we have filter yet :)

lilactown14:08:24

I'm going to create some issues

lilactown14:08:46

filter / remove / mapcat / etc. might be good first issues for people to take on

lilactown14:08:06

shall I make an issue for each one?

borkdude14:08:14

sounds good yes

lilactown14:08:49

I'm also going to make an issue for transducers with the separate ns context, and start sketching out the internal design for them

๐Ÿ‘ 1
lilactown14:08:13

this might be a good test for the protocol changes

๐Ÿ‘ 1
borkdude14:08:42

btw, I've sent you an invitation for the github org, I wonder if you got it

lilactown14:08:25

I did get it, it's in my inbox. thanks for reminding me

borkdude14:08:41

It seems the bundling of vite + solidjs + clava works really well: https://twitter.com/borkdude/status/1560271562569555972 9kb of JS (4kb zipped) for a reactive example

๐Ÿ’ฏ 3
โค๏ธ 1
borkdude15:08:01

I want to deploy the solidjs example at https://clavascript.github.io/demos/clava/solidjs/ but the problem is that the built solidjs expects to be deployed at the root of the website, I think. So it tries to load assets from https://clavascript.github.io/demos/assets/... Does anyone know what the solution to this could be?

lilactown15:08:18

is the html auto generated somehow?

borkdude15:08:41

yes, using npm run build

borkdude15:08:27

I suspect that you can put the base url somewhere in a config file, but I don't know which

lilactown15:08:27

yeah, was about to link to https://vitejs.dev/guide/static-deploy.html#github-pages which says to set the base property to the repo

lilactown15:08:34

never used Vite before. seems neat

borkdude15:08:38

yep, npx vite build --base=/clava/solidjs/ seems to do the trick

lilactown15:08:36

where would I put a transducers.cljs that would be accessible to Clava programs?

borkdude15:08:01

@lilactown Well, core.js is in the root of the project, so maybe just in the root?

borkdude15:08:41

Oh wait, transducers.cljs ?

lilactown15:08:31

I was thinking about writing transducers in clava to force me to get protocols to work right ๐Ÿ™‚

borkdude15:08:33

I think what you should do in this case is just check in the compiled file for distribution

borkdude06:08:22

Btw, I'd be fine writing it all in JS to ensure the best perf and and smallest code output

lilactown16:08:45

I'd be fine with it too, but I think it would also be cool to figure out how to have protocols be small and performant

lilactown16:08:53

i guess it depends on how itchy we are to have transducers

lilactown16:08:35

at the end of the day, the way that clojure does transducers using different arity produces way less code than using prototype dispatch

lilactown16:08:46

haven't done any benchmarks yet

lilactown16:08:56

I'll open a draft PR for protocols this AM

๐Ÿ‘ 1
Brandon Stubbs17:08:09

Am I missing something? What do I need to do once I have added a function to core.js for bump-core-vars to pick it up?

borkdude17:08:14

just restart bb dev

Brandon Stubbs17:08:21

Thanks, my issue I was using yarn instead of npm and something seemed to have cached

borkdude17:08:03

The bb dev task deletes some analysis file which will evict the cache of core functions

Aleed17:08:55

could the mutable and immutable options work in tandem? e.g. if you want most of your program to be immutable but critical, interop parts to work directly on JS but with Clojureโ€™s methods it seems like Clava is deviating enough from CLJS that this will not be possible nor intended?

borkdude17:08:09

@UPH6EL9DH This is not in scope of clava, but you could use clava's stdlib from ClojureScript

Aleed17:08:55

oh ok nice to know that may be possible, thanks

borkdude17:08:35

or you can use clava's stdlib from cherry even

๐Ÿ‘ 1