clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
oliver 2021-01-23T16:59:32.043900Z

Hello, folks. I want to use spec to define the shape and structure of some data and validate data with it. I'm trying to add some versioning. I'm thinking multiple namespaces could work, e.g. :my.spec.v1/thing, :my.spec.v2/thing, but I'm not sure whether that'd be the right approach. Anyone got any experience with this or general advice?

Helins 2021-01-23T17:35:22.051100Z

I am experimenting with a novel CSS tool for Clojure(script) which is quite drastically changing the way I write CSS. However I do have one major problem with a lack of dead-code elimination. It is not specific to that CSS thing but it's a good example. Essentially, let us suppose a set of namespaces which contains CSS related vars. Some vars are used at runtime, but some are not. Those dead vars are truly dead, there is absolutely nothing using relying on them at runtime. Those are CSS Garden rules that I am sure are not used nor referenced in an advanced build. However, yes, the namespaces containing them are used at runtime. The problem is that those dead vars are not eliminated in advanced builds, which is indeed a problem since they are quite heavy code-wise. I find that intuitively surprising since there is nothing ambiguous or tricky about the fact they are dead. Shadow-cljs advanced build report does not shine any light on the matter. Any idea?

thheller 2021-01-23T17:50:30.051600Z

I'd suggest running shadow-cljs release app --pseudo-names and then looking at the actual resulting code

👍 1
thheller 2021-01-23T17:50:55.052300Z

foo.bar/thing will be named foo$bar$thing so it is relatively easy to search stuff

thheller 2021-01-23T17:51:20.052900Z

then identify what the code does and that usually tells you why it isn't removed (usually stuff getting stored in an atom or so

Helins 2021-01-23T18:21:36.055600Z

@thheller Oh, it's just I might have been mistaken about how smart dead-code elimination is. It's actually not recursive, is it? Because my scenario is essentially this:

(def a {:something 42})

(def b [a])
And b is never used elsewhere. So I was thinking that both a and b would be removed, but they are not. Is it because b references a ?

Helins 2021-01-23T18:24:34.056100Z

Well I am not sure that b is not removed, but a definitely isn't.

thheller 2021-01-23T18:28:52.056900Z

closure does not recognize all CLJS datastructures as "pure" so some are not removed

thheller 2021-01-23T18:29:46.057600Z

simple maps usually are removed but it really depends on whats in them

oliver 2021-01-23T18:33:47.059100Z

@thheller: shadow-cljs is amazing, thanks for all the great work.

💯 3
❤️ 6
Helins 2021-01-23T18:33:57.059200Z

That must be it because they is literally nothing else going on than gathering maps in vectors. Thanks, very helpful as always!

simongray 2021-01-23T18:37:05.059500Z

Seems sensible to me.